I have the following directory layout
awesome_package
\- module1.py
\- build
\- module2.so
I currently import module1 as
import awesome_package.module1
and module2 as
import sys
sys.path.append('path/to/awesome_package/build')
import module2
but I would like to be able to use the former syntax.
module2 is created by pybind11 in a fashion like:
PYBIND11_MODULE(module2, module2) {
module2.doc() = "C++ module wrapped for Python";
module2.def("some_cpp_function", some_cpp_function)
}
import awesome_package.build.module2
would work?__init__.py
files?). But you could use__init__.py
files and have the the code to append to sys path inside the__init__.py
file in the build directory. You would need another__init__.py
file in the root directory, and this one as far as I understand from the way you write can be empty. In that way you wouldn't need every time you write a script to add the code to append to path.