Skip to content

Commit

Permalink
Merge pull request #150 from precice/python-bindings-v2.5.0.0
Browse files Browse the repository at this point in the history
Release v2.5.0.0
  • Loading branch information
IshaanDesai authored Aug 30, 2022
2 parents f6828eb + 417b7bf commit ec6990c
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 43 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install & upgrade pip3
run: |
apt-get -yy update
apt-get install -y python3-pip
apt-get install -y python3-pip pkg-config
rm -rf /var/lib/apt/lists/*
pip3 install --upgrade --user pip
- name: Install dependencies
Expand All @@ -38,10 +38,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install & upgrade pip3
- name: Install pip3, pkgconfig and upgrade pip3
run: |
apt-get -yy update
apt-get install -y python3-pip
apt-get install -y python3-pip pkg-config
rm -rf /var/lib/apt/lists/*
pip3 install --upgrade --user pip
- name: Install dependencies
Expand All @@ -61,10 +61,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install & upgrade pip3
- name: Install pip3, pkgconfig and upgrade pip3
run: |
apt-get -yy update
apt-get install -y python3-pip
apt-get install -y python3-pip pkg-config
rm -rf /var/lib/apt/lists/*
pip3 install --upgrade --user pip
- name: Install dependencies
Expand All @@ -80,22 +80,30 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install & upgrade pip3 and install OpenMPI
- uses: actions/setup-python@v1
- name: Install OpenMPI, CMake, Boost library, Eigen and pkg-config
run: |
sudo apt-get -yy update
sudo apt-get install -y python3-pip libopenmpi-dev
sudo apt-get install -y libopenmpi-dev cmake libboost-all-dev libeigen3-dev pkg-config
sudo rm -rf /var/lib/apt/lists/*
pip3 install --upgrade --user pip
- uses: BSFishy/pip-action@v1
with:
packages: toml
- name: Checkout precice and make required files discoverable
run: |
git clone https://github.com/precice/precice.git precice-core
mkdir -p precice
cp precice-core/src/precice/SolverInterface.hpp precice/SolverInterface.hpp
cd precice-core
mkdir build && cd build
cmake .. -DPRECICE_MPICommunication=OFF -DPRECICE_PETScMapping=OFF -DPRECICE_PythonActions=OFF -DBUILD_TESTING=OFF
- name: Install dependencies
run: |
pip3 install --user toml
python3 -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | pip3 install -r /dev/stdin
- name: Run setup test
env:
PKG_CONFIG_PATH: "precice-core/build"
PKG_CONFIG_SYSTEM_INCLUDE_PATH: 1
run: |
export CFLAGS=-I$GITHUB_WORKSPACE
python3 setup.py test
Expand All @@ -108,10 +116,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install & upgrade pip3
- name: Install pip3, pkgconfig and upgrade pip3
run: |
apt-get -yy update
apt-get install -y python3-pip
apt-get install -y python3-pip pkg-config
rm -rf /var/lib/apt/lists/*
pip3 install --upgrade --user pip
- name: Run pip install
Expand All @@ -127,10 +135,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install & upgrade pip3
- name: Install pip3, pkgconfig and upgrade pip3
run: |
apt-get -yy update
apt-get install -y python3-pip
apt-get install -y python3-pip pkg-config
rm -rf /var/lib/apt/lists/*
pip3 install --upgrade --user pip
- name: Run pip install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
with:
push: true
context: .
file: spack/ci-spack-pyprecice-deps-1804.dockerfile
tags: precice/ci-spack-pyprecice-deps-1804
file: spack/ci-spack-pyprecice-deps-2204.dockerfile
tags: precice/ci-spack-pyprecice-deps-2204
10 changes: 8 additions & 2 deletions .github/workflows/build-spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: build_spack
runs-on: ubuntu-latest
timeout-minutes: 15
container: precice/ci-spack-pyprecice-deps-1804
container: precice/ci-spack-pyprecice-deps-2204
defaults:
run:
shell: "bash --login -eo pipefail {0}"
Expand All @@ -26,4 +26,10 @@ 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 remove py-pyprecice
spack add pyprecice.test.py-pyprecice@develop && spack develop pyprecice.test.py-pyprecice@develop
spack install && spack find
spack load py-pyprecice
BINDINGS_VERSION=$(python3 -c "import precice; print(precice.__version__)") && echo "Installed version of bindings is ${BINDINGS_VERSION}"
12 changes: 9 additions & 3 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ jobs:
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine cython packaging numpy
uses: BSFishy/pip-action@v1
with:
packages: |
setuptools
wheel
twine
cython
packaging
numpy
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-solverdummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Dependencies
run: |
apt-get -qq update
apt-get -qq install software-properties-common python3-dev python3-pip git apt-utils
apt-get -qq install software-properties-common python3-dev python3-pip git apt-utils pkg-config
rm -rf /var/lib/apt/lists/*
- name: Install bindings
run: pip3 install --user .
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## latest

## 2.5.0.0

* Bindings now use pkgconfig to determine flags and link to preCICE. https://github.com/precice/python-bindings/pull/149

## 2.4.0.0

* Move solverdummy into examples/ folder and remove MeshName from its input arguments. https://github.com/precice/python-bindings/pull/141
Expand Down
2 changes: 1 addition & 1 deletion cyprecice/cyprecice.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ cdef class Interface:
>>> vertex_id = 5
>>> value = interface.read_scalar_data(data_id, vertex_id)
"""
cdef double _value
cdef double _value = 0
self.thisptr.readScalarData (data_id, vertex_id, _value)
return _value

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
# PEP 518 - minimum build system requirements
requires = ["setuptools", "wheel", "Cython>=0.29", "packaging", "pip>=19.0.0", "numpy", "mpi4py"]
requires = ["setuptools", "wheel", "Cython>=0.29", "packaging", "pip>=19.0.0", "numpy", "mpi4py", "pkgconfig"]
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from Cython.Distutils.build_ext import new_build_ext as build_ext
from Cython.Build import cythonize
import numpy
import pkgconfig


# name of Interfacing API
Expand All @@ -69,8 +70,10 @@ def get_extensions(is_test):
bindings_sources = [os.path.join(PYTHON_BINDINGS_PATH, "cyprecice",
"cyprecice" + ".pyx")]

compile_args += pkgconfig.cflags('libprecice').split()

if not is_test:
link_args.append("-lprecice")
link_args += pkgconfig.libs('libprecice').split()
if is_test:
bindings_sources.append(os.path.join(PYTHON_BINDINGS_PATH, "test",
"SolverInterface.cpp"))
Expand Down
8 changes: 4 additions & 4 deletions spack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

The Spack package `py-pyprecice` provides the python bindings via Spack and was submitted via [pull request 19558](https://github.com/spack/spack/pull/19558) in the Spack repository. This folder contains the Spack package script that can be used for testing whether the Spack installation works.

## Docker image `precice/ci-spack-pyprecice-deps-1804`
## Docker image `precice/ci-spack-pyprecice-deps-2204`

The workflow `build-spack-pyprecice-deps` in `.github/workflows/build-env.yml` creates the image `precice/ci-spack-pyprecice-deps-1804`. This image contains all dependencies of `py-pyprecice@develop`.
The workflow `build-spack-pyprecice-deps` in `.github/workflows/build-env.yml` creates the image `precice/ci-spack-pyprecice-deps-2204`. This image contains all dependencies of `py-pyprecice@develop`.

The workflow `build_spack` in `.github/workflows/build-spack.yml` uses the image `precice/ci-spack-pyprecice-deps-1804` to reduce build time. The workflow uses the `package.py` from this repository to build the latest version of the bindings and run a small test on this version.
The workflow `build_spack` in `.github/workflows/build-spack.yml` uses the image `precice/ci-spack-pyprecice-deps-2204` to reduce build time. The workflow uses the `package.py` from this repository to build the latest version of the bindings and run a small test on this version.

## When a new Spack release is necessary

Expand Down Expand Up @@ -62,4 +62,4 @@ The workflow `build_spack` in `.github/workflows/build-spack.yml` uses the image
7. Ideally one runs the solverdummy with the freshly installed Python bindings.
* Use `package.py` together with the patches provided in `python-bindings/spack/repo/packages/py-pyprecice` to [create a pull request for Spack](https://github.com/spack/spack/compare) and submit the new release.
* After the pull request in the Spack repository is merged, merge the current package configuration into the repository of the Python bindings if necessery.
* After the pull request in the Spack repository is merged, merge the current package configuration into the repository of the Python bindings if necessery.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build stage with Spack pre-installed and ready to be used
FROM spack/ubuntu-bionic:latest
FROM spack/ubuntu-jammy:latest

# Mount the current sources into the build container
# and build the default environment
Expand Down
27 changes: 14 additions & 13 deletions spack/repo/packages/py-pyprecice/package.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *
from spack.package import *


class PyPyprecice(PythonPackage):
Expand All @@ -14,16 +14,17 @@ class PyPyprecice(PythonPackage):

homepage = "https://precice.org"
git = "https://github.com/precice/python-bindings.git"
url = "https://github.com/precice/python-bindings/archive/v2.0.0.1.tar.gz"
url = "https://github.com/precice/python-bindings/archive/v2.4.0.0.tar.gz"
maintainers = ["ajaust", "BenjaminRodenberg", "IshaanDesai"]

# Always prefer final version of release candidate
version("develop", branch="develop")
version('2.3.0.1', sha256='ed4e48729b662680beaa4ee2a9aff724a79e760534c6c58181be739988da2789')
version('2.2.1.1', sha256='139bac5077c3807e1b7b83d8d0da5ca0fc8c17393fd0df4bc5999cd63a351b78')
version('2.2.0.2', sha256='2287185f9ad7500dced53459543d27bb66bd2438c2e4bf81ee3317e6a00513d5')
version('2.2.0.1', sha256='229625e2e6df03987ababce5abe2021b0974cbe5a588b936a9cba653f4908d4b')
version('2.1.1.2', sha256='363eb3eeccf964fd5ee87012c1032353dd1518662868f2b51f04a6d8a7154045')
version("2.4.0.0", sha256="8877da85df97d66966892440c7e777b667d8e6a33747304ed3762f4c33b729ec")
version("2.3.0.1", sha256="ed4e48729b662680beaa4ee2a9aff724a79e760534c6c58181be739988da2789")
version("2.2.1.1", sha256="139bac5077c3807e1b7b83d8d0da5ca0fc8c17393fd0df4bc5999cd63a351b78")
version("2.2.0.2", sha256="2287185f9ad7500dced53459543d27bb66bd2438c2e4bf81ee3317e6a00513d5")
version("2.2.0.1", sha256="229625e2e6df03987ababce5abe2021b0974cbe5a588b936a9cba653f4908d4b")
version("2.1.1.2", sha256="363eb3eeccf964fd5ee87012c1032353dd1518662868f2b51f04a6d8a7154045")
version("2.1.1.1", sha256="972f574549344b6155a8dd415b6d82512e00fa154ca25ae7e36b68d4d2ed2cf4")
version("2.1.0.1", sha256="ac5cb7412c6b96b08a04fa86ea38e52d91ea739a3bd1c209baa93a8275e4e01a")
version("2.0.2.1", sha256="c6fca26332316de041f559aecbf23122a85d6348baa5d3252be4ddcd5e94c09a")
Expand All @@ -32,6 +33,7 @@ class PyPyprecice(PythonPackage):
version("2.0.0.1", sha256="96eafdf421ec61ad6fcf0ab1d3cf210831a815272984c470b2aea57d4d0c9e0e")

depends_on("precice@develop", when="@develop")
depends_on("[email protected]", when="@2.4.0.1:2.4.0")
depends_on("[email protected]", when="@2.3.0.1:2.3.1")
depends_on("[email protected]", when="@2.2.1.1:2.2.1")
depends_on("[email protected]", when="@2.2.0.1:2.2.0")
Expand All @@ -46,11 +48,10 @@ class PyPyprecice(PythonPackage):
depends_on("py-numpy", type=("build", "link", "run"))
depends_on("py-mpi4py", type=("build", "run"))
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("py-packaging", type="build")
depends_on("[email protected]:", type="build")
depends_on("py-pkgconfig", type="build")

@when("@:2.1")
def patch(self):
filter_file(
"distutils.command.install", "setuptools.command.install", "setup.py"
)
filter_file("distutils.command.install", "setuptools.command.install", "setup.py")
3 changes: 2 additions & 1 deletion tools/releasing/packaging/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ RUN apt-get -qq update && apt-get -qq install \
git \
sudo \
python3-dev \
python3-pip && \
python3-pip \
pkg-config && \
rm -rf /var/lib/apt/lists/*

## Needed, because precice/precice:latest does not create a user? See also https://github.com/precice/precice/pull/1090
Expand Down

0 comments on commit ec6990c

Please sign in to comment.