Skip to content

Commit 4ccf103

Browse files
authored
Improve setup.py (#39)
1 parent 6674329 commit 4ccf103

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/setup.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,43 @@
99
language = "c++"
1010
std = "c++17"
1111

12-
default_compile_args = sysconfig.get_config_var("CFLAGS").split()
12+
# Handle case where CFLAGS might be None
13+
if args := sysconfig.get_config_var("CFLAGS"):
14+
default_compile_args = args.split()
15+
else:
16+
default_compile_args = []
17+
1318
extra_compile_args = [f"-std={std}", "-Wall", "-Wextra", "-Werror", "-DNDEBUG", "-O3"]
1419

1520
print(f"Default compile arguments: {default_compile_args}")
1621
print(f"Extra compile arguments: {extra_compile_args}")
1722

1823
cpython_extension = Extension(
1924
"cpython_sieve",
20-
sources=[THIS_DIR / "cpython_wrapper.cpp", THIS_DIR / "cpp_impl/sieve.cpp"],
25+
sources=[
26+
str(THIS_DIR / "cpython_wrapper.cpp"),
27+
str(THIS_DIR / "cpp_impl/sieve.cpp"),
28+
],
2129
extra_compile_args=extra_compile_args,
2230
language=language,
31+
include_dirs=[str(THIS_DIR / "cpp_impl")],
2332
)
2433

2534
cython_extension = Extension(
2635
"cython_sieve",
27-
sources=[THIS_DIR / "cython_wrapper/wrapper.pyx", THIS_DIR / "cpp_impl/sieve.cpp"],
36+
sources=[
37+
str(THIS_DIR / "cython_wrapper/wrapper.pyx"),
38+
str(THIS_DIR / "cpp_impl/sieve.cpp"),
39+
],
2840
extra_compile_args=extra_compile_args,
2941
language=language,
42+
include_dirs=[str(THIS_DIR / "cpp_impl")],
3043
)
3144

32-
setup(
45+
_ = setup(
3346
name="cpp_python_extension",
34-
version="1.0",
35-
description="This is Example module written in C++",
47+
version="1.0.0",
48+
description="Example module written in C++ with Python bindings",
3649
ext_modules=cythonize([cython_extension]) + [cpython_extension],
50+
zip_safe=False,
3751
)

0 commit comments

Comments
 (0)