Browse Source

pyBind11 evaluation - parallel mode with boost.python

REWORK
heck 5 years ago
parent
commit
8aa36d9f95
  1. 16
      setup.py
  2. 2
      src/pEp/__init__.py
  3. 14
      src/pEp/_pybind/pEpModule.cc

16
setup.py

@ -174,6 +174,12 @@ class BuildExtCommand(build_ext):
module_pEp.libraries = libs module_pEp.libraries = libs
module_pEp.extra_compile_args = compile_flags 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("Include Dirs:", module_pEp.include_dirs)
pEpLog("Libs Dirs:", module_pEp.library_dirs) pEpLog("Libs Dirs:", module_pEp.library_dirs)
pEpLog("Libraries:", module_pEp.libraries) 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 # "MAIN" Function
setup( setup(
package_dir={'': 'src'}, package_dir={'': 'src'},
packages=['pEp'], packages=['pEp'],
ext_modules=[module_pEp], ext_modules=[module_pEp, module_pybind11],
cmdclass={ cmdclass={
'build_ext': BuildExtCommand, 'build_ext': BuildExtCommand,
}, },

2
src/pEp/__init__.py

@ -25,10 +25,12 @@ except ImportError:
# Imports all symbols EXCEPT the ones beginning with underscore # Imports all symbols EXCEPT the ones beginning with underscore
from ._pEp import * from ._pEp import *
from ._pybind import *
# import the native module into the current namespace because we also need to access the names beginning # 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 # with an underscore (of _pEp), but we dont want to import them into this module
import pEp._pEp import pEp._pEp
import pEp._pybind
# Executed on module import # Executed on module import
def init(): def init():

14
src/pEp/_pybind/pEpModule.cc

@ -0,0 +1,14 @@
#include <string>
#include <pybind11/pybind11.h>
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");
}
Loading…
Cancel
Save