From 199f649ef4704f0ef668260a167c0f1ae50b2462 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 21 Nov 2022 14:21:23 +0000 Subject: [PATCH 1/6] Modernise python package management: - Use flit instead of setuptools - Replace setup.json & setup.py with pyproject.toml - Update publish workflow - Remove MANIFEST.in --- .github/workflows/publish.yml | 126 ++++++++-------------------------- MANIFEST.in | 1 - aiida_cp2k/__init__.py | 2 +- pyproject.toml | 59 ++++++++++++++++ setup.json | 54 --------------- setup.py | 27 -------- 6 files changed, 87 insertions(+), 182 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.json delete mode 100644 setup.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 39af6504..b644316d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,104 +1,32 @@ --- -name: Publish on Test PyPI and PyPI +name: Publish on PyPI on: - push: - branches: - # Commits pushed to release/ branches are published on Test PyPI if they - # have a new version number. - - release/** - tags: - # Tags that start with the "v" prefix are published on PyPI. - - v* + push: + tags: + # After vMajor.Minor.Patch _anything_ is allowed (without "/") ! + - v[0-9]+.[0-9]+.[0-9]+* jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - - uses: actions/checkout@v2 - - - name: Set up Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - - name: Install pypa/build - run: python -m pip install build - - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ - - name: Upload distribution artifact - uses: actions/upload-artifact@v2 - with: - name: release - path: dist/ - - - publish-test: - - name: Build and publish on TestPyPI - if: startsWith(github.ref, 'refs/heads/release/') - needs: [build] - runs-on: ubuntu-latest - - environment: - name: Test PyPI - url: https://test.pypi.org/project/aiida-cp2k/ - - steps: - - uses: actions/download-artifact@v2 - name: Download distribution artifact - with: - name: release - path: dist/ - - - name: Publish distribution on Test PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - if: startsWith(github.ref, 'refs/heads/release/') - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: true - - publish: - - name: Build and publish on PyPI - if: startsWith(github.ref, 'refs/tags') - needs: [build] - runs-on: ubuntu-latest - - environment: - name: PyPI - url: https://pypi.org/project/aiida-cp2k/ - - steps: - - - uses: actions/download-artifact@v2 - name: Download distribution artifact - with: - name: release - path: dist/ - - - uses: softprops/action-gh-release@v0.1.14 - name: Create release - if: startsWith(github.ref, 'refs/tags/v') - with: - files: | - dist/* - generate_release_notes: true - - - name: Publish distribution on PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} + publish: + runs-on: ubuntu-latest + if: github.repository == 'aiidateam/aiida-core' && startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Checkout source + uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - uses: softprops/action-gh-release@v0.1.14 + name: Create release + with: + generate_release_notes: true + + - name: Build and publish + run: | + flit publish + env: + FLIT_USERNAME: __token__ + FLIT_PASSWORD: ${{ secrets.PYPI_KEY }} diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index d2ce7024..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include setup.json diff --git a/aiida_cp2k/__init__.py b/aiida_cp2k/__init__.py index d818fdc0..e100a3b7 100644 --- a/aiida_cp2k/__init__.py +++ b/aiida_cp2k/__init__.py @@ -4,7 +4,7 @@ # AiiDA-CP2K is hosted on GitHub at https://github.com/aiidateam/aiida-cp2k # # For further information on the license, see the LICENSE.txt file. # ############################################################################### -"""AiiDA-CP2K plugins, parsers, workflows, etc ...""" +"""The official AiiDA plugin for CP2K.""" __version__ = "1.5.0" diff --git a/pyproject.toml b/pyproject.toml index ef27a665..c68fd2ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,62 @@ +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.module] +name = "aiida_cp2k" + +[project] +name = "aiida-cp2k" +dynamic = ["version", "description"] +readme = "README.md" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Framework :: AiiDA", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", + "Programming Language :: Python :: 3", +] +dependencies = [ + "aiida-core>=1.1.0,<2.0.0", + "aiida-gaussian-datatypes", + "ase", + "ruamel.yaml>=0.16.5", + "cp2k-output-tools", +] + +[[project.authors]] +name = "The AiiDA team" + +[project.urls] +Homepage = "https://github.com/aiidateam/aiida-cp2k" + +[project.optional-dependencies] +dev = [ + "pgtest~=1.3", + "pytest~=6.0", + "pytest-cov~=2.11.1", + "coverage", + "pre-commit~=2.19", +] +docs = [ + "sphinx", + "sphinx-rtd-theme", + "sphinxcontrib-contentui", + "sphinxcontrib-details-directive", +] + +[project.entry-points."aiida.calculations"] +cp2k = "aiida_cp2k.calculations:Cp2kCalculation" + +[project.entry-points."aiida.parsers"] +cp2k_base_parser = "aiida_cp2k.parsers:Cp2kBaseParser" +cp2k_advanced_parser = "aiida_cp2k.parsers:Cp2kAdvancedParser" +cp2k_tools_parser = "aiida_cp2k.parsers:Cp2kToolsParser" + +[project.entry-points."aiida.workflows"] +"cp2k.base" = "aiida_cp2k.workchains:Cp2kBaseWorkChain" + [tool.pytest.ini_options] python_files = "test_*.py example_*.py" python_functions = "example_* test_*" diff --git a/setup.json b/setup.json deleted file mode 100644 index 6e7fdbb6..00000000 --- a/setup.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "author": "The AiiDA team", - "author_email": "yakutovicha@gmail.com", - "classifiers": [ - "Development Status :: 5 - Production/Stable", - "Framework :: AiiDA", - "License :: OSI Approved :: MIT License", - "Operating System :: POSIX :: Linux", - "Operating System :: MacOS :: MacOS X", - "Programming Language :: Python :: 3" - ], - "description": "The official AiiDA plugin for CP2K.", - "install_requires": [ - "aiida-core>=1.1.0,<2.0.0", - "aiida-gaussian-datatypes", - "ase", - "ruamel.yaml>=0.16.5", - "cp2k-output-tools" - ], - "entry_points": { - "aiida.calculations": [ - "cp2k = aiida_cp2k.calculations:Cp2kCalculation" - ], - "aiida.parsers": [ - "cp2k_base_parser = aiida_cp2k.parsers:Cp2kBaseParser", - "cp2k_advanced_parser = aiida_cp2k.parsers:Cp2kAdvancedParser", - "cp2k_tools_parser = aiida_cp2k.parsers:Cp2kToolsParser" - ], - "aiida.workflows": [ - "cp2k.base = aiida_cp2k.workchains:Cp2kBaseWorkChain" - ] - }, - "extras_require": { - "test": [ - "pgtest~=1.3", - "pytest~=6.0", - "pytest-cov~=2.11.1", - "coverage" - ], - "pre-commit":[ - "pre-commit~=2.19" - ], - "docs": [ - "sphinx", - "sphinx-rtd-theme", - "sphinxcontrib-contentui", - "sphinxcontrib-details-directive" - ] - }, - "license": "MIT License", - "name": "aiida_cp2k", - "url": "https://github.com/aiidateam/aiida-cp2k", - "version": "1.5.0" -} diff --git a/setup.py b/setup.py deleted file mode 100644 index 9bfdeae6..00000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -############################################################################### -# Copyright (c), The AiiDA-CP2K authors. # -# SPDX-License-Identifier: MIT # -# AiiDA-CP2K is hosted on GitHub at https://github.com/aiidateam/aiida-cp2k # -# For further information on the license, see the LICENSE.txt file. # -############################################################################### -"""Setting up CP2K plugin for AiiDA""" - -import json - -from setuptools import find_packages, setup - - -def run_setup(): - with open("setup.json", encoding="utf-8") as info: - kwargs = json.load(info) - setup( - include_package_data=True, - packages=find_packages(), - long_description=open("README.md", encoding="utf-8").read(), - long_description_content_type="text/markdown", - **kwargs - ) - - -if __name__ == "__main__": - run_setup() From 7398ea7a26b14428473eaf8309636fc773423d7d Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 21 Nov 2022 14:30:32 +0000 Subject: [PATCH 2/6] fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33323023..e627d8f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: - name: Install python dependencies run: | pip install --upgrade pip - pip install -e .[pre-commit,test,docs] + pip install -e .[dev,docs] reentry scan - name: Run pre-commit run: | From 46d00777f0c6a29c50fb13a33e489a562c8330d3 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 21 Nov 2022 14:36:07 +0000 Subject: [PATCH 3/6] Fix2 --- .github/workflows/ci.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e627d8f8..2ba5d1ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,7 @@ jobs: - name: Install python dependencies run: | pip install --upgrade pip - pip install -e .[docs,test] + pip install -e .[docs,dev] reentry scan - name: Build docs diff --git a/Dockerfile b/Dockerfile index f221a268..cf7dad42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN set -ex ; \ # Install aiida-cp2k plugin. COPY . aiida-cp2k -RUN pip install ./aiida-cp2k[pre-commit,test,docs] +RUN pip install ./aiida-cp2k[dev,docs] # Install coverals. RUN pip install coveralls From bd8cb30e2e1f671246b146f1e78ef0246b18eb80 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 21 Nov 2022 14:52:36 +0000 Subject: [PATCH 4/6] Remove an obsolete test for the version agreement --- test/test_version_agreement.py | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 test/test_version_agreement.py diff --git a/test/test_version_agreement.py b/test/test_version_agreement.py deleted file mode 100644 index 0ac9f7a2..00000000 --- a/test/test_version_agreement.py +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################### -# Copyright (c), The AiiDA-CP2K authors. # -# SPDX-License-Identifier: MIT # -# AiiDA-CP2K is hosted on GitHub at https://github.com/aiidateam/aiida-cp2k # -# For further information on the license, see the LICENSE.txt file. # -############################################################################### -"""Check versions""" - -import json -import sys - -import aiida_cp2k - - -def test_version_agreement(): - """Check if versions in setup.json and in plugin are consistent""" - version1 = aiida_cp2k.__version__ - with open("setup.json") as fhandle: - version2 = json.load(fhandle)["version"] - - if version1 != version2: - print( - f"ERROR: Versions in aiida_cp2k/__init__.py and setup.json are inconsistent: {version1} vs {version2}" - ) - sys.exit(3) From b331532f2f9a742d940b70d7bd1f3d073d28b34c Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 21 Nov 2022 17:41:53 +0000 Subject: [PATCH 5/6] Apply review suggestions. --- .github/workflows/publish.yml | 14 +++++++++----- pyproject.toml | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b644316d..0e029fac 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ on: jobs: publish: runs-on: ubuntu-latest - if: github.repository == 'aiidateam/aiida-core' && startsWith(github.ref, 'refs/tags/v') + if: github.repository == 'aiidateam/aiida-cp2k' steps: - name: Checkout source @@ -19,14 +19,18 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.8' + - name: Build source distribution + run: flit build - uses: softprops/action-gh-release@v0.1.14 name: Create release with: + files: | + dist/* generate_release_notes: true - + - name: Install flit + run: pip install flit~=3.4 - name: Build and publish - run: | - flit publish + run: flit publish env: FLIT_USERNAME: __token__ - FLIT_PASSWORD: ${{ secrets.PYPI_KEY }} + FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index c68fd2ce..ffcfe883 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ name = "aiida_cp2k" name = "aiida-cp2k" dynamic = ["version", "description"] readme = "README.md" +license = {file = 'LICENSE.txt'} classifiers = [ "Development Status :: 5 - Production/Stable", "Framework :: AiiDA", @@ -17,8 +18,9 @@ classifiers = [ "Operating System :: MacOS :: MacOS X", "Programming Language :: Python :: 3", ] +requires-python = ">=3.8" dependencies = [ - "aiida-core>=1.1.0,<2.0.0", + "aiida-core~=1.1", "aiida-gaussian-datatypes", "ase", "ruamel.yaml>=0.16.5", From ee6a5d614d01b1a4340b444368755e4850ab3c6a Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Mon, 21 Nov 2022 21:24:12 +0000 Subject: [PATCH 6/6] Run gh-release actions right after the `flit publish`. --- .github/workflows/publish.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0e029fac..16ff1215 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,14 +19,6 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.8' - - name: Build source distribution - run: flit build - - uses: softprops/action-gh-release@v0.1.14 - name: Create release - with: - files: | - dist/* - generate_release_notes: true - name: Install flit run: pip install flit~=3.4 - name: Build and publish @@ -34,3 +26,9 @@ jobs: env: FLIT_USERNAME: __token__ FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + - uses: softprops/action-gh-release@v0.1.14 + name: Create release + with: + files: | + dist/* + generate_release_notes: true