Skip to content

Use pkg-config to determine flags #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/build-spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand Down
1 change: 1 addition & 0 deletions spack/repo/packages/py-pyprecice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class PyPyprecice(PythonPackage):
depends_on("[email protected]:", 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):
Expand Down