Skip to content

Commit

Permalink
pyproject: migrate to PDM build backend.
Browse files Browse the repository at this point in the history
`.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.
  • Loading branch information
whitequark committed Sep 12, 2023
1 parent a9d0380 commit d32ca04
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 38 deletions.
4 changes: 0 additions & 4 deletions .git_archival.txt

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.git_archival.txt export-subst
/amaranth/vendor/* -linguist-vendored
13 changes: 13 additions & 0 deletions pdm_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pdm.backend._vendor.packaging.version import Version


# 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
# 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:
url_version = "latest"
else:
url_version = f"v{version}"
context.config.metadata["urls"]["Documentation"] += url_version
22 changes: 14 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Project metadata

[tool.pdm.version]
source = "scm"

[project]
dynamic = ["version", "urls"]
dynamic = ["version"]

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

[project.urls]
"Homepage" = "https://amaranth-lang.org/"
"Documentation" = "https://amaranth-lang.org/docs/amaranth/" # modified in pdm_build.py
"Source Code" = "https://github.com/amaranth-lang/amaranth"
"Bug Tracker" = "https://github.com/amaranth-lang/amaranth/issues"

# Build system configuration

[build-system]
requires = ["wheel", "setuptools>=67.0", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.setuptools]
[tool.pdm.build]
# If amaranth 0.3 is checked out with git (e.g. as a part of a persistent editable install or
# a git worktree cached by tools like poetry), it can have an empty `nmigen` directory left over,
# which causes a hard error because setuptools cannot determine the top-level package.
# Add a workaround to improve experience for people upgrading from old checkouts.
packages = ["amaranth"]

[tool.setuptools_scm]
local_scheme = "node-and-timestamp"
includes = ["amaranth/"]

# Development workflow configuration

Expand Down
25 changes: 0 additions & 25 deletions setup.py

This file was deleted.

0 comments on commit d32ca04

Please sign in to comment.