Skip to content

Commit 67a5d2b

Browse files
authored
Drop unsupported Python versions
* Update GitHub CI workflow * Upgrade pre-commit dependencies * Rename codecov config file * Update manifest file * Update tests configuration * Migrate to pyproject.toml * Update requirements files * Fix coverage report generation * Add make rules for pip-compile commands * Add GitHub workflow for uploading to PyPI
1 parent 6bec0c8 commit 67a5d2b

22 files changed

+419
-278
lines changed
File renamed without changes.

.coveragerc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.flake8

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[flake8]
2+
exclude = .tox, .git, __pycache__, .cache, build, dist, *.pyc, *.egg-info, .eggs
3+
# Error codes:
4+
# - https://flake8.pycqa.org/en/latest/user/error-codes.html
5+
# - https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
6+
# - https://github.com/PyCQA/flake8-bugbear#list-of-warnings
7+
#
8+
# E203: whitespace before `,`, `;` or `:`
9+
# E402: module level import not at top of file
10+
# E501: line too long
11+
# W503: line break before binary operator
12+
ignore =
13+
E203,
14+
E402,
15+
E501,
16+
W503

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: "Release"
3+
on: "workflow_dispatch"
4+
jobs:
5+
build:
6+
name: "Build"
7+
runs-on: "ubuntu-22.04"
8+
steps:
9+
- name: "Check out repository"
10+
uses: "actions/checkout@v4"
11+
- name: "Set up Python"
12+
uses: "actions/setup-python@v4"
13+
with:
14+
python-version: "3.9"
15+
- name: "Build distribution packages"
16+
run: make package-check
17+
- name: "Save distribution directory"
18+
uses: "actions/upload-artifact@v3"
19+
with:
20+
name: "distribution"
21+
path: |
22+
dist
23+
upload:
24+
name: "Upload"
25+
needs: "build"
26+
runs-on: "ubuntu-22.04"
27+
environment: "release"
28+
permissions:
29+
id-token: "write"
30+
steps:
31+
- name: "Restore distribution directory"
32+
uses: "actions/download-artifact@v3"
33+
with:
34+
name: "distribution"
35+
path: |
36+
dist
37+
- name: "Upload distribution packages to PyPI"
38+
uses: "pypa/gh-action-pypi-publish@release/v1"

.github/workflows/test.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,30 @@ on:
66
branches:
77
- "master"
88
jobs:
9-
tox:
10-
name: "Test ${{ matrix.toxenv }}"
11-
runs-on: "ubuntu-20.04"
9+
test:
10+
name: "Test Python ${{ matrix.python-version }}"
11+
runs-on: "ubuntu-22.04"
1212
strategy:
13+
fail-fast: false
1314
matrix:
14-
include:
15-
- python-version: "3.6"
16-
toxenv: "py36"
17-
- python-version: "3.7"
18-
toxenv: "py37"
19-
- python-version: "3.8"
20-
toxenv: "py38"
21-
- python-version: "3.9"
22-
toxenv: "py39"
15+
python-version: [
16+
"3.8",
17+
"3.9",
18+
"3.10",
19+
"3.11",
20+
"3.12",
21+
]
2322
steps:
2423
- name: "Check out repository"
25-
uses: "actions/checkout@v3"
24+
uses: "actions/checkout@v4"
2625
- name: "Set up Python ${{ matrix.python-version }}"
2726
uses: "actions/setup-python@v4"
2827
with:
2928
python-version: "${{ matrix.python-version }}"
29+
cache: "pip"
30+
cache-dependency-path: |
31+
requirements.txt
32+
requirements-dev.txt
3033
- name: "Install OS packages"
3134
run: |
3235
sudo apt-get --quiet update
@@ -42,31 +45,31 @@ jobs:
4245
- name: "Install tox"
4346
run: |
4447
python -m pip install --upgrade pip
45-
pip install tox
48+
pip install tox tox-gh-actions
4649
- name: "Run tox"
47-
env:
48-
TOXENV: ${{ matrix.toxenv }}
4950
run: |
50-
tox -- --cov ammcpc --cov-config .coveragerc --cov-report xml:coverage.xml
51+
tox -- --cov ammcpc --cov-report xml:coverage.xml
5152
- name: "Upload coverage report"
5253
if: github.repository == 'artefactual-labs/ammcpc'
5354
uses: "codecov/codecov-action@v3"
5455
with:
5556
files: ./coverage.xml
56-
fail_ci_if_error: true
57+
fail_ci_if_error: false
5758
verbose: true
58-
name: ${{ matrix.toxenv }}
59-
flags: ${{ matrix.toxenv }}
6059
lint:
6160
name: "Lint"
6261
runs-on: "ubuntu-22.04"
6362
steps:
6463
- name: "Check out repository"
65-
uses: "actions/checkout@v3"
64+
uses: "actions/checkout@v4"
6665
- name: "Set up Python"
6766
uses: "actions/setup-python@v4"
6867
with:
69-
python-version: "3.8"
68+
python-version: "3.12"
69+
cache: "pip"
70+
cache-dependency-path: |
71+
requirements.txt
72+
requirements-dev.txt
7073
- name: "Install tox"
7174
run: |
7275
python -m pip install --upgrade pip

.pre-commit-config.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
repos:
22
- repo: https://github.com/asottile/pyupgrade
3-
rev: v2.31.0
3+
rev: v3.15.0
44
hooks:
55
- id: pyupgrade
6-
args: [--py3-plus, --py36-plus]
6+
args: [--py38-plus]
77
- repo: https://github.com/asottile/reorder_python_imports
8-
rev: v2.6.0
8+
rev: v3.12.0
99
hooks:
1010
- id: reorder-python-imports
11-
args: [--py3-plus, --py36-plus]
12-
- repo: https://github.com/ambv/black
13-
rev: 22.8.0
11+
args: [--py38-plus]
12+
- repo: https://github.com/psf/black
13+
rev: "23.10.1"
1414
hooks:
1515
- id: black
1616
args: [--safe, --quiet]
17-
language_version: python3
1817
- repo: https://github.com/pycqa/flake8
19-
rev: 5.0.4
18+
rev: "6.1.0"
2019
hooks:
2120
- id: flake8
22-
language_version: python3
21+
additional_dependencies:
22+
- flake8-bugbear==23.9.16
23+
- flake8-comprehensions==3.14.0

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
include LICENSE
2+
include README.rst

Makefile

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
.PHONY: clean package package-deps package-source package-upload package-wheel
1+
.DEFAULT_GOAL := help
22

3-
package-deps:
4-
pip install --upgrade twine wheel
3+
.PHONY: clean package package-deps package-distribution package-upload pip-compile pip-upgrade
54

6-
package-source:
7-
python setup.py sdist
5+
package-deps: ## Upgrade dependencies for packaging
6+
python3 -m pip install --upgrade build twine
87

9-
package-wheel: package-deps
10-
python setup.py bdist_wheel --universal
8+
package-distribution: package-deps ## Create distribution packages
9+
python3 -m build
1110

12-
package-check: package-source package-wheel ## Check the distribution is valid
13-
twine check dist/*
11+
package-check: package-distribution ## Check the distribution is valid
12+
python3 -m twine check --strict dist/*
1413

15-
package-upload: package-deps package-check
16-
twine upload dist/* --repository-url https://upload.pypi.org/legacy/
14+
package-upload: package-deps package-check ## Upload distribution packages
15+
python3 -m twine upload dist/* --repository-url https://upload.pypi.org/legacy/
1716

1817
package: package-upload
1918

20-
clean:
21-
rm -rf metsrw.egg-info/
19+
clean: ## Clean the package directory
20+
rm -rf ammcpc.egg-info/
2221
rm -rf build/
2322
rm -rf dist/
23+
24+
pip-compile: ## Compile pip requirements
25+
pip-compile --allow-unsafe --output-file=requirements.txt pyproject.toml
26+
pip-compile --allow-unsafe --extra=dev --output-file=requirements-dev.txt pyproject.toml
27+
28+
pip-upgrade: ## Upgrade pip requirements
29+
pip-compile --allow-unsafe --upgrade --output-file=requirements.txt pyproject.toml
30+
pip-compile --allow-unsafe --upgrade --extra=dev --output-file=requirements-dev.txt pyproject.toml
31+
32+
help: ## Print this help message
33+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

pyproject.toml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=68",
4+
"wheel>=0.41",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[tool.setuptools.packages.find]
9+
where = [""]
10+
include = ["ammcpc*"]
11+
namespaces = false
12+
13+
[project]
14+
name = "ammcpc"
15+
dynamic = [
16+
"version",
17+
"readme",
18+
]
19+
description = "Python command line wrapper around MediaConch policy checks."
20+
requires-python = ">=3.8"
21+
license = {file = "LICENSE"}
22+
dependencies = [
23+
"lxml",
24+
]
25+
keywords = [
26+
"archivematica",
27+
"preservation",
28+
]
29+
classifiers = [
30+
"Development Status :: 3 - Alpha",
31+
"Environment :: Console",
32+
"Intended Audience :: Information Technology",
33+
"License :: OSI Approved :: GNU Affero General Public License v3",
34+
"Operating System :: POSIX :: Linux",
35+
"Programming Language :: Python :: 3 :: Only",
36+
"Programming Language :: Python :: 3.8",
37+
"Programming Language :: Python :: 3.9",
38+
"Programming Language :: Python :: 3.10",
39+
"Programming Language :: Python :: 3.11",
40+
"Programming Language :: Python :: 3.12",
41+
]
42+
authors = [
43+
{name = "Artefactual Systems Inc.", email = "[email protected]"}
44+
]
45+
maintainers = [
46+
{name = "Artefactual Systems Inc.", email = "[email protected]"}
47+
]
48+
49+
[project.urls]
50+
homepage = "https://github.com/artefactual-labs/ammcpc/"
51+
repository = "https://github.com/artefactual-labs/ammcpc/"
52+
issues = "https://github.com/archivematica/Issues/issues"
53+
54+
[project.scripts]
55+
ammcpc = "ammcpc.ammcpc:main"
56+
57+
[project.optional-dependencies]
58+
dev = [
59+
"pytest",
60+
"pytest-cov",
61+
"coverage",
62+
"pip-tools",
63+
]
64+
65+
[tool.setuptools.dynamic]
66+
version = {attr = "ammcpc.ammcpc.__version__"}
67+
readme = {file = ["README.rst"]}
68+
69+
[tool.pytest.ini_options]
70+
python_files = [
71+
"test_*.py",
72+
]
73+
testpaths = [
74+
"tests",
75+
]
76+
77+
[tool.coverage.run]
78+
source = [
79+
"ammcpc",
80+
]
81+
branch = true
82+
omit = [
83+
"tests/*",
84+
]
85+
86+
[tool.tox]
87+
legacy_tox_ini = """
88+
[tox]
89+
envlist = py{38,39,310,311,312}, linting
90+
91+
[gh-actions]
92+
python =
93+
3.8: py38
94+
3.9: py39
95+
3.10: py310
96+
3.11: py311
97+
3.12: py312
98+
99+
[testenv]
100+
skip_install = true
101+
deps = -r {toxinidir}/requirements-dev.txt
102+
commands = pytest {posargs}
103+
104+
[testenv:linting]
105+
basepython = python3
106+
deps = pre-commit
107+
commands = pre-commit run --all-files --show-diff-on-failure
108+
"""

requirements-dev.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.9
3+
# by the following command:
4+
#
5+
# pip-compile --allow-unsafe --extra=dev --output-file=requirements-dev.txt pyproject.toml
6+
#
7+
build==1.0.3
8+
# via pip-tools
9+
click==8.1.7
10+
# via pip-tools
11+
coverage[toml]==7.3.2
12+
# via
13+
# ammcpc (pyproject.toml)
14+
# pytest-cov
15+
exceptiongroup==1.1.3
16+
# via pytest
17+
importlib-metadata==6.8.0
18+
# via build
19+
iniconfig==2.0.0
20+
# via pytest
21+
lxml==4.9.3
22+
# via ammcpc (pyproject.toml)
23+
packaging==23.2
24+
# via
25+
# build
26+
# pytest
27+
pip-tools==7.3.0
28+
# via ammcpc (pyproject.toml)
29+
pluggy==1.3.0
30+
# via pytest
31+
pyproject-hooks==1.0.0
32+
# via build
33+
pytest==7.4.3
34+
# via
35+
# ammcpc (pyproject.toml)
36+
# pytest-cov
37+
pytest-cov==4.1.0
38+
# via ammcpc (pyproject.toml)
39+
tomli==2.0.1
40+
# via
41+
# build
42+
# coverage
43+
# pip-tools
44+
# pyproject-hooks
45+
# pytest
46+
wheel==0.41.3
47+
# via pip-tools
48+
zipp==3.17.0
49+
# via importlib-metadata
50+
51+
# The following packages are considered to be unsafe in a requirements file:
52+
pip==23.3.1
53+
# via pip-tools
54+
setuptools==68.2.2
55+
# via pip-tools

0 commit comments

Comments
 (0)