From d17327347552d31e3ac7f04fbe8fd0360e66d6f3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 11 Oct 2023 16:31:40 +0200 Subject: [PATCH 1/3] Format pyproject.toml for easy comparison with other projects --- pyproject.toml | 51 ++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e47b7eb..79492d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,34 +1,41 @@ [build-system] -requires = ["flit_core>=3.2,<4"] build-backend = "flit_core.buildapi" +requires = [ + "flit_core<4,>=3.2", +] [project] -name = "cherry_picker" -authors = [{ name = "Mariatta Wijaya", email = "mariatta@python.org" }] +name = "cherry-picker" +readme = "readme.rst" maintainers = [{ name = "Python Core Developers", email = "core-workflow@python.org" }] +authors = [{ name = "Mariatta Wijaya", email = "mariatta@python.org" }] +requires-python = ">=3.8" +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3 :: Only", + "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", +] +dynamic = [ + "description", + "version", +] dependencies = [ - "click>=6.0", - "gidgethub", - "requests", - "tomli>=1.1.0;python_version<'3.11'", + "click>=6", + "gidgethub", + "requests", + 'tomli>=1.1; python_version < "3.11"', ] -readme = "readme.rst" -classifiers = [ - "Programming Language :: Python :: 3.8", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", +[project.optional-dependencies] +dev = [ + "pytest", + "pytest-cov", ] -requires-python = ">=3.8" -dynamic = ["version", "description"] - [project.urls] "Homepage" = "https://github.com/python/cherry-picker" - [project.scripts] cherry_picker = "cherry_picker.cherry_picker:cherry_pick_cli" - -[project.optional-dependencies] -dev = [ - "pytest", - "pytest-cov", -] From 115970c7301433624b5fea25e58c4cd08c042fe6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 11 Oct 2023 16:39:01 +0200 Subject: [PATCH 2/3] Use hatch-vcs to get version from Git to enable publishing to Test PyPI --- .github/workflows/deploy.yml | 71 ++++++++++++++++++++++++++++++++++++ cherry_picker/__init__.py | 4 +- pyproject.toml | 11 +++++- 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..3133d5e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,71 @@ +name: Build & maybe upload PyPI package + +on: + push: + pull_request: + release: + types: + - published + workflow_dispatch: + +permissions: + contents: read + +jobs: + # Always build & lint package. + build-package: + name: Build & verify package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: hynek/build-and-inspect-python-package@v1 + + # Upload to Test PyPI on every commit on main. + release-test-pypi: + name: Publish in-dev package to test.pypi.org + if: | + github.repository_owner == 'python' + && github.event_name == 'push' + && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + needs: build-package + + permissions: + id-token: write + + steps: + - name: Download packages built by build-and-inspect-python-package + uses: actions/download-artifact@v3 + with: + name: Packages + path: dist + + - name: Upload package to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + # Upload to real PyPI on GitHub Releases. + release-pypi: + name: Publish released package to pypi.org + # Only run for published releases. + if: | + github.repository_owner == 'python' + && github.event.action == 'published' + runs-on: ubuntu-latest + needs: build-package + + permissions: + id-token: write + + steps: + - name: Download packages built by build-and-inspect-python-package + uses: actions/download-artifact@v3 + with: + name: Packages + path: dist + + - name: Upload package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/cherry_picker/__init__.py b/cherry_picker/__init__.py index 5636972..b654ebc 100644 --- a/cherry_picker/__init__.py +++ b/cherry_picker/__init__.py @@ -1,2 +1,4 @@ """Backport CPython changes from main to maintenance branches.""" -__version__ = "2.2.0" +import importlib.metadata + +__version__ = importlib.metadata.version(__name__) diff --git a/pyproject.toml b/pyproject.toml index 79492d9..1fc22dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,8 @@ [build-system] -build-backend = "flit_core.buildapi" +build-backend = "hatchling.build" requires = [ - "flit_core<4,>=3.2", + "hatch-vcs", + "hatchling", ] [project] @@ -39,3 +40,9 @@ dev = [ "Homepage" = "https://github.com/python/cherry-picker" [project.scripts] cherry_picker = "cherry_picker.cherry_picker:cherry_pick_cli" + +[tool.hatch] +version.source = "vcs" + +[tool.hatch.version.raw-options] +local_scheme = "no-local-version" From f888a92163e79e171d955639ff83d7e0f5bca575 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 12 Oct 2023 02:09:55 -0600 Subject: [PATCH 3/3] Improve wording Co-authored-by: Mariatta --- .github/workflows/deploy.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3133d5e..fb242cc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Build & maybe upload PyPI package +name: Build package on: push: @@ -22,7 +22,7 @@ jobs: - uses: hynek/build-and-inspect-python-package@v1 - # Upload to Test PyPI on every commit on main. + # Publish to Test PyPI on every commit on main. release-test-pypi: name: Publish in-dev package to test.pypi.org if: | @@ -42,14 +42,14 @@ jobs: name: Packages path: dist - - name: Upload package to Test PyPI + - name: Publish to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ - # Upload to real PyPI on GitHub Releases. + # Publish to PyPI on GitHub Releases. release-pypi: - name: Publish released package to pypi.org + name: Publish to PyPI # Only run for published releases. if: | github.repository_owner == 'python' @@ -67,5 +67,5 @@ jobs: name: Packages path: dist - - name: Upload package to PyPI + - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1