pyproject: use .dev{distance}
, not +{node}
, for non-release builds.
At the moment this uses a git URL for pdm-backend because required PDM functionality (pdm-project/pdm-backend#217) is not released yet.
This commit is contained in:
parent
8bf4f77616
commit
3fbed68365
2
.github/workflows/main.yaml
vendored
2
.github/workflows/main.yaml
vendored
|
@ -132,6 +132,8 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source code
|
- name: Check out source code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
- name: Set up PDM
|
- name: Set up PDM
|
||||||
uses: pdm-project/setup-pdm@v4
|
uses: pdm-project/setup-pdm@v4
|
||||||
with:
|
with:
|
||||||
|
|
17
pdm_build.py
17
pdm_build.py
|
@ -1,11 +1,24 @@
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
from pdm.backend.hooks.version import SCMVersion
|
||||||
from pdm.backend._vendor.packaging.version import Version
|
from pdm.backend._vendor.packaging.version import Version
|
||||||
|
|
||||||
|
|
||||||
|
def format_version(version: SCMVersion) -> str:
|
||||||
|
major, minor, patch = (int(n) for n in str(version.version).split(".")[:3])
|
||||||
|
dirty = f"+{datetime.utcnow():%Y%m%d.%H%M%S}" if version.dirty else ""
|
||||||
|
if version.distance is None:
|
||||||
|
return f"{major}.{minor}.{patch}{dirty}"
|
||||||
|
else:
|
||||||
|
return f"{major}.{minor}.{patch}.dev{version.distance}{dirty}"
|
||||||
|
|
||||||
|
|
||||||
|
def pdm_build_initialize(context):
|
||||||
|
version = Version(context.config.metadata["version"])
|
||||||
|
|
||||||
# This is done in a PDM build hook without specifying `dynamic = [..., "version"]` to put all
|
# This is done in a PDM build hook without specifying `dynamic = [..., "version"]` to put all
|
||||||
# of the static metadata into pyproject.toml. Tools other than PDM will not execute this script
|
# of the static metadata into pyproject.toml. Tools other than PDM will not execute this script
|
||||||
# and will use the generic version of the documentation URL (which redirects to /latest).
|
# and will use the generic version of the documentation URL (which redirects to /latest).
|
||||||
def pdm_build_initialize(context):
|
|
||||||
version = Version(context.config.metadata["version"])
|
|
||||||
if version.is_prerelease:
|
if version.is_prerelease:
|
||||||
url_version = "latest"
|
url_version = "latest"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
[tool.pdm.version]
|
[tool.pdm.version]
|
||||||
source = "scm"
|
source = "scm"
|
||||||
|
version_format = "pdm_build:format_version"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
|
@ -39,7 +40,7 @@ amaranth-rpc = "amaranth.rpc:main"
|
||||||
# Build system configuration
|
# Build system configuration
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["pdm-backend"]
|
requires = ["pdm-backend @ git+https://github.com/pdm-project/pdm-backend@885bc8d9b75d068a34b2df86c6324c5fdf5c0cc8"]
|
||||||
build-backend = "pdm.backend"
|
build-backend = "pdm.backend"
|
||||||
|
|
||||||
[tool.pdm]
|
[tool.pdm]
|
||||||
|
|
Loading…
Reference in a new issue