Skip to content
Merged
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
30 changes: 16 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pathlib
from setuptools import setup
from Cython.Distutils.extension import Extension
from Cython.Build import cythonize
Expand All @@ -9,32 +8,35 @@
MOCKED_ENV = "PYPRECICE_MOCKED"


def get_extensions():
def find_precice():
if not pkgconfig.exists("libprecice"):
raise Exception(
"\n".join(
[
"pkg-config was unable to find libprecice.",
"Please make sure that preCICE was installed correctly and pkg-config is able to find it.",
"You may need to set PKG_CONFIG_PATH to include the location of the libprecice.pc file.",
'Use "pkg-config --modversion libprecice" for debugging.',
]
)
print(
"pkg-config was unable to find libprecice.\n"
"Please make sure that preCICE was installed correctly and pkg-config is able to find it.\n"
"You may need to set PKG_CONFIG_PATH to include the location of the libprecice.pc file.\n"
'Use "pkg-config --modversion libprecice" for debugging.'
)
return [], ["-lprecice"]

version = pkgconfig.modversion("libprecice")
print(f"Found preCICE version {version}")
return pkgconfig.cflags("libprecice").split(), pkgconfig.libs("libprecice").split()

print("Found preCICE version " + pkgconfig.modversion("libprecice"))

def get_extensions():
cflags, ldflags = find_precice()

compile_args = ["-std=c++17"]
link_args = []
include_dirs = [numpy.get_include()]
bindings_sources = ["cyprecice/cyprecice.pyx"]
compile_args += pkgconfig.cflags("libprecice").split()
compile_args += cflags

if os.environ.get(MOCKED_ENV) is not None:
print(f"Building mocked pyprecice as {MOCKED_ENV} is set")
bindings_sources.append("test/Participant.cpp")
else:
link_args += pkgconfig.libs("libprecice").split()
link_args += ldflags

return [
Extension(
Expand Down