Skip to content

Commit

Permalink
Merge pull request #144 from precice/python-bindings-v2.4.0.0
Browse files Browse the repository at this point in the history
Release v2.4.0.0
  • Loading branch information
IshaanDesai authored May 24, 2022
2 parents 44b715d + 0e3020b commit f6828eb
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 77 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,7 @@ jobs:
- name: Run pip install
run: pip3 install --user .
- name: Run solverdummy
run: python3 solverdummy/solverdummy.py solverdummy/precice-config.xml SolverOne MeshOne & python3 solverdummy/solverdummy.py solverdummy/precice-config.xml SolverTwo MeshTwo
run: |
cd examples/solverdummy/
python3 solverdummy.py precice-config.xml SolverOne MeshOne & python3 solverdummy.py precice-config.xml SolverTwo MeshTwo
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 && mkdir runner && cd runner && python3 -c "import precice; print(precice.__version__)"
. /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}"
2 changes: 1 addition & 1 deletion .github/workflows/run-solverdummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
run: python3 -c "import precice; assert({item.split('=')[0]:item.split('=')[-1] for item in str(precice.get_version_information()).split(';')}['PRECICE_MPICommunication']=='Y')"
- name: Run solverdummies
run: |
cd solverdummy/
cd examples/solverdummy/
python3 solverdummy.py precice-config.xml SolverOne MeshOne & python3 solverdummy.py precice-config.xml SolverTwo MeshTwo
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

## latest

## 2.4.0.0

* Move solverdummy into examples/ folder and remove MeshName from its input arguments. https://github.com/precice/python-bindings/pull/141
* Remove MeshName from input arguments of solverdummy. https://github.com/precice/python-bindings/pull/142

## 2.3.0.1

* Improve CI w.r.t spack package. https://github.com/precice/python-bindings/pull/117
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
⚠️ The latest version of the documentation for the python bindings can be found on [precice.org](https://precice.org/installation-bindings-python.html). The information from this `README` is currently under revision and will be moved ⚠️

Python language bindings for the C++ library preCICE
----------------------------------------------------

Expand All @@ -13,6 +15,8 @@ Please refer to [the preCICE documentation](https://www.precice.org/installation

**preCICE**: Refer to [the preCICE documentation](https://precice.org/installation-overview.html) for information on building and installation.

**C++**: A working C++ compiler, e.g., `g++`.

**MPI**: `mpi4py` requires MPI to be installed on your system.

# Installing the package
Expand Down
26 changes: 24 additions & 2 deletions docs/ReleaseGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,35 @@ The release of the `python-bindings` repository is made directly from a release

* *Note:* We use the [python-versioneer](https://github.com/python-versioneer/python-versioneer/) for maintaining the version. Therefore the tag directly defines the version in all relevant places.
* *Note:* If it is a pre-release then the option *This is a pre-release* needs to be selected at the bottom of the page. Use `@target:python-bindings-v2.1.1.1` for a pre-release, since we will never merge a pre-release into master.
* Use the `Auto-generate release notes` feature. See, for example, https://github.com/precice/python-bindings/releases/tag/v2.3.0.1

a) If a pre-release is made: Directly hit the "Publish release" button in your Release Draft. Now you can check the artifacts (e.g. release on [PyPI](https://pypi.org/project/pyprecice/#history)) of the release. *Note:* As soon as a new tag is created github actions will take care of deploying the new version on PyPI using [this workflow](https://github.com/precice/python-bindings/actions?query=workflow%3A%22Upload+Python+Package%22).

b) If this is a "real" release: As soon as one approving review is made, merge the release PR (from `python-bindings-v2.1.1.1`) into `master`.

6. Merge `master` into `develop` for synchronization of `develop`.
5. Merge `master` into `develop` for synchronization of `develop`.

7. If everything is in order up to this point then the new version can be released by hitting the "Publish release" button in your Release Draft. This will create the corresponding tag and trigger (publishing the release to PyPI)[https://github.com/precice/python-bindings/actions?query=workflow%3A%22Upload+Python+Package%22].
6. If everything is in order up to this point then the new version can be released by hitting the "Publish release" button in your Release Draft. This will create the corresponding tag and trigger [publishing the release to PyPI](https://github.com/precice/python-bindings/actions?query=workflow%3A%22Upload+Python+Package%22).

7. Add an empty commit on master via `git checkout master`, then `git commit --allow-empty -m "post-tag bump"`. Check that everything is in order via `git log`. Important: The `tag` and `origin/master` should not point to the same commit. For example:

```
commit 44b715dde4e3194fa69e61045089ca4ec6925fe3 (HEAD -> master, origin/master)
Author: Benjamin Rodenberg <[email protected]>
Date: Wed Oct 20 10:52:41 2021 +0200
post-tag bump
commit d2645cc51f84ad5eda43b9c673400aada8e1505a (tag: v2.3.0.1)
Merge: 2039557 aca2354
Author: Benjamin Rodenberg <[email protected]>
Date: Tue Oct 19 12:57:24 2021 +0200
Merge pull request #132 from precice/python-bindings-v2.3.0.1
Release v2.3.0.1
```

For more details refer to https://github.com/precice/python-bindings/issues/109 and https://github.com/python-versioneer/python-versioneer/issues/217.

8. Update Spack package (refer to `python-bindings/spack/README.md`).
File renamed without changes.
4 changes: 2 additions & 2 deletions solverdummy/README.md → examples/solverdummy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Run

You can test the dummy solver by coupling two instances with each other. Open two terminals and run
* `python3 solverdummy.py precice-config.xml SolverOne MeshOne`
* `python3 solverdummy.py precice-config.xml SolverTwo MeshTwo`
* `python3 solverdummy.py precice-config.xml SolverOne`
* `python3 solverdummy.py precice-config.xml SolverTwo`

# Next Steps

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
parser.add_argument("configurationFileName",
help="Name of the xml config file.", type=str)
parser.add_argument("participantName", help="Name of the solver.", type=str)
parser.add_argument("meshName", help="Name of the mesh.", type=str)

try:
args = parser.parse_args()
except SystemExit:
print("")
print("Usage: python ./solverdummy precice-config participant-name mesh-name")
print("Usage: python ./solverdummy precice-config participant-name")
quit()

configuration_file_name = args.configurationFileName
participant_name = args.participantName
mesh_name = args.meshName

if participant_name == 'SolverOne':
write_data_name = 'dataOne'
read_data_name = 'dataTwo'
mesh_name = 'MeshOne'

if participant_name == 'SolverTwo':
read_data_name = 'dataOne'
write_data_name = 'dataTwo'
mesh_name = 'MeshTwo'

num_vertices = 3 # Number of vertices

Expand Down
57 changes: 54 additions & 3 deletions spack/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,65 @@
# Spack package: py-pyprecice

The Spack package `py-pyprecice` provides the python bindings via Spack and was submitted via https://github.com/spack/spack/pull/19558. This folder contains the Spack package script that can be used for testing whether the Spack installation works.
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`

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` 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.

## When a new spack release is necessary
## When a new Spack release is necessary

* Add checksum of newest version(s) to the [package recipe in `package.py`](https://github.com/precice/python-bindings/blob/develop/spack/repo/packages/py-pyprecice/package.py). You can get checksum for any released version by running `spack checksum py-pyprecice`.
* Check whether the new release works locally. You can add the Spack repo in this repository and do the following:

1. Add the repository to your Spack installation if you have not done that before. You can check the repositories available with your Spack installation via `spack repo list`. If there is a repository called `pyprecice.test`, check whether it points to the correct path. The correct path is the `spack/repo` directory of python-bindings repository. If the repository is missing, add it via

```text
spack repo add ${REPOSITORY_ROOT}/spack/repo
```
2. Build the new python bindings. Usually, we use a new Spack environment. This is created and loaded via
```text
spack env create pyprecicetest-VERSIONNUMBER
spack env activate -p pyprecicetest-VERSIONNUMBER
```
Note that the dots `.` of the version number are not allowed in the name of Spack environments. One could, e.g., create an environment named `pyprecicetest-2_0_0_1` instead of `pyprecicetest-2.0.0.1`.
3. We add the `py-pyprecice` package from our repository to the environment via
```text
spack add pyprecice.test.py-pyprecice@VERSIONNUMBER
```
This ensures that one uses the local repository which has the namespace `pyprecice.test` when installing `py-precice`. Note that when speciying the `VERSIONNUMBER` you use the actual version number with dots, e.g., `2.0.0.1`, but you have to drop the `v` character from the versioning of the bindings.
4. Concretize the software packages
```text
spack concretize -f
```
and check whether everything looks good. You might want to edit the environment of the Spack environment (the `spack.yaml` file) and enforce combined concretization by adding `concretization: together` at the end of the file. You might want to double check whether the correct repository is used by calling
```text
spack spec -N py-pyprecice@VERSIONNUMBER
```
It will print the concretization and prefixes each packages with the repository it will be installed from.
5. Run `spack install` to actually install the package.
6. If the installation went through, check the installation by running `python3 -c "import precice; print(precice.__version__)"`. This should print the version number of the Python bindings you have installed. *Note*: In order to make the bindings available one might have to reload the environment via
```text
despacktivate
spack env activate -p pyprecicetest-VERSIONNUMBER
```
7. Ideally one runs the solverdummy with the freshly installed Python bindings.
* Add checksum of newest version(s) to https://github.com/precice/python-bindings/blob/develop/spack/repo/packages/py-pyprecice/package.py. You can get checksum for any released version by running `spack checksum py-pyprecice`.
* 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.

This file was deleted.

58 changes: 26 additions & 32 deletions spack/repo/packages/py-pyprecice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ class PyPyprecice(PythonPackage):
C++ library preCICE.
"""

homepage = "https://www.precice.org"
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"
maintainers = ["ajaust", "BenjaminRodenberg"]
maintainers = ["ajaust", "BenjaminRodenberg", "IshaanDesai"]

# Always prefer final version of release candidate
version("develop", branch="develop")
version('2.2.0.1', sha256='032fa58193cfa69e3be37557977056e8f507d89b40c490a351d17271269b25ad')
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")
Expand All @@ -28,35 +31,26 @@ class PyPyprecice(PythonPackage):
version("2.0.0.2", sha256="5f055d809d65ec2e81f4d001812a250f50418de59990b47d6bcb12b88da5f5d7")
version("2.0.0.1", sha256="96eafdf421ec61ad6fcf0ab1d3cf210831a815272984c470b2aea57d4d0c9e0e")

# Older versions of the bindings checked versions via pip. This patch
# removes the pip dependency.
# See also https://github.com/spack/spack/pull/19558
patch("deactivate-version-check-via-pip.patch", when="@:2.1.1.1")

depends_on("precice@develop", when="@develop")
depends_on("[email protected]", when="@2.2.0.1:2.2.0.99")
depends_on("[email protected]", when="@2.1.1.1:2.1.1.99")
depends_on("[email protected]", when="@2.1.0.1:2.1.0.99")
depends_on("[email protected]", when="@2.0.2.1:2.0.2.99")
depends_on("[email protected]", when="@2.0.1.1:2.0.1.99")
depends_on("[email protected]", when="@2.0.0.1:2.0.0.99")

depends_on("python@3:", type=("build", "run"))
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")
depends_on("[email protected]", when="@2.1.1.1:2.1.1")
depends_on("[email protected]", when="@2.1.0.1:2.1.0")
depends_on("[email protected]", when="@2.0.2.1:2.0.2")
depends_on("[email protected]", when="@2.0.1.1:2.0.1")
depends_on("[email protected]", when="@2.0.0.1:2.0.0")

depends_on("python@3:", type=("build", "link", "run"))
depends_on("py-setuptools", type="build")
depends_on("py-numpy", type=("build", "run"))
depends_on("py-numpy", type=("build", "link", "run"))
depends_on("py-mpi4py", type=("build", "run"))
depends_on("[email protected]:", type=("build"))

phases = ['install_lib', 'build_ext', 'install']

def build_ext_args(self, spec, prefix):
return [
"--include-dirs=" + spec["precice"].headers.directories[0],
"--library-dirs=" + spec["precice"].libs.directories[0]
]

def install(self, spec, prefix):
# Older versions of the bindings had a non-standard installation routine
# See also https://github.com/spack/spack/pull/19558#discussion_r513123239
if self.version <= Version("2.1.1.1"):
self.setup_py("install", "--prefix={0}".format(prefix))
depends_on("[email protected]:", type="build")
depends_on("py-packaging", when="@:2.1", type="build")
depends_on("py-pip", when="@:2.1", type="build")

@when("@:2.1")
def patch(self):
filter_file(
"distutils.command.install", "setuptools.command.install", "setup.py"
)

0 comments on commit f6828eb

Please sign in to comment.