Skip to content

Commit

Permalink
+ pyproject: use setuptools-scm to derive version number from tags
Browse files Browse the repository at this point in the history
this way we don't have to change it in two places and have it pollute
the commits, instead the latest tag will be what the version number is.
it means we have to check in the source code before releasing but that's
probably normal anyways
  • Loading branch information
smemsh committed Oct 30, 2024
1 parent 4142c39 commit c749bb8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
LIB := timew
PYBASE := python3.12

SHELL := /bin/bash
VERSION := $(shell \
numpat='\d+\.\d+\.\d+'; \
grep -P -m1 "^version\\s+=\\s+\"$$numpat\"\$$" pyproject.toml \
| grep -oP "$$numpat")
ver=$$($(PYBASE) -m setuptools_scm -q version); \
major=$${ver%%.*}; \
rest=$${ver#*.}; \
minor=$${rest%%.*}; \
rest=$${rest#*.}; \
patch=$${rest%%.*}; \
echo $$major.$$minor.$$patch; \
:; )

REQIN = requirements.in
REQOUT = requirements.txt
Expand Down Expand Up @@ -66,4 +72,8 @@ clean: cleandoc

rebuild: clean sdist wheel

vartest:
@echo shell: $(SHELL)
@echo version: $(VERSION)

.PHONY: wheel sdist test docs sync pkgup reqs devreqs clean cleandoc rebuild
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

[project]
name = "timew"
version = "0.1.1"
readme = "README.rst"
keywords = ["timewarrior",]
dynamic = ["dependencies", "optional-dependencies",]
dynamic = ["version", "dependencies", "optional-dependencies",]
authors = [
{name = "Tjaart van der Walt", email = "[email protected]"},
{name = "Scott Mcdermott", email = "[email protected]"},
Expand Down Expand Up @@ -36,6 +35,10 @@ optional-dependencies.dev = { file = ["requirements-dev.txt"] }
[tool.setuptools.packages]
find = {namespaces = false}

[tool.setuptools_scm]
version_scheme = "only-version"
local_scheme = "no-local-version"

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ build >= 1.0.3
pytest >= 7.4.4
pytest-cov >= 4.1.0

setuptools-scm >= 8.1.0

sphinx >= 7.2.6
sphinxcontrib-apidoc >= 0.4.0
sphinxcontrib-napoleon >= 0.7.0
Expand Down
13 changes: 10 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ certifi==2023.11.17
charset-normalizer==3.3.2
# via requests
coverage[toml]==7.4.0
# via
# coverage
# pytest-cov
# via pytest-cov
docutils==0.20.1
# via sphinx
exceptiongroup==1.2.0
Expand All @@ -40,6 +38,7 @@ packaging==23.2
# via
# build
# pytest
# setuptools-scm
# sphinx
pbr==6.0.0
# via sphinxcontrib-apidoc
Expand All @@ -61,6 +60,8 @@ python-dateutil==2.8.2
# via -r requirements.in
requests==2.31.0
# via sphinx
setuptools-scm==8.1.0
# via -r requirements-dev.in
six==1.16.0
# via
# pockets
Expand Down Expand Up @@ -97,7 +98,13 @@ tomli==2.0.1
# coverage
# pyproject-hooks
# pytest
# setuptools-scm
typing-extensions==4.12.2
# via setuptools-scm
urllib3==2.1.0
# via requests
zipp==3.17.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools

0 comments on commit c749bb8

Please sign in to comment.