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

Modernise python package management: #166

Merged
merged 6 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
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
126 changes: 27 additions & 99 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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')
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved

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
Copy link

Choose a reason for hiding this comment

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

How does this work? Is this supposed to create the tag automatically? If so, this will never get called though, because the workflow is only run when a tag is pushed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I typically use bumpver to create a tag automatically. I will add the tool in the next PR together with a section in the README explaining how to use it.

Copy link

Choose a reason for hiding this comment

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

Ok, so the tag will have been created locally, and then the action is just responsible for creating a release entry on Github. However, did I understand correctly that this also pushes the build to PyPI? If so, then you don't want to have flit publish in the next step. Because then you are pushing to PyPI twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, did I understand correctly that this also pushes the build to PyPI?

No, publishing on PyPi is typically done as the next step, see for example https://github.com/nanotech-empa/aiida-gaussian/blob/master/.github/workflows/publish.yml


- name: Build and publish
run: |
flit publish
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved
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
59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved
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",
Copy link

Choose a reason for hiding this comment

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

Good practice to indicate explicitly which Python 3 versions are supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's leave it for the next PR if that is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

]
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved
dependencies = [
"aiida-core>=1.1.0,<2.0.0",
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved
"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"
Copy link

Choose a reason for hiding this comment

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

Does the identifier need to be quoted? That's what I have in my pyproject.toml's but not sure if it is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know 🤷


[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.