Skip to content

Commit

Permalink
Merge pull request #370 from BvB93/wheels
Browse files Browse the repository at this point in the history
BLD: Add workflows for building linux aarch64 and macos x86_68 wheels
  • Loading branch information
BvB93 authored Apr 26, 2022
2 parents c7d89b1 + 0dc0b93 commit 4740043
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 34 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -31,11 +33,37 @@ 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/[email protected]
if: matrix.buildplat[1] != 'manylinux_aarch64'
env:
CIBW_BUILD: ${{ matrix.version }}-${{ matrix.buildplat[1] }}

- name: Build wheels (aarch64)
uses: pypa/[email protected]
if: matrix.buildplat[1] == 'manylinux_aarch64'
env:
CIBW_BUILD: ${{ matrix.version }}-${{ matrix.buildplat[1] }}
CIBW_ARCHS_LINUX: aarch64

- uses: actions/upload-artifact@v3
with:
name: wheels
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -151,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__
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# 0.13.2 (unreleased)

## New
* *Placeholder**.
* Add MacOS x86_64 and Linux aarch64 wheels.


# 0.13.1 (21/04/2022)
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 4 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions linting_requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion nanoqm/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""The Nano-QMFlows version."""

__version__ = '0.13.2.dev0'
__version__ = '0.13.2'
34 changes: 26 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
]
7 changes: 4 additions & 3 deletions scripts/download_cp2k.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -198,6 +205,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']
Expand Down
4 changes: 3 additions & 1 deletion test/test_absorption_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
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

from .utilsTest import PATH_TEST, remove_files


@requires_cp2k
class TestComputeOscillators:
_PARAMS = {
"MOLOPT": ("Cd", "input_test_absorption_spectrum.yml", ""),
Expand Down Expand Up @@ -75,4 +77,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)
6 changes: 3 additions & 3 deletions test/test_input_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions test/test_workflow_single_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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."""
Expand Down

0 comments on commit 4740043

Please sign in to comment.