|
9 | 9 | language = "c++" |
10 | 10 | std = "c++17" |
11 | 11 |
|
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 | + |
13 | 18 | extra_compile_args = [f"-std={std}", "-Wall", "-Wextra", "-Werror", "-DNDEBUG", "-O3"] |
14 | 19 |
|
15 | 20 | print(f"Default compile arguments: {default_compile_args}") |
16 | 21 | print(f"Extra compile arguments: {extra_compile_args}") |
17 | 22 |
|
18 | 23 | cpython_extension = Extension( |
19 | 24 | "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 | + ], |
21 | 29 | extra_compile_args=extra_compile_args, |
22 | 30 | language=language, |
| 31 | + include_dirs=[str(THIS_DIR / "cpp_impl")], |
23 | 32 | ) |
24 | 33 |
|
25 | 34 | cython_extension = Extension( |
26 | 35 | "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 | + ], |
28 | 40 | extra_compile_args=extra_compile_args, |
29 | 41 | language=language, |
| 42 | + include_dirs=[str(THIS_DIR / "cpp_impl")], |
30 | 43 | ) |
31 | 44 |
|
32 | | -setup( |
| 45 | +_ = setup( |
33 | 46 | 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", |
36 | 49 | ext_modules=cythonize([cython_extension]) + [cpython_extension], |
| 50 | + zip_safe=False, |
37 | 51 | ) |
0 commit comments