Skip to content

Commit

Permalink
Migrate to the PDM build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfng committed Jan 30, 2024
1 parent 2f2ad5c commit d66881d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 19 deletions.
4 changes: 0 additions & 4 deletions .git_archival.txt

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

19 changes: 15 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ on:
pull_request:
schedule:
- cron: '0 0 * * *' # test daily against git HEAD of dependencies

name: CI
jobs:

test:
runs-on: ubuntu-latest
strategy:
Expand All @@ -18,10 +20,16 @@ jobs:
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
fetch-depth: 0
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install codecov
pdm install --dev
- name: Install Amaranth release
if: ${{ matrix.amaranth-version != 'git' }}
run: |
Expand All @@ -30,9 +38,12 @@ jobs:
if: ${{ matrix.amaranth-version == 'git' }}
run: |
pip install git+https://github.com/amaranth-lang/amaranth.git
- name: Test
- name: Run tests
run: |
python -m unittest discover
pdm run test
- name: Submit code coverage
run:
codecov

required: # group all required workflows into one for the required status check
needs:
Expand Down
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
18 changes: 12 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Project metadata

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

[project]
dynamic = ["version"]

Expand All @@ -15,17 +18,16 @@ dependencies = [
]

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

# Build system configuration

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

[tool.setuptools_scm]
local_scheme = "node-and-timestamp"
requires = ["pdm-backend"]
build-backend = "pdm.backend"

# Development workflow configuration

Expand All @@ -34,7 +36,7 @@ test = [
"coverage",
]
docs = [
"sphinx~=5.3",
"sphinx~=7.1",
"sphinx-rtd-theme~=1.2",
"sphinx-autobuild",
]
Expand All @@ -43,3 +45,7 @@ docs = [
test.composite = ["test-code"]
test-code.env = {PYTHONWARNINGS = "error"}
test-code.cmd = "python -m coverage run -m unittest discover -t . -s tests -v"
test-docs.cmd = "sphinx-build -b doctest docs docs/_build"

document.cmd = "sphinx-build docs docs/_build"
document-live.cmd = "sphinx-autobuild docs docs/_build --watch amaranth"
4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

0 comments on commit d66881d

Please sign in to comment.