Skip to content

Commit 7cd4914

Browse files
committed
Final touch up getting ready for TR
1 parent 37bb307 commit 7cd4914

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

python-bindings/overview_article/cffi_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import cffi_example
33

44
if __name__ == "__main__":
5-
# sample data for our call:
5+
# Sample data for our call:
66
x, y = 6, 2.3
77

88
answer = cffi_example.lib.cmult(x, y)

python-bindings/overview_article/ctypes_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66

77
if __name__ == "__main__":
8-
# load the shared library into c types.
8+
# Load the shared library into c types.
99
libname = pathlib.Path().absolute() / "libcmult.so"
1010
c_lib = ctypes.CDLL(libname)
1111

12-
# sample data for our call:
12+
# Sample data for our call:
1313
x, y = 6, 2.3
1414

1515
# This will not work:

python-bindings/overview_article/cython_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
import cython_example
33

4-
# sample data for our call:
4+
# Sample data for our call
55
x, y = 6, 2.3
66

77
answer = cython_example.pymult(x, y)

python-bindings/overview_article/pybind11_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env python
22
import pybind11_example
33

4-
54
if __name__ == "__main__":
6-
# sample data for our call:
5+
# Sample data for our call:
76
x, y = 6, 2.3
87

98
answer = pybind11_example.cpp_function(x, y)

python-bindings/overview_article/tasks.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@invoke.task
99
def clean(c):
10-
""" Remove any built objects. """
10+
""" Remove any built objects """
1111
for pattern in ["*.o", "*.so", "cffi_example* cython_wrapper.cpp", ]:
1212
c.run("rm -rf {}".format(pattern))
1313

@@ -17,7 +17,7 @@ def print_banner(msg):
1717

1818
@invoke.task
1919
def build_cmult(c):
20-
""" Compile and link the shared library (DLL) for the sample C++ code."""
20+
""" Build the shared library for the sample C code """
2121
print_banner("Building C Library")
2222
invoke.run("gcc -c -Wall -Werror -fpic cmult.c -I /usr/include/python3.7")
2323
invoke.run("gcc -shared -o libcmult.so cmult.o")
@@ -26,11 +26,13 @@ def build_cmult(c):
2626

2727
@invoke.task(build_cmult)
2828
def test_ctypes(c):
29+
""" Run the script to test ctypes """
2930
print_banner("Testing ctypes Module")
3031
invoke.run("python3 ctypes_test.py", pty=True)
3132

3233
@invoke.task(build_cmult)
3334
def build_cffi(c):
35+
""" Build the CFFI Python bindings """
3436
print_banner("Building CFFI Module")
3537
ffi = cffi.FFI()
3638

@@ -57,13 +59,14 @@ def build_cffi(c):
5759

5860
@invoke.task()
5961
def test_cffi(c):
62+
""" Run the script to test CFFI """
6063
print_banner("Testing CFFI Module")
6164
invoke.run("python3 cffi_test.py", pty=True)
6265

6366

6467
@invoke.task()
6568
def build_cppmult(c):
66-
""" Compile and link the shared library (DLL) for the sample C++ code."""
69+
""" Build the shared library for the sample C++ code """
6770
print_banner("Building C++ Library")
6871
invoke.run(
6972
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC cppmult.cpp -o libcppmult.so "
@@ -81,35 +84,38 @@ def compile_python_module(cpp_name, extension_name):
8184

8285
@invoke.task(build_cppmult)
8386
def build_pybind11(c):
84-
""" compile and link the pybind11 wrapper library """
87+
""" Build the pybind11 wrapper library """
8588
print_banner("Building PyBind11 Module")
8689
compile_python_module("pybind11_wrapper.cpp", "pybind11_example")
8790
print("* Complete")
8891

8992
@invoke.task()
9093
def test_pybind11(c):
94+
""" Run the script to test PyBind11 """
9195
print_banner("Testing PyBind11 Module")
9296
invoke.run("python3 pybind11_test.py", pty=True)
9397

9498

9599
@invoke.task(build_cppmult)
96100
def build_cython(c):
97-
""" build the cython extension module """
101+
""" Build the cython extension module """
98102
print_banner("Building Cython Module")
99-
# run cython on the pyx file to create a .cpp file
103+
# Run cython on the pyx file to create a .cpp file
100104
invoke.run("cython --cplus -3 cython_example.pyx -o cython_wrapper.cpp")
101105

102-
# compile and link the cython wrapper library
106+
# Compile and link the cython wrapper library
103107
compile_python_module("cython_wrapper.cpp", "cython_example")
104108
print("* Complete")
105109

106110
@invoke.task()
107111
def test_cython(c):
112+
""" Run the script to test Cython """
108113
print_banner("Testing Cython Module")
109114
invoke.run("python3 cython_test.py", pty=True)
110115

111116
@invoke.task(clean, build_cmult, test_ctypes, build_cffi, test_cffi,
112117
build_pybind11, test_pybind11, build_cython, test_cython)
113118
def all(c):
119+
""" Build and run all tests """
114120
pass
115121

0 commit comments

Comments
 (0)