Skip to content

Minor fixes to make things work in other Python versions than 3.7 #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python-bindings/ctypes_test.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
if sys.platform.startswith("win"):
c_lib = ctypes.CDLL("cmult.dll")
else:
c_lib = ctypes.CDLL("libcmult.so")
c_lib = ctypes.CDLL("./libcmult.so")

# Sample data for our call:
x, y = 6, 2.3
9 changes: 5 additions & 4 deletions python-bindings/tasks.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import glob

on_win = sys.platform.startswith("win")
python_minor_version = sys.version.split('.')[1]


@invoke.task
@@ -57,7 +58,7 @@ def build_cmult(c, path=None):
c.run(path)
else:
print_banner("Building C Library")
cmd = "gcc -c -Wall -Werror -fpic cmult.c -I /usr/include/python3.7"
cmd = f"gcc -c -Wall -Werror -fpic cmult.c -I /usr/include/python3.{python_minor_version}"
invoke.run(cmd)
invoke.run("gcc -shared -o libcmult.so cmult.o")
print("* Complete")
@@ -129,10 +130,10 @@ def compile_python_module(cpp_name, extension_name):
invoke.run(
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
"`python3 -m pybind11 --includes` "
"-I /usr/include/python3.7 -I . "
"-I /usr/include/python3.{2} -I . "
"{0} "
"-o {1}`python3.7-config --extension-suffix` "
"-L. -lcppmult -Wl,-rpath,.".format(cpp_name, extension_name)
"-o {1}`python3.{2}-config --extension-suffix` "
"-L. -lcppmult -Wl,-rpath,.".format(cpp_name, extension_name, python_minor_version)
)