File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,8 @@ jobs:
132132 steps :
133133 - name : Check out source code
134134 uses : actions/checkout@v4
135+ with :
136+ fetch-depth : 0
135137 - name : Set up PDM
136138 uses : pdm-project/setup-pdm@v4
137139 with :
@@ -260,4 +262,4 @@ jobs:
260262 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
261263 with :
262264 tag_name : ${{ github.ref_name }}
263- release_name : ${{ steps.metadata.outputs.name }}
265+ release_name : ${{ steps.metadata.outputs.name }}
Original file line number Diff line number Diff line change 1+ import os
2+ from datetime import datetime
3+ from pdm .backend .hooks .version import SCMVersion
14from pdm .backend ._vendor .packaging .version import Version
25
36
4- # This is done in a PDM build hook without specifying `dynamic = [..., "version"]` to put all
5- # of the static metadata into pyproject.toml. Tools other than PDM will not execute this script
6- # and will use the generic version of the documentation URL (which redirects to /latest).
7+ def format_version (version : SCMVersion ) -> str :
8+ major , minor , patch = (int (n ) for n in str (version .version ).split ("." )[:3 ])
9+ dirty = f"+{ datetime .utcnow ():%Y%m%d.%H%M%S} " if version .dirty else ""
10+ if version .distance is None :
11+ return f"{ major } .{ minor } .{ patch } { dirty } "
12+ else :
13+ return f"{ major } .{ minor } .{ patch } .dev{ version .distance } { dirty } "
14+
15+
716def pdm_build_initialize (context ):
817 version = Version (context .config .metadata ["version" ])
18+
19+ # This is done in a PDM build hook without specifying `dynamic = [..., "version"]` to put all
20+ # of the static metadata into pyproject.toml. Tools other than PDM will not execute this script
21+ # and will use the generic version of the documentation URL (which redirects to /latest).
922 if version .is_prerelease :
1023 url_version = "latest"
1124 else :
Original file line number Diff line number Diff line change 22
33[tool .pdm .version ]
44source = " scm"
5+ version_format = " pdm_build:format_version"
56
67[project ]
78dynamic = [" version" ]
@@ -39,7 +40,7 @@ amaranth-rpc = "amaranth.rpc:main"
3940# Build system configuration
4041
4142[build-system ]
42- requires = [" pdm-backend" ]
43+ requires = [" pdm-backend @ git+https://github.com/pdm-project/pdm-backend@885bc8d9b75d068a34b2df86c6324c5fdf5c0cc8 " ]
4344build-backend = " pdm.backend"
4445
4546[tool .pdm ]
You can’t perform that action at this time.
0 commit comments