Skip to content

Commit

Permalink
💚 Fix version string to be PEP440 compliant for TestPyPI
Browse files Browse the repository at this point in the history
Change from semver to PEP440 and remove the git hash part of the version string when uploading to TestPyPI. Based on mtkennerly/poetry-dynamic-versioning#78 (comment). Prevents errors like `'0.0.0.post15+f899e49' is an invalid value for Version. Error: Can't use PEP 440 local versions. See https://packaging.python.org/specifications/core-metadata for more information`.
  • Loading branch information
weiji14 committed Jun 7, 2022
1 parent c59a79a commit db7513a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ jobs:
poetry plugin add poetry-dynamic-versioning-plugin
poetry show
- name: Fix up version string for TestPyPI
if: ${{ !startsWith(github.ref, 'refs/tags') }}
run: |
# Change poetry-dynamic-versioning to use metadata=false so that the
# local part of the version isn't included, making the version string
# compatible with PyPI.
sed --in-place "s/metadata = true/metadata = false/g" pyproject.toml
- name: Build a binary wheel and a source tarball
run: |
poetry build -vvv
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ docs = [
]

[tool.poetry-dynamic-versioning]
bump = true
enable = true
style = "semver"
metadata = true
style = "pep440"

[build-system]
requires = ["poetry>=1.2.0b1", "poetry-dynamic-versioning"]
Expand Down

0 comments on commit db7513a

Please sign in to comment.