From 9dda9fc535575c71599b6437453ff11c47a4a0bd Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 31 Jul 2024 08:38:07 +0200 Subject: [PATCH 1/6] Stop using deprecated packages in CI pep517 has been deprecated for a long time and we don't need it anymore, courtesy of importlib.metadata. --- .github/workflows/ci.yml | 13 +++++-------- admin/check_tag_version_match.py | 13 +++++++------ pyproject.toml | 4 +--- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad8f354c..20a4a5a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -250,18 +250,15 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.11 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pep517 + python-version: 3.12 - name: Display structure of files to be pushed run: ls --recursive dist/ - - name: Check matched tag version and branch version - on tag - run: python admin/check_tag_version_match.py "${{ github.ref }}" + - name: Ensure tag and package versions match. + run: | + python -Im pip install dist/*.whl + python -I admin/check_tag_version_match.py "${{ github.ref }}" - name: Publish to PyPI - on tag uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598 diff --git a/admin/check_tag_version_match.py b/admin/check_tag_version_match.py index f340e040..d401d5bc 100644 --- a/admin/check_tag_version_match.py +++ b/admin/check_tag_version_match.py @@ -1,15 +1,16 @@ # # Used during the release process to make sure that we release based on a -# tag that has the same version as the current twisted.__version. +# tag that has the same version as the current packaging metadata. # # Designed to be conditionally called inside GitHub Actions release job. # Tags should use PEP440 version scheme. # -# To be called as: admin/check_tag_version_match.py refs/tags/twisted-20.3.0 +# To be called as: admin/check_tag_version_match.py refs/tags/20.3.0 # + import sys -import pep517.meta +from importlib import metadata TAG_PREFIX = "refs/tags/" @@ -18,7 +19,7 @@ print("No tag check requested.") sys.exit(0) -branch_version = pep517.meta.load(".").version +branch_version = metadata.version("towncrier") run_version = sys.argv[1] if not run_version.startswith(TAG_PREFIX): @@ -28,8 +29,8 @@ run_version = run_version[len(TAG_PREFIX) :] # noqa: E203 if run_version != branch_version: - print(f"Branch is at '{branch_version}' while tag is '{run_version}'") + print(f"Package is at '{branch_version}' while tag is '{run_version}'") exit(1) -print(f"All good. Branch and tag versions match for '{branch_version}'.") +print(f"All good. Package and tag versions match for '{branch_version}'.") sys.exit(0) diff --git a/pyproject.toml b/pyproject.toml index 133ee710..4e46bdc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,5 @@ [build-system] -requires = [ - "hatchling", -] +requires = ["hatchling"] build-backend = "hatchling.build" From 73a04a8ef9cb81b46a0c26164606ce2454ce288d Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 31 Jul 2024 08:48:05 +0200 Subject: [PATCH 2/6] News fragment --- src/towncrier/newsfragments/630.misc.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/towncrier/newsfragments/630.misc.rst diff --git a/src/towncrier/newsfragments/630.misc.rst b/src/towncrier/newsfragments/630.misc.rst new file mode 100644 index 00000000..e69de29b From 3aadb6a2f105125c48e3e18fe19493b764cad4b2 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 31 Jul 2024 08:51:58 +0200 Subject: [PATCH 3/6] Try a fake version to look at the output --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20a4a5a5..6bf2f61b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -263,6 +263,32 @@ jobs: - name: Publish to PyPI - on tag uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598 + fake-pypi-publish: + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v3 + + - name: Download package files + uses: actions/download-artifact@v3 + with: + name: dist + path: dist/ + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 + + - name: Display structure of files to be pushed + run: ls --recursive dist/ + + - name: Ensure tag and package versions match. + run: | + python -Im pip install dist/*.whl + python -I admin/check_tag_version_match.py "${{ github.ref }}" + coverage: name: Combine & check coverage. From a5ffc701c748b50875c16f512239819452da3026 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 31 Jul 2024 08:56:21 +0200 Subject: [PATCH 4/6] Silence pip version warnings The default pip versions are good enought, nowadays. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bf2f61b..1fba63d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,9 @@ defaults: run: shell: bash +env: + PIP_DISABLE_PIP_VERSION_CHECK: "1" + jobs: build: name: ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }} From 493641cb786668f37bdb3226d00327a57b31e5ff Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 31 Jul 2024 08:58:22 +0200 Subject: [PATCH 5/6] Add debug output & give better name --- admin/check_tag_version_match.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/admin/check_tag_version_match.py b/admin/check_tag_version_match.py index d401d5bc..25ae1809 100644 --- a/admin/check_tag_version_match.py +++ b/admin/check_tag_version_match.py @@ -19,7 +19,8 @@ print("No tag check requested.") sys.exit(0) -branch_version = metadata.version("towncrier") +pkg_version = metadata.version("towncrier") +print(f"Package version is {pkg_version}.") run_version = sys.argv[1] if not run_version.startswith(TAG_PREFIX): @@ -28,9 +29,9 @@ run_version = run_version[len(TAG_PREFIX) :] # noqa: E203 -if run_version != branch_version: - print(f"Package is at '{branch_version}' while tag is '{run_version}'") +if run_version != pkg_version: + print(f"Package is at '{pkg_version}' while tag is '{run_version}'") exit(1) -print(f"All good. Package and tag versions match for '{branch_version}'.") +print(f"All good. Package and tag versions match for '{pkg_version}'.") sys.exit(0) From 0a75ecc755bafa67f213678e11e5ccaa799b5755 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 31 Jul 2024 09:01:01 +0200 Subject: [PATCH 6/6] Revert "Try a fake version to look at the output" This reverts commit 3aadb6a2f105125c48e3e18fe19493b764cad4b2. --- .github/workflows/ci.yml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fba63d8..697d578d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -266,32 +266,6 @@ jobs: - name: Publish to PyPI - on tag uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598 - fake-pypi-publish: - runs-on: ubuntu-latest - needs: - - build - steps: - - uses: actions/checkout@v3 - - - name: Download package files - uses: actions/download-artifact@v3 - with: - name: dist - path: dist/ - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.12 - - - name: Display structure of files to be pushed - run: ls --recursive dist/ - - - name: Ensure tag and package versions match. - run: | - python -Im pip install dist/*.whl - python -I admin/check_tag_version_match.py "${{ github.ref }}" - coverage: name: Combine & check coverage.