Skip to content

Commit d32ca04

Browse files
committed
pyproject: migrate to PDM build backend.
`.git_archival.txt` and the functionality of deriving SCM version from a GitHub generated archive is removed pending implementation of pdm-project/pdm-backend#194.
1 parent a9d0380 commit d32ca04

File tree

5 files changed

+27
-38
lines changed

5 files changed

+27
-38
lines changed

.git_archival.txt

-4
This file was deleted.

.gitattributes

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
.git_archival.txt export-subst
21
/amaranth/vendor/* -linguist-vendored

pdm_build.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pdm.backend._vendor.packaging.version import Version
2+
3+
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 pdm_build_initialize(context):
8+
version = Version(context.config.metadata["version"])
9+
if version.is_prerelease:
10+
url_version = "latest"
11+
else:
12+
url_version = f"v{version}"
13+
context.config.metadata["urls"]["Documentation"] += url_version

pyproject.toml

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Project metadata
22

3+
[tool.pdm.version]
4+
source = "scm"
5+
36
[project]
4-
dynamic = ["version", "urls"]
7+
dynamic = ["version"]
58

69
name = "amaranth"
710
description = "Amaranth hardware definition language"
@@ -23,21 +26,24 @@ remote-build = ["paramiko~=2.7"]
2326
[project.scripts]
2427
amaranth-rpc = "amaranth.rpc:main"
2528

29+
[project.urls]
30+
"Homepage" = "https://amaranth-lang.org/"
31+
"Documentation" = "https://amaranth-lang.org/docs/amaranth/" # modified in pdm_build.py
32+
"Source Code" = "https://github.com/amaranth-lang/amaranth"
33+
"Bug Tracker" = "https://github.com/amaranth-lang/amaranth/issues"
34+
2635
# Build system configuration
2736

2837
[build-system]
29-
requires = ["wheel", "setuptools>=67.0", "setuptools_scm[toml]>=6.2"]
30-
build-backend = "setuptools.build_meta"
38+
requires = ["pdm-backend"]
39+
build-backend = "pdm.backend"
3140

32-
[tool.setuptools]
41+
[tool.pdm.build]
3342
# If amaranth 0.3 is checked out with git (e.g. as a part of a persistent editable install or
3443
# a git worktree cached by tools like poetry), it can have an empty `nmigen` directory left over,
3544
# which causes a hard error because setuptools cannot determine the top-level package.
3645
# Add a workaround to improve experience for people upgrading from old checkouts.
37-
packages = ["amaranth"]
38-
39-
[tool.setuptools_scm]
40-
local_scheme = "node-and-timestamp"
46+
includes = ["amaranth/"]
4147

4248
# Development workflow configuration
4349

setup.py

-25
This file was deleted.

0 commit comments

Comments
 (0)