Skip to content

Commit bc4e791

Browse files
committed
Clean up pybind11 section
1 parent f2fb1bd commit bc4e791

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
#!/usr/bin/env python
2-
""" Simple examples of calling C functions through ctypes module. """
32
import pybind11_example
43

54

65
if __name__ == "__main__":
76
# sample data for our call:
8-
x = 6
9-
y = 2.3
7+
x, y = 6, 2.3
108

119
answer = pybind11_example.cpp_function(x, y)
1210
print(f" In Python: int: {x} float {y:.1f} return val {answer:.1f}")
13-
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#include <pybind11/pybind11.h>
22
#include <cppmult.hpp>
33

4-
54
PYBIND11_MODULE(pybind11_example, m) {
65
m.doc() = "pybind11 example plugin"; // optional module docstring
76
m.def("cpp_function", &cppmult, "A function which multiplies two numbers");
87
}
9-

python-bindings/overview_article/tasks.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,17 @@ def test_cffi(c):
5757
@invoke.task()
5858
def build_pybind11(c):
5959
""" Compile and link the shared library (DLL) for the sample C++ code."""
60-
# compile and link the c++ library
61-
invoke.run("g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC " \
62-
"-I /usr/include/python3.7 " \
63-
"cppmult.cpp " \
64-
"-o libcppmult.so "
60+
# compile and link the cmult c++ library
61+
invoke.run("g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
62+
"cppmult.cpp -o libcppmult.so "
6563
)
6664
# compile and link the pybind11 wrapper library
6765
invoke.run("g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
6866
"`python3 -m pybind11 --includes` "
6967
"-I /usr/include/python3.7 -I . "
7068
"pybind11_wrapper.cpp "
7169
"-o pybind11_example`python3.7-config --extension-suffix` "
72-
"-L. -lcppmult "
73-
"-Wl,-rpath,. "
70+
"-L. -lcppmult -Wl,-rpath,. "
7471
)
7572

7673
@invoke.task()

0 commit comments

Comments
 (0)