Skip to content

Commit

Permalink
chore: Template upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 3, 2025
1 parent 84d7fed commit 2751291
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 1.5.4
_commit: 1.5.7
_src_path: gh:pawamoy/copier-uv
author_email: dev@pawamoy.fr
author_fullname: Timothée Mazzucotelli
Expand Down
2 changes: 2 additions & 0 deletions docs/insiders/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ else:
```
<!-- blacken-docs:on -->

Additionally, your sponsorship will give more weight to your upvotes on issues, helping us prioritize work items in our backlog. For more information on how we prioritize work, see this page: [Backlog management](https://pawamoy.github.io/backlog/).

## How to become a sponsor

Thanks for your interest in sponsoring! In order to become an eligible sponsor
Expand Down
1 change: 1 addition & 0 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def check_docs(ctx: Context) -> None:
@duty
def check_types(ctx: Context) -> None:
"""Check that the code is correctly typed."""
os.environ["FORCE_COLOR"] = "1"
ctx.run(
tools.mypy(*PY_SRC_LIST, config_file="config/mypy.ini"),
title=pyprefix("Type-checking"),
Expand Down
11 changes: 3 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ Funding = "https://github.com/sponsors/pawamoy"
[project.entry-points."mkdocs.plugins"]
markdown-exec = "markdown_exec.mkdocs_plugin:MarkdownExecPlugin"

[tool.pdm]
version = {source = "scm"}
[tool.pdm.version]
source = "call"
getter = "scripts.get_version:get_version"

[tool.pdm.build]
package-dir = "src"
editable-backend = "editables"

# Include as much as possible in the source distribution, to help redistributors.
excludes = ["**/.pytest_cache"]
source-includes = [
Expand All @@ -79,9 +77,6 @@ data = [

[dependency-groups]
dev = [
# dev
"editables>=0.5",

# maintenance
"build>=1.2",
"git-changelog>=2.5",
Expand Down
27 changes: 27 additions & 0 deletions scripts/get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Get current project version from Git tags or changelog."""

import re
from contextlib import suppress
from pathlib import Path

from pdm.backend.hooks.version import SCMVersion, Version, default_version_formatter, get_version_from_scm

_root = Path(__file__).parent.parent
_changelog = _root / "CHANGELOG.md"
_changelog_version_re = re.compile(r"^## \[(\d+\.\d+\.\d+)\].*$")
_default_scm_version = SCMVersion(Version("0.0.0"), None, False, None, None) # noqa: FBT003


def get_version() -> str:
"""Get current project version from Git tags or changelog."""
scm_version = get_version_from_scm(_root) or _default_scm_version
if scm_version.version <= Version("0.1"): # Missing Git tags?
with suppress(OSError, StopIteration): # noqa: SIM117
with _changelog.open("r", encoding="utf8") as file:
match = next(filter(None, map(_changelog_version_re.match, file)))
scm_version = scm_version._replace(version=Version(match.group(1)))
return default_version_formatter(scm_version)


if __name__ == "__main__":
print(get_version())
8 changes: 3 additions & 5 deletions scripts/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ def setup() -> None:
uv_install(venv_path)


def run(version: str, cmd: str, *args: str, no_sync: bool = False, **kwargs: Any) -> None:
def run(version: str, cmd: str, *args: str, **kwargs: Any) -> None:
"""Run a command in a virtual environment."""
kwargs = {"check": True, **kwargs}
uv_run = ["uv", "run"]
if no_sync:
uv_run.append("--no-sync")
uv_run = ["uv", "run", "--no-sync"]
if version == "default":
with environ(UV_PROJECT_ENVIRONMENT=".venv"):
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510
Expand Down Expand Up @@ -141,7 +139,7 @@ def main() -> int:
)
if os.path.exists(".venv"):
print("\nAvailable tasks", flush=True)
run("default", "duty", "--list", no_sync=True)
run("default", "duty", "--list")
return 0

while args:
Expand Down

0 comments on commit 2751291

Please sign in to comment.