Skip to content

Commit

Permalink
Modernise python package management (#166)
Browse files Browse the repository at this point in the history
- Use `flit` instead of `setuptools`.
- Replace `setup.json` & `setup.py` with `pyproject.toml`.
- Update publish workflow.
- Remove `MANIFEST.in`.
- Remove an obsolete test for the version agreement.
  • Loading branch information
yakutovicha authored Nov 21, 2022
1 parent aaf3fe9 commit 23881a7
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 210 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
128 changes: 29 additions & 99 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,104 +1,34 @@
---
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/[email protected]
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-cp2k'

steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install flit
run: pip install flit~=3.4
- name: Build and publish
run: flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
- uses: softprops/[email protected]
name: Create release
with:
files: |
dist/*
generate_release_notes: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion aiida_cp2k/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
61 changes: 61 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
[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"
license = {file = 'LICENSE.txt'}
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",
]
requires-python = ">=3.8"
dependencies = [
"aiida-core~=1.1",
"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_*"
Expand Down
54 changes: 0 additions & 54 deletions setup.json

This file was deleted.

27 changes: 0 additions & 27 deletions setup.py

This file was deleted.

25 changes: 0 additions & 25 deletions test/test_version_agreement.py

This file was deleted.

0 comments on commit 23881a7

Please sign in to comment.