diff --git a/setup.py b/setup.py index 335380e..051699f 100755 --- a/setup.py +++ b/setup.py @@ -174,6 +174,12 @@ class BuildExtCommand(build_ext): module_pEp.libraries = libs module_pEp.extra_compile_args = compile_flags + global module_pybind11 + module_pybind11.include_dirs = includes + module_pybind11.library_dirs = libdirs + # module_pybind11.libraries = libs + module_pybind11.extra_compile_args = compile_flags + pEpLog("Include Dirs:", module_pEp.include_dirs) pEpLog("Libs Dirs:", module_pEp.library_dirs) pEpLog("Libraries:", module_pEp.libraries) @@ -205,11 +211,19 @@ module_pEp = Extension( ], ) +module_pybind11 = Extension( + 'pEp._pybind', + sources=[ + 'src/pEp/_pybind/pEpmodule.cc', + ], +) + + # "MAIN" Function setup( package_dir={'': 'src'}, packages=['pEp'], - ext_modules=[module_pEp], + ext_modules=[module_pEp, module_pybind11], cmdclass={ 'build_ext': BuildExtCommand, }, diff --git a/src/pEp/__init__.py b/src/pEp/__init__.py index 596266b..a49f529 100755 --- a/src/pEp/__init__.py +++ b/src/pEp/__init__.py @@ -25,10 +25,12 @@ except ImportError: # Imports all symbols EXCEPT the ones beginning with underscore from ._pEp import * +from ._pybind import * # import the native module into the current namespace because we also need to access the names beginning # with an underscore (of _pEp), but we dont want to import them into this module import pEp._pEp +import pEp._pybind # Executed on module import def init(): diff --git a/src/pEp/_pybind/pEpModule.cc b/src/pEp/_pybind/pEpModule.cc new file mode 100644 index 0000000..de0b79d --- /dev/null +++ b/src/pEp/_pybind/pEpModule.cc @@ -0,0 +1,14 @@ +#include +#include + +using namespace std; + +string testfunc() { + return "fsdfg"; +} + +PYBIND11_MODULE(_pybind, m) { + m.doc() = "pybind11 example plugin"; // optional module docstring + m.def("add", &testfunc, "A function which adds two numbers"); +} +