Skip to content

Commit

Permalink
Merge remote-tracking branch 'antonio-origin/porkchop_and_hybrid_modu…
Browse files Browse the repository at this point in the history
…les' into develop
  • Loading branch information
DominicDirkx committed Oct 23, 2023
2 parents d8cf039 + 34b8f4a commit 7dd55ad
Show file tree
Hide file tree
Showing 48 changed files with 1,507 additions and 15 deletions.
52 changes: 38 additions & 14 deletions tudatpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,46 @@ INSTALL_PURE_PYTHON_MODULE_DIR(bodies)
INSTALL_PURE_PYTHON_MODULE_DIR(plotting)
INSTALL_PURE_PYTHON_MODULE_DIR(util)
INSTALL_PURE_PYTHON_MODULE_DIR(io)

# Create hybrid C++/Python modules
macro(CREATE_HYBRID_CPP_PYTHON_MODULE module_dir_name)
install(DIRECTORY kernel_hybrid/${module_dir_name}/ DESTINATION "${TUDATPY_INSTALL_PATH}/${module_dir_name}")
file(COPY kernel_hybrid/${module_dir_name}/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${module_dir_name}/)
endmacro()
# CREATE_HYBRID_CPP_PYTHON_MODULE(utils)
CREATE_HYBRID_CPP_PYTHON_MODULE(astro)
CREATE_HYBRID_CPP_PYTHON_MODULE(trajectory_design)
CREATE_HYBRID_CPP_PYTHON_MODULE(constants)
CREATE_HYBRID_CPP_PYTHON_MODULE(interface)
# CREATE_HYBRID_CPP_PYTHON_MODULE(io)
CREATE_HYBRID_CPP_PYTHON_MODULE(math)
CREATE_HYBRID_CPP_PYTHON_MODULE(numerical_simulation)

# TODO: Automatic exposure of hybrid C++/Python modules
# This involves solving the dependencies which conda
# uses for the builds. The tudat-feedstock contains the
# recipes used to build tudatpy.
# To build tudatpy, conda creates first machine images
# in which to run the build:
# - Linux (Docker)
# - OSX
# - Windows
# When attempting to build tudatpy using the automatic
# kernel exposure below, the build processes fail with a
# `module not found: numpy` error.
#
## Install the Python components of kernel modules
#macro(INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE module_dir_name)
# install(DIRECTORY kernel_hybrid/${module_dir_name}/ DESTINATION "${TUDATPY_INSTALL_PATH}/${module_dir_name}")
# file(COPY kernel_hybrid/${module_dir_name}/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${module_dir_name}/)
#endmacro()
## INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(utils)
##INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(astro)
#INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(trajectory_design)
##INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(constants)
##INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(interface)
## INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(io)
##INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(math)
##INSTALL_PYTHON_COMPONENTS_OF_HYBRID_MODULE(numerical_simulation)
# The cause of this error is that the python interpreter
# called here (PYTHON_EXECUTABLE) is badly configured.
# This means somewhere along the build
#
# SOLUTIONS ATTEMPTED
# - build.sh
# - FAILED: Adding conda install statement before make
#
## Expose hybrid C++/Python modules
# POSSIBLE SOLUTIONS:
# - meta.yaml
# - `requirements` may not be correctly set up
# -----------------------------------------------------
#file(COPY ${CMAKE_CURRENT_LIST_DIR}/setup_hybrid_modules.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../)
#macro(EXPOSE_HYBRID_MODULES)
# foreach(module ${ARGN})
Expand Down
2 changes: 1 addition & 1 deletion tudatpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._version import *
from tudatpy._version import *

Check warning on line 1 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

Missing module docstring

Check failure on line 1 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name '_version' in module 'tudatpy'

Check failure on line 1 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

Unable to import 'tudatpy._version'

Check warning on line 1 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

Missing module docstring

Check failure on line 1 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name '_version' in module 'tudatpy'

Check failure on line 1 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

Unable to import 'tudatpy._version'
from tudatpy.kernel import constants

Check failure on line 2 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name 'constants' in module 'tudatpy.kernel'

Check failure on line 2 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name 'constants' in module 'tudatpy.kernel'
from tudatpy.kernel import astro

Check failure on line 3 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name 'astro' in module 'tudatpy.kernel'

Check failure on line 3 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name 'astro' in module 'tudatpy.kernel'
from tudatpy.kernel import interface

Check failure on line 4 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name 'interface' in module 'tudatpy.kernel'

Check failure on line 4 in tudatpy/__init__.py

View workflow job for this annotation

GitHub Actions / pylinter

No name 'interface' in module 'tudatpy.kernel'
Expand Down
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/astro/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro` kernel module directly from tudatpy:
#
# from tudatpy.astro import <any>
#
# Without the statement below, importing the `astro` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro import *
28 changes: 28 additions & 0 deletions tudatpy/kernel_hybrid/astro/element_conversion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro.element_conversion` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro/element_conversion`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro.element_conversion` kernel module directly from tudatpy:
#
# from tudatpy.astro.element_conversion import <any>
#
# Without the statement below, importing the `astro.element_conversion` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro.element_conversion import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro.element_conversion import *
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/astro/frame_conversion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro.frame_conversion` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro/frame_conversion`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro.frame_conversion` kernel module directly from tudatpy:
#
# from tudatpy.astro.frame_conversion import <any>
#
# Without the statement below, importing the `astro.frame_conversion` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro.frame_conversion import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro.frame_conversion import *
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/astro/fundamentals/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro.fundamentals` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro/fundamentals`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro.fundamentals` kernel module directly from tudatpy:
#
# from tudatpy.astro.fundamentals import <any>
#
# Without the statement below, importing the `astro.fundamentals` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro.fundamentals import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro.fundamentals import *
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/astro/gravitation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro.gravitation` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro/gravitation`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro.gravitation` kernel module directly from tudatpy:
#
# from tudatpy.astro.gravitation import <any>
#
# Without the statement below, importing the `astro.gravitation` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro.gravitation import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro.gravitation import *
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/astro/polyhedron_utilities/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro.polyhedron_utilities` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro/polyhedron_utilities`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro.polyhedron_utilities` kernel module directly from tudatpy:
#
# from tudatpy.astro.polyhedron_utilities import <any>
#
# Without the statement below, importing the `astro.polyhedron_utilities` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro.polyhedron_utilities import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro.polyhedron_utilities import *
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/astro/time_conversion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro.time_conversion` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro/time_conversion`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro.time_conversion` kernel module directly from tudatpy:
#
# from tudatpy.astro.time_conversion import <any>
#
# Without the statement below, importing the `astro.time_conversion` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro.time_conversion import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro.time_conversion import *
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/astro/two_body_dynamics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.astro.two_body_dynamics` with
# its Python extensions defined in `tudatpy/kernel_hybrid/astro/two_body_dynamics`.
#
# This allows the import of all the C++ and Python submodules of the
# `astro.two_body_dynamics` kernel module directly from tudatpy:
#
# from tudatpy.astro.two_body_dynamics import <any>
#
# Without the statement below, importing the `astro.two_body_dynamics` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.astro.two_body_dynamics import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.astro.two_body_dynamics import *
32 changes: 32 additions & 0 deletions tudatpy/kernel_hybrid/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file, by virtue of the import statement below, merges
# the Tudat kernel module `tudatpy.kernel.constants` with
# its Python extensions defined in `tudatpy/kernel_hybrid/constants`.
#
# This allows the import of all the C++ and Python submodules of the
# `constants` kernel module directly from tudatpy:
#
# from tudatpy.constants import <any>
#
# Without the statement below, importing the `constants` kernel module
# would only be possible as follows, and hybrid Python/C++ modules would not
# be posible in tudatpy.
#
# from tudatpy.kernel.constants import <any>
#
# The reason why C++ kernel modules can only be imported as written above
# is an issue with the `def_submodule` function of pybind11. The issue is discussed
# [here](https://github.com/pybind/pybind11/issues/2639).
#
# We circumvent the issue by automatically creating an *empty* Python module for each
# kernel module and submodule, and exposing the kernel module or submodule from the
# Python module by adding the import statement below to the Python module's `__init__.py` (this file).
# This workaround was proposed in [this comment](https://github.com/pybind/pybind11/issues/2639#issuecomment-721238757).
#
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside the newly created Python
# module (at the same level as this file), which is not possible with the `def_submodule`
# function of pybind11.
# An added benefit of this method is that it makes it possible to write Python extensions
# and add them to the kernel modules simply by placing them inside this module!

from tudatpy.kernel.constants import *
Loading

0 comments on commit 7dd55ad

Please sign in to comment.