@@ -70,24 +70,28 @@ def build_cppmult(c):
7070 )
7171 print ("* Complete" )
7272
73+ def compile_python_module (cpp_name , extension_name ):
74+ invoke .run ("g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
75+ "`python3 -m pybind11 --includes` "
76+ "-I /usr/include/python3.7 -I . "
77+ "{0} "
78+ "-o {1}`python3.7-config --extension-suffix` "
79+ "-L. -lcppmult -Wl,-rpath,." .format (cpp_name , extension_name )
80+ )
81+
7382@invoke .task (build_cppmult )
7483def build_pybind11 (c ):
7584 """ compile and link the pybind11 wrapper library """
7685 print_banner ("Building PyBind11 Module" )
77- invoke .run ("g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
78- "`python3 -m pybind11 --includes` "
79- "-I /usr/include/python3.7 -I . "
80- "pybind11_wrapper.cpp "
81- "-o pybind11_example`python3.7-config --extension-suffix` "
82- "-L. -lcppmult -Wl,-rpath,. "
83- )
86+ compile_python_module ("pybind11_wrapper.cpp" , "pybind11_example" )
8487 print ("* Complete" )
8588
8689@invoke .task ()
8790def test_pybind11 (c ):
8891 print_banner ("Testing PyBind11 Module" )
8992 invoke .run ("python3 pybind11_test.py" , pty = True )
9093
94+
9195@invoke .task (build_cppmult )
9296def build_cython (c ):
9397 """ build the cython extension module """
@@ -96,12 +100,7 @@ def build_cython(c):
96100 invoke .run ("cython --cplus -3 cython_example.pyx -o cython_wrapper.cpp" )
97101
98102 # compile and link the cython wrapper library
99- invoke .run ("g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
100- "-I /usr/include/python3.7 -I . "
101- "cython_wrapper.cpp "
102- "-o cython_example`python3.7-config --extension-suffix` "
103- "-L. -lcppmult -Wl,-rpath,."
104- )
103+ compile_python_module ("cython_wrapper.cpp" , "cython_example" )
105104 print ("* Complete" )
106105
107106@invoke .task ()
0 commit comments