Skip to content
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

Update Spack recipe (v2.3.0.1, release documentation, sync packages) #133

Merged
merged 5 commits into from
Oct 21, 2021
Merged
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 && 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}"
Copy link
Member

@BenjaminRodenberg BenjaminRodenberg Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As already discussed personally: Interesting that this has ever worked...

35 changes: 34 additions & 1 deletion spack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,40 @@ The workflow `build-spack-pyprecice-deps` in `.github/workflows/build-env.yml` c

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 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
```bash
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
```
spack env create pyprecicetest-VERSIONNUMBER
spack env activate -p pyprecicetest-VERSIONNUMBER
spack
```
Note that the dots `.` in the version number must be replaced by underscores or similar.
3. We add the `py-pyprecice` package from our repository to the environment via
```
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`.
4. Concretize the software packages
```
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
```
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 ```
despacktivate
spack env activate -p pyprecicetest-VERSIONNUMBER
```
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.

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("precice@2.2.0", when="@2.2.0.1:2.2.0.99")
depends_on("precice@2.1.1", when="@2.1.1.1:2.1.1.99")
depends_on("precice@2.1.0", when="@2.1.0.1:2.1.0.99")
depends_on("precice@2.0.2", when="@2.0.2.1:2.0.2.99")
depends_on("precice@2.0.1", when="@2.0.1.1:2.0.1.99")
depends_on("precice@2.0.0", when="@2.0.0.1:2.0.0.99")

depends_on("python@3:", type=("build", "run"))
depends_on("precice@2.3.0", when="@2.3.0.1:2.3.1")
depends_on("precice@2.2.1", when="@2.2.1.1:2.2.1")
depends_on("precice@2.2.0", when="@2.2.0.1:2.2.0")
depends_on("precice@2.1.1", when="@2.1.1.1:2.1.1")
depends_on("precice@2.1.0", when="@2.1.0.1:2.1.0")
depends_on("precice@2.0.2", when="@2.0.2.1:2.0.2")
depends_on("precice@2.0.1", when="@2.0.1.1:2.0.1")
depends_on("precice@2.0.0", 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("py-cython@0.29:", 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("py-cython@0.29:", 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"
)