File tree 3 files changed +21
-5
lines changed
3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,8 @@ jobs:
132
132
steps :
133
133
- name : Check out source code
134
134
uses : actions/checkout@v4
135
+ with :
136
+ fetch-depth : 0
135
137
- name : Set up PDM
136
138
uses : pdm-project/setup-pdm@v4
137
139
with :
@@ -260,4 +262,4 @@ jobs:
260
262
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
261
263
with :
262
264
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
1
4
from pdm .backend ._vendor .packaging .version import Version
2
5
3
6
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
+
7
16
def pdm_build_initialize (context ):
8
17
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).
9
22
if version .is_prerelease :
10
23
url_version = "latest"
11
24
else :
Original file line number Diff line number Diff line change 2
2
3
3
[tool .pdm .version ]
4
4
source = " scm"
5
+ version_format = " pdm_build:format_version"
5
6
6
7
[project ]
7
8
dynamic = [" version" ]
@@ -39,7 +40,7 @@ amaranth-rpc = "amaranth.rpc:main"
39
40
# Build system configuration
40
41
41
42
[build-system ]
42
- requires = [" pdm-backend" ]
43
+ requires = [" pdm-backend @ git+https://github.com/pdm-project/pdm-backend@885bc8d9b75d068a34b2df86c6324c5fdf5c0cc8 " ]
43
44
build-backend = " pdm.backend"
44
45
45
46
[tool .pdm ]
You can’t perform that action at this time.
0 commit comments