Skip to content

Commit f87dffd

Browse files
committed
Revert "helping jim"
This reverts commit ced7e4b.
1 parent ced7e4b commit f87dffd

File tree

1 file changed

+15
-50
lines changed
  • python-bindings/overview_article

1 file changed

+15
-50
lines changed

python-bindings/overview_article/tasks.py

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
import cffi
44
import invoke
55
import pathlib
6-
import platform
7-
8-
# Flag if we are on windows as that will require a different command line
9-
# for the compilers
10-
WINDOWS = platform.system().startswith("Windows")
116

127

138
@invoke.task
@@ -26,15 +21,8 @@ def print_banner(msg):
2621
def build_cmult(c):
2722
""" Build the shared library for the sample C code """
2823
print_banner("Building C Library")
29-
if WINDOWS:
30-
invoke.run(
31-
"cl.exe /LD cmult.c /OUT:libcmult.dll"
32-
)
33-
else:
34-
invoke.run(
35-
"gcc -Wall -Werror -fpic cmult.c -I /usr/include/python3.7 "
36-
"-shared -o libcmult.so"
37-
)
24+
invoke.run("gcc -c -Wall -Werror -fpic cmult.c -I /usr/include/python3.7")
25+
invoke.run("gcc -shared -o libcmult.so cmult.o")
3826
print("* Complete")
3927

4028

@@ -56,14 +44,6 @@ def build_cffi(c):
5644
with open(h_file_name) as h_file:
5745
ffi.cdef(h_file.read())
5846

59-
# need to set the rpath so the new Python module lib can find the .so file
60-
# in linux
61-
if WINDOWS:
62-
extra_links = []
63-
else:
64-
extra_links = ["-Wl,-rpath,."]
65-
66-
6747
ffi.set_source(
6848
"cffi_example",
6949
# Since we are calling a fully built library directly no custom source
@@ -75,7 +55,7 @@ def build_cffi(c):
7555
# libraries we are linking against:
7656
libraries=["cmult"],
7757
library_dirs=[this_dir.as_posix()],
78-
extra_link_args=extra_links,
58+
extra_link_args=["-Wl,-rpath,."],
7959
)
8060

8161
ffi.compile()
@@ -93,37 +73,22 @@ def test_cffi(c):
9373
def build_cppmult(c):
9474
""" Build the shared library for the sample C++ code """
9575
print_banner("Building C++ Library")
96-
if WINDOWS:
97-
invoke.run(
98-
"cl.exe /LD cmult.c /OUT:libcmult.dll"
99-
)
100-
else:
101-
invoke.run(
102-
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC cppmult.cpp "
103-
"-o libcppmult.so "
104-
)
76+
invoke.run(
77+
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC cppmult.cpp "
78+
"-o libcppmult.so "
79+
)
10580
print("* Complete")
10681

10782

10883
def compile_python_module(cpp_name, extension_name):
109-
if WINDOWS:
110-
# This needs to get updated with a way to call the python3.7-config
111-
# tool
112-
# This is the command line - possbily we jsut want a different function
113-
# for windows. The 'spam.lib' portion is going to be the cppmult lib.
114-
# cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib
115-
invoke.run(
116-
"cl.exe /LD {0} /OUT:{1}".format(cpp_name, extension_name)
117-
)
118-
else:
119-
invoke.run(
120-
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
121-
"`python3 -m pybind11 --includes` "
122-
"-I /usr/include/python3.7 -I . "
123-
"{0} "
124-
"-o {1}`python3.7-config --extension-suffix` "
125-
"-L. -lcppmult -Wl,-rpath,.".format(cpp_name, extension_name)
126-
)
84+
invoke.run(
85+
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
86+
"`python3 -m pybind11 --includes` "
87+
"-I /usr/include/python3.7 -I . "
88+
"{0} "
89+
"-o {1}`python3.7-config --extension-suffix` "
90+
"-L. -lcppmult -Wl,-rpath,.".format(cpp_name, extension_name)
91+
)
12792

12893

12994
@invoke.task(build_cppmult)

0 commit comments

Comments
 (0)