From e6905ff517abc2156ca78e3402c155c2afd8ae95 Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Fri, 22 Apr 2022 22:46:44 +0200 Subject: [PATCH 1/7] BLD: Add workflows for building linux aarch64 and macos x86_68 wheels --- .github/workflows/pypi.yaml | 32 ++++++++++++++++++++++++++++-- .github/workflows/pythonapp.yml | 2 +- pyproject.toml | 34 ++++++++++++++++++++++++-------- scripts/download_cp2k.sh | 7 ++++--- test/test_absorption_spectrum.py | 2 +- 5 files changed, 62 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 484fb972e..9a6476652 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -22,6 +22,8 @@ jobs: matrix: buildplat: - [ubuntu-20.04, manylinux_x86_64] + - [ubuntu-20.04, manylinux_aarch64] + - [macos-10.15, macosx_x86_64] version: - "cp37" - "cp38" @@ -31,10 +33,36 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Build wheels + - name: Set up QEMU + if: matrix.buildplat[1] == 'manylinux_aarch64' + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64 + + - name: Get MacOS build dependencies + if: matrix.buildplat[1] == 'macosx_x86_64' + run: | + git clone https://github.com/nlesc-nano/nano-qmflows-manylinux + + cd nano-qmflows-manylinux/macos + tar -xzf macos_deps.tar.gz + cp -r output/bin/* /usr/local/bin/ + cp -r output/lib/* /usr/local/lib/ + cp -r output/include/* /usr/local/include/ + cp -r output/share/* /usr/local/share/ + + - name: Build wheels (x86_64) + uses: pypa/cibuildwheel@v2.4.0 + if: matrix.buildplat[1] != 'manylinux_aarch64' + env: + CIBW_BUILD: ${{ matrix.version }}-${{ matrix.buildplat[1] }} + + - name: Build wheels (aarch64) uses: pypa/cibuildwheel@v2.4.0 + if: matrix.buildplat[1] == 'manylinux_aarch64' env: CIBW_BUILD: ${{ matrix.version }}-${{ matrix.buildplat[1] }} + CIBW_ARCHS_LINUX: aarch64 - uses: actions/upload-artifact@v3 with: @@ -82,7 +110,7 @@ jobs: - uses: actions/checkout@v3 - name: Install CP2K - run: bash scripts/download_cp2k.sh 9.1 + run: bash scripts/download_cp2k.sh x86_64 9.1 - name: Info CP2K run: cp2k.popt --version diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 7de92a42e..1ebd24f55 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -80,7 +80,7 @@ jobs: - uses: actions/checkout@v3 - name: Install CP2K - run: bash scripts/download_cp2k.sh "${{ matrix.cp2k }}" + run: bash scripts/download_cp2k.sh x86_64 "${{ matrix.cp2k }}" - name: Info CP2K run: cp2k.popt --version diff --git a/pyproject.toml b/pyproject.toml index bd01d4060..2f13637f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,21 +20,39 @@ module = [ ignore_missing_imports = true [tool.cibuildwheel] -build = "cp*-manylinux_x86_64" +build = [ + "cp*-manylinux_aarch64", + "cp*-manylinux_x86_64", + "cp*-macosx_x86_64", +] build-verbosity = "3" before-all = "cp licenses/LICENSE*.txt ." -repair-wheel-command = "auditwheel -v repair -w {dest_dir} {wheel}" -manylinux-x86_64-image = "ghcr.io/nlesc-nano/manylinux2014_x86_64-qmflows" -environment = { QMFLOWS_INCLUDEDIR="", QMFLOWS_LIBDIR="", CFLAGS="-Werror", LDFLAGS="-Wl,--strip-debug" } -before-test = [ - "bash {project}/scripts/download_cp2k.sh 9.1", +test-command = [ "mkdir /tmp/nanoqm", "cp {project}/setup.cfg /tmp/nanoqm/", "cp {project}/conftest.py /tmp/nanoqm/conftest.py", "cp -r {project}/test /tmp/nanoqm/test", -] -test-command = [ "cd /tmp/nanoqm", "pytest -m 'not (slow or long)' test", ] test-extras = ["test"] + +[tool.cibuildwheel.linux] +environment = { QMFLOWS_INCLUDEDIR="", QMFLOWS_LIBDIR="", CFLAGS="-Werror", LDFLAGS="-Wl,--strip-debug" } +manylinux-x86_64-image = "ghcr.io/nlesc-nano/manylinux2014_x86_64-qmflows" +manylinux-aarch64-image = "ghcr.io/nlesc-nano/manylinux2014_aarch64-qmflows" +repair-wheel-command = "auditwheel -v repair -w {dest_dir} {wheel}" +before-test = "bash {project}/scripts/download_cp2k.sh x86_64 9.1" +test-skip = "cp310-manylinux_aarch64" # TODO: Remove once aarch64 python 3.10 wheels are available for h5py + +[[tool.cibuildwheel.overrides]] +select = "*-manylinux_aarch64" +before-test = "bash {project}/scripts/download_cp2k.sh arm64 9.1" + +[tool.cibuildwheel.macos] +# TODO: Install CP2K for the tests once a workaround can be found for SCM-NV/qmflows#295 +environment = { QMFLOWS_INCLUDEDIR="", QMFLOWS_LIBDIR="", CFLAGS="-Werror -Wno-sign-compare", LDFLAGS="-Wl", MACOSX_DEPLOYMENT_TARGET="10.14" } +repair-wheel-command = [ + "delocate-listdeps {wheel}", + "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}", +] diff --git a/scripts/download_cp2k.sh b/scripts/download_cp2k.sh index cf1909504..eac50eb57 100644 --- a/scripts/download_cp2k.sh +++ b/scripts/download_cp2k.sh @@ -2,10 +2,11 @@ set -euo pipefail -VERSION="$1" +ARCH="$1" +VERSION="$2" VERSION_LONG=v"$VERSION".0 -echo "Installing CP2K $VERSION binaries" -curl -Ls https://github.com/cp2k/cp2k/releases/download/$VERSION_LONG/cp2k-$VERSION-Linux-x86_64.ssmp -o cp2k.ssmp +echo "Installing CP2K $ARCH $VERSION binaries" +curl -Lsf https://github.com/cp2k/cp2k/releases/download/$VERSION_LONG/cp2k-$VERSION-Linux-$ARCH.ssmp -o cp2k.ssmp chmod u+rx cp2k.ssmp mv cp2k.ssmp /usr/local/bin/cp2k.popt diff --git a/test/test_absorption_spectrum.py b/test/test_absorption_spectrum.py index bd034476b..5ddf043d4 100644 --- a/test/test_absorption_spectrum.py +++ b/test/test_absorption_spectrum.py @@ -75,4 +75,4 @@ def check_properties(self, path: Path, orbitals_type: str, name: str) -> None: # Compare with reference data with h5py.File(PATH_TEST / "test_files.hdf5", "r") as f: ref = f[f"test_absorption_spectrum/TestComputeOscillators/{name}/dipole"][...] - np.testing.assert_allclose(dipole_matrices, ref) + np.testing.assert_allclose(dipole_matrices, ref, rtol=0, atol=1e-08) From a9176dd5dbe8eeaddd35b7dd6fc7792fb8adf82c Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:13:00 +0200 Subject: [PATCH 2/7] TST: Ensure that all tests requiring CP2K are marked as such --- test/test_absorption_spectrum.py | 2 ++ test/test_input_validation.py | 6 +++--- test/test_workflow_single_points.py | 4 +--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_absorption_spectrum.py b/test/test_absorption_spectrum.py index 5ddf043d4..8f32c3943 100644 --- a/test/test_absorption_spectrum.py +++ b/test/test_absorption_spectrum.py @@ -7,6 +7,7 @@ import pytest import qmflows import numpy as np +from qmflows.test_utils import requires_cp2k from nanoqm.common import retrieve_hdf5_data from nanoqm.workflows import workflow_stddft from nanoqm.workflows.input_validation import process_input @@ -14,6 +15,7 @@ from .utilsTest import PATH_TEST, remove_files +@requires_cp2k class TestComputeOscillators: _PARAMS = { "MOLOPT": ("Cd", "input_test_absorption_spectrum.yml", ""), diff --git a/test/test_input_validation.py b/test/test_input_validation.py index 10435574b..85bd69f1b 100644 --- a/test/test_input_validation.py +++ b/test/test_input_validation.py @@ -5,6 +5,7 @@ import yaml import pytest from qmflows import cp2k, run +from qmflows.test_utils import requires_cp2k from qmflows.type_hints import PathLike from qmflows.packages import CP2K_Result from scm import plams @@ -13,7 +14,7 @@ from nanoqm.common import read_cell_parameters_as_array from nanoqm.workflows.input_validation import process_input, schema_workflows, InputSanitizer -from .utilsTest import PATH_TEST, cp2k_available, remove_files, validate_status +from .utilsTest import PATH_TEST, remove_files, validate_status class TestInputValidation: @@ -105,8 +106,7 @@ def test_functional(self, functional_c: bool, functional_x: bool) -> None: assert dft.xc.xc_functional == ref -@pytest.mark.skipif( - not cp2k_available(), reason="CP2K is not install or not loaded") +@requires_cp2k def test_call_cp2k_pbe() -> None: """Check if the input for a PBE cp2k job is valid.""" try: diff --git a/test/test_workflow_single_points.py b/test/test_workflow_single_points.py index 25b5e823f..693f9a434 100644 --- a/test/test_workflow_single_points.py +++ b/test/test_workflow_single_points.py @@ -9,7 +9,7 @@ from nanoqm.workflows.input_validation import process_input from nanoqm.workflows.workflow_single_points import workflow_single_points -from .utilsTest import PATH_TEST, cp2k_available, remove_files +from .utilsTest import PATH_TEST, remove_files def run_single_point(tmp_path: Path, input_file: str): @@ -28,8 +28,6 @@ def run_single_point(tmp_path: Path, input_file: str): remove_files() -# @pytest.mark.skipif( -# not cp2k_available(), reason="CP2K is not install or not loaded") @pytest.mark.slow def test_single_point(tmp_path: Path): """Check that the couplings run.""" From c534c79a2d0162db6da0f3986d303604bd52041e Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:24:11 +0200 Subject: [PATCH 3/7] TST: Move linting dependencies to its own requirementst file --- .github/workflows/pythonapp.yml | 2 +- linting_requirements.txt | 11 +++++++++++ setup.py | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 linting_requirements.txt diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 1ebd24f55..e19525548 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -157,7 +157,7 @@ jobs: python-version: "3.10" - name: Install linters - run: pip install pydocstyle pycodestyle mypy qmflows "numpy>=1.21" types-pyyaml types-setuptools "pyparsing>=3.0.8" + run: pip install -r ./linting_requirements.txt - name: Python info run: | diff --git a/linting_requirements.txt b/linting_requirements.txt new file mode 100644 index 000000000..e5e2ebbcb --- /dev/null +++ b/linting_requirements.txt @@ -0,0 +1,11 @@ +pydocstyle +pycodestyle + +# Mypy-related stuff +mypy +qmflows +numpy>=1.21 +types-pyyaml +types-setuptools +pyparsing>=3.0.8 +Nano-Utils>=2.0.0 diff --git a/setup.py b/setup.py index 554c9fa2b..e6f7353c1 100644 --- a/setup.py +++ b/setup.py @@ -198,6 +198,7 @@ def get_paths() -> "tuple[list[str], list[str]]": extras_require={ 'test': parse_requirements("test_requirements.txt"), 'doc': parse_requirements("doc_requirements.txt"), + 'lint': parse_requirements("linting_requirements.txt"), }, package_data={ 'nanoqm': ['basis/*.json', 'basis/BASIS*', 'basis/GTH_POTENTIALS', 'py.typed', '*.pyi'] From b8fc6292acdbbad835ab3e48049398cef9ed91ab Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:41:32 +0200 Subject: [PATCH 4/7] REL: Only publish wheels to pypi when triggered via a github release --- .github/workflows/pypi.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 9a6476652..d7c72bed8 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -179,6 +179,7 @@ jobs: twine check dist/* - name: Publish wheels + if: github.event_name == 'release' uses: pypa/gh-action-pypi-publish@master with: user: __token__ From d98576ec38a658a25a493c43f3b2ac0cfa505f3c Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:47:25 +0200 Subject: [PATCH 5/7] DOC: Update pypi classifiers --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index e6f7353c1..ae9ac1506 100644 --- a/setup.py +++ b/setup.py @@ -182,10 +182,17 @@ def get_paths() -> "tuple[list[str], list[str]]": classifiers=[ 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', + 'Operating System :: MacOS', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: C++', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: Implementation :: CPython', 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', 'Topic :: Scientific/Engineering :: Chemistry', From c730e640c4d0f636ab96723d3e25b601b2608e22 Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:47:41 +0200 Subject: [PATCH 6/7] DOC: Recommend installation via pypi over building from source --- README.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index cc6e63274..26cd9ae8d 100644 --- a/README.rst +++ b/README.rst @@ -21,15 +21,11 @@ For further information on the theory behind nano-qmflows and how to use the pro Installation ------------ +Pre-compiled binaries are available on pypi and can be installed via ``pip install nano-qmflows`` on MacOS and Linux. -In order to install the **nano-qmflows** library there two options: - -1. Install pre-compiled binaries. -2. Build Nano-QMFlows from source. - -Pre-compiled linux binaries are available on pypi. In order to use them all one needs is a linux machine and then issue the ``pip install nano-qmflows`` command. - -On the other hand, other operating systems (and source builds in general) first require an installation of *Miniconda* as is detailed here_. +Building from source +-------------------- +Building Nano-QMFlows from source first requires an installation of *Miniconda* as is detailed here_. .. _here: https://docs.conda.io/en/latest/miniconda.html From 0dc0b9330e81e47e0657d307f84acb4f0cd77186 Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:42:39 +0200 Subject: [PATCH 7/7] REL: Prepare for the Nano-QMFlows 0.13.2 release --- CHANGELOG.md | 2 +- CITATION.cff | 4 ++-- nanoqm/_version.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea940b289..6fbc8ed1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ # 0.13.2 (unreleased) ## New -* *Placeholder**. +* Add MacOS x86_64 and Linux aarch64 wheels. # 0.13.1 (21/04/2022) diff --git a/CITATION.cff b/CITATION.cff index a91e86d7c..f786e0590 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -17,8 +17,8 @@ keywords: - materials-science - python - Workflows -version: '0.13.1' -date-released: "2022-04-21" +version: '0.13.2' +date-released: "2022-04-26" repository-code: https://github.com/SCM-NV/nano-qmflows license: "Apache-2.0" doi: 10.5281/zenodo.2576893 diff --git a/nanoqm/_version.py b/nanoqm/_version.py index 4a72e0ed8..e8e8a939a 100644 --- a/nanoqm/_version.py +++ b/nanoqm/_version.py @@ -1,3 +1,3 @@ """The Nano-QMFlows version.""" -__version__ = '0.13.2.dev0' +__version__ = '0.13.2'