|
1 | | -import pathlib |
2 | 1 | from setuptools import setup |
3 | 2 | from Cython.Distutils.extension import Extension |
4 | 3 | from Cython.Build import cythonize |
|
9 | 8 | MOCKED_ENV = "PYPRECICE_MOCKED" |
10 | 9 |
|
11 | 10 |
|
12 | | -def get_extensions(): |
| 11 | +def find_precice(): |
13 | 12 | if not pkgconfig.exists("libprecice"): |
14 | | - raise Exception( |
15 | | - "\n".join( |
16 | | - [ |
17 | | - "pkg-config was unable to find libprecice.", |
18 | | - "Please make sure that preCICE was installed correctly and pkg-config is able to find it.", |
19 | | - "You may need to set PKG_CONFIG_PATH to include the location of the libprecice.pc file.", |
20 | | - 'Use "pkg-config --modversion libprecice" for debugging.', |
21 | | - ] |
22 | | - ) |
| 13 | + print( |
| 14 | + "pkg-config was unable to find libprecice.\n" |
| 15 | + "Please make sure that preCICE was installed correctly and pkg-config is able to find it.\n" |
| 16 | + "You may need to set PKG_CONFIG_PATH to include the location of the libprecice.pc file.\n" |
| 17 | + 'Use "pkg-config --modversion libprecice" for debugging.' |
23 | 18 | ) |
| 19 | + return [], ["-lprecice"] |
| 20 | + |
| 21 | + version = pkgconfig.modversion("libprecice") |
| 22 | + print(f"Found preCICE version {version}") |
| 23 | + return pkgconfig.cflags("libprecice").split(), pkgconfig.libs("libprecice").split() |
24 | 24 |
|
25 | | - print("Found preCICE version " + pkgconfig.modversion("libprecice")) |
| 25 | + |
| 26 | +def get_extensions(): |
| 27 | + cflags, ldflags = find_precice() |
26 | 28 |
|
27 | 29 | compile_args = ["-std=c++17"] |
28 | 30 | link_args = [] |
29 | 31 | include_dirs = [numpy.get_include()] |
30 | 32 | bindings_sources = ["cyprecice/cyprecice.pyx"] |
31 | | - compile_args += pkgconfig.cflags("libprecice").split() |
| 33 | + compile_args += cflags |
32 | 34 |
|
33 | 35 | if os.environ.get(MOCKED_ENV) is not None: |
34 | 36 | print(f"Building mocked pyprecice as {MOCKED_ENV} is set") |
35 | 37 | bindings_sources.append("test/Participant.cpp") |
36 | 38 | else: |
37 | | - link_args += pkgconfig.libs("libprecice").split() |
| 39 | + link_args += ldflags |
38 | 40 |
|
39 | 41 | return [ |
40 | 42 | Extension( |
|
0 commit comments