From edcb9c6dfd1d0cc7a935c0a2c34c9283900cfdc2 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Thu, 21 Oct 2021 17:13:57 +0200 Subject: [PATCH 1/8] Use pkg-config. #5. --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b6efc9ff..450b36c8 100644 --- a/setup.py +++ b/setup.py @@ -65,12 +65,13 @@ def get_extensions(is_test): link_args = [] compile_args.append("-std=c++11") compile_args.append("-I{}".format(numpy.get_include())) + compile_args.append("pkg-config --cflags libprecice") bindings_sources = [os.path.join(PYTHON_BINDINGS_PATH, "cyprecice", "cyprecice" + ".pyx")] if not is_test: - link_args.append("-lprecice") + link_args.append("pkg-config --libs") if is_test: bindings_sources.append(os.path.join(PYTHON_BINDINGS_PATH, "test", "SolverInterface.cpp")) From 684d0f332a61a5d70daad0292e09852a9924e888 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Thu, 21 Oct 2021 17:33:40 +0200 Subject: [PATCH 2/8] Fix pkg-config calls. --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 450b36c8..b7a040e7 100644 --- a/setup.py +++ b/setup.py @@ -65,13 +65,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("pkg-config --cflags libprecice") + 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("pkg-config --libs") + 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")) From de19c81d78ef98669388527cce39daf0ff29389d Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Thu, 21 Oct 2021 17:52:33 +0200 Subject: [PATCH 3/8] Improve error messages. --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index b7a040e7..a3e9270b 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 From 2453ad949460d0926833f5226ec040a7fcc508a1 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Thu, 21 Oct 2021 18:01:09 +0200 Subject: [PATCH 4/8] Add pkg-config as dependency. --- README.md | 2 ++ spack/repo/packages/py-pyprecice/package.py | 1 + 2 files changed, 3 insertions(+) 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/spack/repo/packages/py-pyprecice/package.py b/spack/repo/packages/py-pyprecice/package.py index 96825b07..8a7dc7b5 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): From f12971c895c187f605417308febd1eb1f49bf71b Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Thu, 21 Oct 2021 18:03:10 +0200 Subject: [PATCH 5/8] Fix format. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a3e9270b..c93989fd 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ "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 +# 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?.") From 8c8358b4a56dc72fc4d5ff262f33f88324fda832 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Fri, 22 Oct 2021 13:43:24 +0200 Subject: [PATCH 6/8] Make pkgconfig available during build. --- .github/workflows/build-spack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index 223abeb3..a00a276b 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 pkgconfig && 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}" From 0b64f309e53a25adc33dd4d608d450f0ad7dee03 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Fri, 22 Oct 2021 15:44:31 +0200 Subject: [PATCH 7/8] Add precice? --- .github/workflows/build-spack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index a00a276b..f8864f7f 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 load pkgconfig && 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 pkgconfig 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}" From c7bf23af38d4ec5d6cd6f5ca3ac0e4b28a1e3388 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Mon, 25 Oct 2021 13:15:35 +0200 Subject: [PATCH 8/8] Fix pkgconfig dependency. --- .github/workflows/build-spack.yml | 2 +- spack/repo/packages/py-pyprecice/package.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index f8864f7f..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 load pkgconfig 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}" + . /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/spack/repo/packages/py-pyprecice/package.py b/spack/repo/packages/py-pyprecice/package.py index 8a7dc7b5..290fb647 100644 --- a/spack/repo/packages/py-pyprecice/package.py +++ b/spack/repo/packages/py-pyprecice/package.py @@ -48,7 +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") + depends_on("pkgconfig", when="@2.3.0.2:", type="build") @when("@:2.1") def patch(self):