From 008d266d8d7be5a8bdc65f825d7f64cdd45bd230 Mon Sep 17 00:00:00 2001 From: Andrey Kislyuk Date: Tue, 31 Dec 2024 13:49:40 -0800 Subject: [PATCH] Use trusted publishing and hatch --- .github/workflows/release.yml | 21 +++++++++++++ common.mk | 9 ------ pyproject.toml | 59 +++++++++++++++++++++++++++++++++++ setup.py | 50 ----------------------------- 4 files changed, 80 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100755 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..26c7ad3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Publish release to PyPI + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + pypi-publish: + name: Build and upload release to PyPI + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - run: pip install build + - run: python -m build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/common.mk b/common.mk index 8a98231..72c3f06 100644 --- a/common.mk +++ b/common.mk @@ -18,11 +18,7 @@ release: @if ! type -P pandoc; then echo "Please install pandoc"; exit 1; fi @if ! type -P sponge; then echo "Please install moreutils"; exit 1; fi @if ! type -P gh; then echo "Please install gh"; exit 1; fi - @if ! type -P twine; then echo "Please install twine"; exit 1; fi git pull - git clean -x --force $$(python setup.py --name) - sed -i -e "s/version=\([\'\"]\)[0-9]*\.[0-9]*\.[0-9]*/version=\1$${TAG:1}/" setup.py - git add setup.py TAG_MSG=$$(mktemp); \ echo "# Changes for ${TAG} ($$(date +%Y-%m-%d))" > $$TAG_MSG; \ git log --pretty=format:%s $$(git describe --abbrev=0)..HEAD >> $$TAG_MSG; \ @@ -34,13 +30,8 @@ release: git push --follow-tags $(MAKE) install gh release create ${TAG} dist/*.whl --notes="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')" - $(MAKE) release-pypi $(MAKE) release-docs -release-pypi: - python -m build - twine upload dist/*.tar.gz dist/*.whl --verbose - release-docs: $(MAKE) docs -git branch -D gh-pages diff --git a/pyproject.toml b/pyproject.toml index 24df85d..2eb8c6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,62 @@ +[project] +name = "signxml" +description = "Python XML Signature and XAdES library" +readme = "README.rst" +requires-python = ">=3.8" +license = { text = "Apache Software License" } +authors = [{ name = "Andrey Kislyuk"}, {email = "kislyuk@gmail.com" }] +authors = [{ name = "Andrey Kislyuk"}, {email = "kislyuk@gmail.com" }] +dynamic = ["version"] +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Development Status :: 5 - Production/Stable", + "Topic :: Software Development", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = [ + "lxml >= 5.2.1, < 6", # Ubuntu 24.04 LTS + "cryptography >= 43", # Required to support client certificate validation + "certifi >= 2023.11.17", # Ubuntu 24.04 LTS + # "tsp-client >= 0.1.3", +] + +[project.optional-dependencies] +test = [ + "ruff", + "coverage", + "build", + "wheel", + "mypy", + "lxml-stubs", +] + +[project.urls] +"Homepage"= "https://github.com/kislyuk/signxml" +"Documentation"= "https://xml-security.github.io/signxml/" +"Source Code"= "https://github.com/kislyuk/signxml" +"Issue Tracker"= "https://github.com/kislyuk/signxml/issues" +"Change Log"= "https://github.com/kislyuk/signxml/blob/main/Changes.rst" + +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "vcs" + [tool.black] line-length = 120 diff --git a/setup.py b/setup.py deleted file mode 100755 index b50719e..0000000 --- a/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python - -from setuptools import find_packages, setup - -setup( - name="signxml", - version="4.0.3", - url="https://github.com/kislyuk/signxml", - license="Apache Software License", - author="Andrey Kislyuk", - author_email="kislyuk@gmail.com", - description="Python XML Signature and XAdES library", - long_description=open("README.rst").read(), - python_requires=">=3.7", - install_requires=[ - "lxml >= 5.2.1, < 6", # Ubuntu 24.04 LTS - "cryptography >= 43", # Required to support client certificate validation - "certifi >= 2023.11.17", # Ubuntu 24.04 LTS - # "tsp-client >= 0.1.3", - ], - extras_require={ - "tests": [ - "ruff", - "coverage", - "build", - "wheel", - "mypy", - "lxml-stubs", - ] - }, - packages=find_packages(exclude=["test"]), - platforms=["MacOS X", "Posix"], - package_data={"signxml": ["schemas/*.xsd", "py.typed"]}, - include_package_data=True, - test_suite="test", - classifiers=[ - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX", - "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development :: Libraries :: Python Modules", - ], -)