diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index 223abeb3..b63ef5c2 100644 --- a/.github/workflows/build-spack.yml +++ b/.github/workflows/build-spack.yml @@ -26,4 +26,4 @@ jobs: cp -r spack/repo/packages/py-pyprecice/ /py-pyprecice-repo/packages/ - name: Try to build py-pyprecice with spack and test it run: | - . /opt/spack/share/spack/setup-env.sh && spack env activate ci && spack arch && spack find && spack dev-build pyprecice.test.py-pyprecice@develop target=x86_64 && spack load precice py-numpy py-mpi4py py-cython openssh openmpi && export PYTHONPATH=${PWD}/build/$(ls build | grep lib.):${PYTHONPATH} && mkdir runner && cd runner && BINDINGS_VERSION=$(python3 -c "import precice; print(precice.__version__)") && echo "Installed version of bindings is ${BINDINGS_VERSION}" + . /opt/spack/share/spack/setup-env.sh && spack env activate ci && spack arch && spack find && spack load precice && spack dev-build pyprecice.test.py-pyprecice@develop target=x86_64 && spack load precice py-numpy py-mpi4py py-cython openssh openmpi && export PYTHONPATH=${PWD}/build/$(ls build | grep lib.):${PYTHONPATH} && mkdir runner && cd runner && BINDINGS_VERSION=$(python3 -c "import precice; print(precice.__version__)") && echo "Installed version of bindings is ${BINDINGS_VERSION}" diff --git a/README.md b/README.md index aa770c0d..090b034a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Please refer to [the preCICE documentation](https://www.precice.org/installation **MPI**: `mpi4py` requires MPI to be installed on your system. +**pkg-config**: `pkg-config` is used to determine dependencies. + # Installing the package We recommend using pip3 (version 19.0.0 or newer required) for the sake of simplicity. You can check your pip3 version via `pip3 --version`. To update pip3, use the following line: diff --git a/setup.py b/setup.py index b6efc9ff..c93989fd 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,13 @@ "your pip installation via 'pip3 install --upgrade pip'. You might have to add the --user" " flag.".format(pip.__version__)) +# check for pkg-config and whether it can find preCICE +out = os.system('pkg-config libprecice') +if out == 256: # error code, if lib is not found by pkg-config + raise Exception("pkg-config is not able to find libprecice. Is preCICE installed correctly?.") +elif out == 32512: # error code, if pkg-config is not found + raise Exception("pkg-config is not found. Please install pkg-config.") + from setuptools import setup from setuptools import Command from setuptools.command.test import test @@ -65,12 +72,14 @@ def get_extensions(is_test): link_args = [] compile_args.append("-std=c++11") compile_args.append("-I{}".format(numpy.get_include())) + compile_args.append(os.popen("pkg-config --cflags libprecice").read()) + print(compile_args) bindings_sources = [os.path.join(PYTHON_BINDINGS_PATH, "cyprecice", "cyprecice" + ".pyx")] if not is_test: - link_args.append("-lprecice") + link_args.append(os.popen("pkg-config --libs libprecice").read()) if is_test: bindings_sources.append(os.path.join(PYTHON_BINDINGS_PATH, "test", "SolverInterface.cpp")) diff --git a/spack/repo/packages/py-pyprecice/package.py b/spack/repo/packages/py-pyprecice/package.py index 96825b07..290fb647 100644 --- a/spack/repo/packages/py-pyprecice/package.py +++ b/spack/repo/packages/py-pyprecice/package.py @@ -48,6 +48,7 @@ class PyPyprecice(PythonPackage): depends_on("py-cython@0.29:", type="build") depends_on("py-packaging", when="@:2.1", type="build") depends_on("py-pip", when="@:2.1", type="build") + depends_on("pkgconfig", when="@2.3.0.2:", type="build") @when("@:2.1") def patch(self):