Skip to content

Commit

Permalink
Drop unsupported Python versions
Browse files Browse the repository at this point in the history
* Upgrade pre-commit dependencies
* Rename codecov config file
* Update manifest file
* Update tests configuration
* Update contributor's agreement link
* Do not create universal wheels
* Migrate to pyproject.toml
* Update requirements files
* Run docs CI job separately
* Pin sphinx version to support Python 3.8
* Add make rules for pip-compile commands
* Add GitHub workflow for uploading to PyPI
* Bump version
  • Loading branch information
replaceafill authored Nov 8, 2023
1 parent e96f0ff commit 30c9805
Show file tree
Hide file tree
Showing 19 changed files with 358 additions and 160 deletions.
File renamed without changes.
6 changes: 0 additions & 6 deletions .coveragerc

This file was deleted.

16 changes: 16 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[flake8]
exclude = .tox, .git, __pycache__, .cache, build, dist, *.pyc, *.egg-info, .eggs
# Error codes:
# - https://flake8.pycqa.org/en/latest/user/error-codes.html
# - https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
# - https://github.com/PyCQA/flake8-bugbear#list-of-warnings
#
# E203: whitespace before `,`, `;` or `:`
# E402: module level import not at top of file
# E501: line too long
# W503: line break before binary operator
ignore =
E203,
E402,
E501,
W503
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: "Release"
on: "workflow_dispatch"
jobs:
build:
name: "Build"
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v4"
with:
python-version: "3.9"
- name: "Build distribution packages"
run: make package-check
- name: "Save distribution directory"
uses: "actions/upload-artifact@v3"
with:
name: "distribution"
path: |
dist
upload:
name: "Upload"
needs: "build"
runs-on: "ubuntu-22.04"
environment: "release"
permissions:
id-token: "write"
steps:
- name: "Restore distribution directory"
uses: "actions/download-artifact@v3"
with:
name: "distribution"
path: |
dist
- name: "Upload distribution packages to PyPI"
uses: "pypa/gh-action-pypi-publish@release/v1"
61 changes: 28 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,57 @@ on:
- "master"
jobs:
test:
name: "Test ${{ matrix.toxenv }}"
runs-on: "ubuntu-20.04"
name: "Test Python ${{ matrix.python-version }}"
runs-on: "ubuntu-22.04"
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.6"
toxenv: "py36"
- python-version: "3.7"
toxenv: "py37"
- python-version: "3.8"
toxenv: "py38"
- python-version: "3.9"
toxenv: "py39"
python-version: [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
- name: "Get pip cache dir"
id: "pip-cache"
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: "Cache pip packages"
uses: "actions/cache@v3"
with:
path: "${{ steps.pip-cache.outputs.dir }}"
key: "${{ runner.os }}-pip-${{ hashFiles('**/base.txt', '**/dev.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
cache: "pip"
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: "Install tox"
run: |
python -m pip install --upgrade pip
pip install tox
pip install tox tox-gh-actions
- name: "Run tox"
env:
TOXENV: ${{ matrix.toxenv }}
run: |
tox -- --cov-report xml:coverage.xml
tox -- --cov metsrw --cov-report xml:coverage.xml
- name: "Upload coverage report"
if: github.repository == 'artefactual-labs/mets-reader-writer'
uses: "codecov/codecov-action@v3"
with:
files: ./coverage.xml
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
name: ${{ matrix.toxenv }}
flags: ${{ matrix.toxenv }}
lint:
name: "Lint"
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v4"
with:
python-version: "3.8"
python-version: "3.12"
cache: "pip"
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: "Install tox"
run: |
python -m pip install --upgrade pip
Expand All @@ -82,7 +74,10 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v4"
with:
python-version: "3.8"
python-version: "3.12"
cache-dependency-path: |
requirements.txt
requirements-dev.txt
- name: "Install tox"
run: |
python -m pip install --upgrade pip
Expand Down
19 changes: 10 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py3-plus, --py36-plus]
args: [--py38-plus]
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: [--py3-plus, --py36-plus]
- repo: https://github.com/ambv/black
rev: 22.8.0
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: "23.10.1"
hooks:
- id: black
args: [--safe, --quiet]
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: "6.1.0"
hooks:
- id: flake8
language_version: python3
additional_dependencies:
- flake8-bugbear==23.9.16
- flake8-comprehensions==3.14.0
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ For more information on contribution guidelines and standards, see the CONTRIBUT

## Contributor's Agreement

In order for the Archivematica development team to accept any patches or code commits, contributors must first sign this [Contributor's Agreement](https://wiki.archivematica.org/images/2/25/Contributor_agreement.txt).
In order for the Archivematica development team to accept any patches or code commits, contributors must first sign this [Contributor's Agreement](https://wiki.archivematica.org/images/e/e6/Archivematica-CLA-firstname-lastname-YYYY.pdf).
The Archivematica contributor's agreement is based almost verbatim on the [Apache Foundation](http://apache.org )'s individual [contributor license](http://www.apache.org/licenses/icla.txt).

If you have any questions or concerns about the Contributor's Agreement, please email us at agreement@artefactual.com to discuss them.
Expand All @@ -61,7 +61,7 @@ This ensures our resources are devoted to making our project the best they can b

### How do I send in an agreement?

Please print out, read, sign, and scan the [contributor agreement](https://wiki.archivematica.org/images/2/25/Contributor_agreement.txt) and email it to agreement@artefactual.com
Please print out, read, sign, and scan the [contributor agreement](https://wiki.archivematica.org/images/e/e6/Archivematica-CLA-firstname-lastname-YYYY.pdf) and email it to agreement@artefactual.com
Alternatively, you may send an original signed agreement to:

Artefactual Systems Inc.
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include metsrw/resources/*
include LICENSE
include LICENSE
include README.md
34 changes: 22 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
.PHONY: clean package package-deps package-source package-upload package-wheel
.DEFAULT_GOAL := help

package-deps:
pip install --upgrade twine wheel
.PHONY: clean package package-deps package-distribution package-upload pip-compile pip-upgrade

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

package-wheel: package-deps
python setup.py bdist_wheel --universal
package-distribution: package-deps ## Create distribution packages
python3 -m build

package-check: package-source package-wheel ## Check the distribution is valid
twine check dist/*
package-check: package-distribution ## Check the distribution is valid
python3 -m twine check --strict dist/*

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

package: package-upload

clean:
clean: ## Clean the package directory
rm -rf metsrw.egg-info/
rm -rf build/
rm -rf dist/

pip-compile: ## Compile pip requirements
pip-compile --allow-unsafe --output-file=requirements.txt pyproject.toml
pip-compile --allow-unsafe --extra=dev --output-file=requirements-dev.txt pyproject.toml

pip-upgrade: ## Upgrade pip requirements
pip-compile --allow-unsafe --upgrade --output-file=requirements.txt pyproject.toml
pip-compile --allow-unsafe --upgrade --extra=dev --output-file=requirements-dev.txt pyproject.toml

help: ## Print this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 1 addition & 1 deletion metsrw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())
__version__ = "0.4.0"
__version__ = "0.5.0"

__all__ = [
"Agent",
Expand Down
6 changes: 3 additions & 3 deletions metsrw/fsentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ def add_dmdsec(self, md, mdtype, mode="mdwrap", **kwargs):
dmdsec.status = kwargs.get("status") or "original"
mdtype_key = utils.generate_mdtype_key(mdtype, kwargs.get("othermdtype", ""))
if mdtype_key in self.dmdsecs_by_mdtype:
group_id = getattr(self.dmdsecs_by_mdtype[mdtype_key][0], "group_id")
if not group_id:
group_id = str(uuid4())
group_id = getattr(
self.dmdsecs_by_mdtype[mdtype_key][0], "group_id", str(uuid4())
)
dmdsec.group_id = group_id
for previous_dmdsec in self.dmdsecs_by_mdtype[mdtype_key]:
previous_dmdsec.group_id = group_id
Expand Down
4 changes: 2 additions & 2 deletions metsrw/plugins/premisrw/premis.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def __getattr__(self, attr_name):
set(
list(self.attrs_to_paths.keys())
+ [x.replace("/", "__") for x in self.attrs_to_paths.values()]
+ list(x.replace(":", "_") for x in self.attributes.keys())
+ [x.replace(":", "_") for x in self.attributes.keys()]
)
)
)
Expand Down Expand Up @@ -897,7 +897,7 @@ def _generate_data(schema, elements, attributes=None, path=None):
subel = _generate_data(subschema, elements, path=new_path)
if (not subel) or (subel == subschema):
continue
if all(map(lambda x: isinstance(x, tuple), subel)):
if all(isinstance(x, tuple) for x in subel):
for subsubel in subel:
data.append(subsubel)
elif not el_is_empty(subel):
Expand Down
Loading

0 comments on commit 30c9805

Please sign in to comment.