Skip to content

Commit 88f1dc9

Browse files
committed
chore: Template upgrade
1 parent 5785a63 commit 88f1dc9

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 1.5.4
2+
_commit: 1.5.6
33
_src_path: gh:pawamoy/copier-uv
44
author_email: dev@pawamoy.fr
55
author_fullname: Timothée Mazzucotelli

pyproject.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ Gitter = "https://gitter.im/mkdocstrings/autorefs"
5151
[project.entry-points."mkdocs.plugins"]
5252
autorefs = "mkdocs_autorefs.plugin:AutorefsPlugin"
5353

54-
[tool.pdm]
55-
version = {source = "scm"}
54+
[tool.pdm.version]
55+
source = "call"
56+
getter = "scripts.get_version:get_version"
5657

5758
[tool.pdm.build]
58-
package-dir = "src"
59-
editable-backend = "editables"
60-
6159
# Include as much as possible in the source distribution, to help redistributors.
6260
excludes = ["**/.pytest_cache"]
6361
source-includes = [
@@ -82,9 +80,6 @@ data = [
8280

8381
[dependency-groups]
8482
dev = [
85-
# dev
86-
"editables>=0.5",
87-
8883
# maintenance
8984
"build>=1.2",
9085
"git-changelog>=2.5",

scripts/get_version.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Get current project version from Git tags or changelog."""
2+
3+
import re
4+
from contextlib import suppress
5+
from pathlib import Path
6+
7+
from pdm.backend.hooks.version import SCMVersion, Version, default_version_formatter, get_version_from_scm
8+
9+
_root = Path(__file__).parent.parent
10+
_changelog = _root / "CHANGELOG.md"
11+
_changelog_version_re = re.compile(r"^## \[(\d+\.\d+\.\d+)\].*$")
12+
_default_scm_version = SCMVersion(Version("0.0.0"), None, False, None, None) # noqa: FBT003
13+
14+
15+
def get_version() -> str:
16+
"""Get current project version from Git tags or changelog."""
17+
scm_version = get_version_from_scm(_root) or _default_scm_version
18+
if scm_version.version <= Version("0.1"): # Missing Git tags?
19+
with suppress(OSError, StopIteration): # noqa: SIM117
20+
with _changelog.open("r", encoding="utf8") as file:
21+
match = next(filter(None, map(_changelog_version_re.match, file)))
22+
scm_version = scm_version._replace(version=Version(match.group(1)))
23+
return default_version_formatter(scm_version)
24+
25+
26+
if __name__ == "__main__":
27+
print(get_version())

scripts/make.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,10 @@ def setup() -> None:
6969
uv_install(venv_path)
7070

7171

72-
def run(version: str, cmd: str, *args: str, no_sync: bool = False, **kwargs: Any) -> None:
72+
def run(version: str, cmd: str, *args: str, **kwargs: Any) -> None:
7373
"""Run a command in a virtual environment."""
7474
kwargs = {"check": True, **kwargs}
75-
uv_run = ["uv", "run"]
76-
if no_sync:
77-
uv_run.append("--no-sync")
75+
uv_run = ["uv", "run", "--no-sync"]
7876
if version == "default":
7977
with environ(UV_PROJECT_ENVIRONMENT=".venv"):
8078
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510
@@ -141,7 +139,7 @@ def main() -> int:
141139
)
142140
if os.path.exists(".venv"):
143141
print("\nAvailable tasks", flush=True)
144-
run("default", "duty", "--list", no_sync=True)
142+
run("default", "duty", "--list")
145143
return 0
146144

147145
while args:

0 commit comments

Comments
 (0)