Skip to content

Commit d9660fd

Browse files
committed
pyproject.toml: use setuptools_scm to determine version number
This means we no longer have to update the version number manually when creating a new release because just setting a tag suffices. It does however also add some complexity and magic to the project, like incorrect version numbers when the git history is not complete (hence why we now clone the whole history in the build job) and all files included in the git repository now being shipped in the source distribution (while previously only files mentioned in the MANIFEST.in were included). The beneftis when it comes to automating the release process do however outweight the drawbacks of added compexity. We use `local_scheme = "no-local-version"` to prevent random files in the project directory from causing "+dirty" version numbers. Signed-off-by: Leonard Göhrs <[email protected]>
1 parent 2da3f46 commit d9660fd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/workflows/check-and-build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- uses: actions/checkout@v4
32+
with:
33+
# include tags and full history for setuptools_scm
34+
fetch-depth: 0
3235
- run: make build
3336
- uses: actions/upload-artifact@v4
3437
with:

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[build-system]
2-
requires = ["setuptools"]
2+
requires = ["setuptools", "setuptools_scm[toml]"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "usbsdmux"
77
description = "Tool to control an USB-SD-Mux from the command line"
8-
version = "24.01.1"
98
authors = [
109
{ name = "Chris Fiege", email = "[email protected]" },
1110
]
@@ -18,6 +17,7 @@ classifiers = [
1817
"Operating System :: Unix",
1918
"Programming Language :: Python :: 3 :: Only",
2019
]
20+
dynamic = ["version"] # via setuptools_scm
2121

2222
[project.optional-dependencies]
2323
mqtt = ["paho-mqtt"]
@@ -37,6 +37,9 @@ packages = [
3737
]
3838
include-package-data = true
3939

40+
[tool.setuptools_scm]
41+
local_scheme = "no-local-version"
42+
4043
[tool.ruff]
4144
line-length = 119
4245
exclude = [

0 commit comments

Comments
 (0)