-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
30 changed files
with
532 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Changes here will be overwritten by Copier | ||
_commit: 1.1.0 | ||
_commit: 1.5.4 | ||
_src_path: gh:pawamoy/copier-uv | ||
author_email: [email protected] | ||
author_fullname: Timothée Mazzucotelli | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
name: Documentation update | ||
about: Point at unclear, missing or outdated documentation. | ||
title: "docs: " | ||
labels: docs | ||
assignees: pawamoy | ||
--- | ||
|
||
### Is something unclear, missing or outdated in our documentation? | ||
<!-- A clear and concise description of what the documentation issue is. Ex. I can't find an explanation on feature [...]. --> | ||
|
||
### Relevant code snippets | ||
<!-- If the documentation issue is related to code, please provide relevant code snippets. --> | ||
|
||
### Link to the relevant documentation section | ||
<!-- Add a link to the relevant section of our documentation, or any addition context. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
name: Change request | ||
about: Suggest any other kind of change for this project. | ||
title: "change: " | ||
assignees: pawamoy | ||
--- | ||
|
||
### Is your change request related to a problem? Please describe. | ||
<!-- A clear and concise description of what the problem is. --> | ||
|
||
### Describe the solution you'd like | ||
<!-- A clear and concise description of what you want to happen. --> | ||
|
||
### Describe alternatives you've considered | ||
<!-- A clear and concise description of any alternative solutions you've considered. --> | ||
|
||
### Additional context | ||
<!-- Add any other context or screenshots about the change request here. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
/.pdm-build/ | ||
/htmlcov/ | ||
/site/ | ||
uv.lock | ||
|
||
# cache | ||
.cache/ | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
[pytest] | ||
python_files = | ||
test_*.py | ||
*_test.py | ||
tests.py | ||
addopts = | ||
--cov | ||
--cov-config config/coverage.ini | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
target-version = "py38" | ||
target-version = "py39" | ||
line-length = 120 | ||
|
||
[lint] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!-- Giscus --> | ||
<!-- https://squidfunk.github.io/mkdocs-material/setup/adding-a-comment-system/#giscus-integration --> | ||
<div id="feedback" style="display: none;"> | ||
<h2 id="__comments">Feedback</h2> | ||
<script src="https://giscus.app/client.js" | ||
data-repo="pawamoy/git-changelog" | ||
data-repo-id="MDEwOlJlcG9zaXRvcnkxMzgwNjk3MjQ=" | ||
data-category="Documentation" | ||
data-category-id="DIC_kwDOCDrG3M4CkmXD" | ||
data-mapping="pathname" | ||
data-strict="1" | ||
data-reactions-enabled="0" | ||
data-emit-metadata="0" | ||
data-input-position="top" | ||
data-theme="preferred_color_scheme" | ||
data-lang="en" | ||
data-loading="lazy" | ||
crossorigin="anonymous" | ||
async> | ||
</script> | ||
|
||
<!-- Synchronize Giscus theme with palette --> | ||
<script> | ||
var giscus = document.querySelector("script[src*=giscus]") | ||
|
||
// Set palette on initial load | ||
var palette = __md_get("__palette") | ||
if (palette && typeof palette.color === "object") { | ||
var theme = palette.color.scheme === "slate" | ||
? "transparent_dark" | ||
: "light" | ||
|
||
// Instruct Giscus to set theme | ||
giscus.setAttribute("data-theme", theme) | ||
} | ||
|
||
// Register event handlers after documented loaded | ||
document.addEventListener("DOMContentLoaded", function() { | ||
var ref = document.querySelector("[data-md-component=palette]") | ||
ref.addEventListener("change", function() { | ||
var palette = __md_get("__palette") | ||
if (palette && typeof palette.color === "object") { | ||
var theme = palette.color.scheme === "slate" | ||
? "transparent_dark" | ||
: "light" | ||
|
||
// Instruct Giscus to change theme | ||
var frame = document.querySelector(".giscus-frame") | ||
frame.contentWindow.postMessage( | ||
{ giscus: { setConfig: { theme } } }, | ||
"https://giscus.app" | ||
) | ||
} | ||
}) | ||
}) | ||
</script> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
--- | ||
hide: | ||
- feedback | ||
--- | ||
|
||
--8<-- "README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const feedback = document.forms.feedback; | ||
feedback.hidden = false; | ||
|
||
feedback.addEventListener("submit", function(ev) { | ||
ev.preventDefault(); | ||
const commentElement = document.getElementById("feedback"); | ||
commentElement.style.display = "block"; | ||
feedback.firstElementChild.disabled = true; | ||
const data = ev.submitter.getAttribute("data-md-value"); | ||
const note = feedback.querySelector(".md-feedback__note [data-md-value='" + data + "']"); | ||
if (note) { | ||
note.hidden = false; | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
--- | ||
hide: | ||
- feedback | ||
--- | ||
|
||
# License | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
make.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
#!/usr/bin/env python3 | ||
"""Management commands.""" | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
import shutil | ||
import subprocess | ||
import sys | ||
from contextlib import contextmanager | ||
from pathlib import Path | ||
from textwrap import dedent | ||
from typing import TYPE_CHECKING, Any | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Iterator | ||
|
||
|
||
PYTHON_VERSIONS = os.getenv("PYTHON_VERSIONS", "3.9 3.10 3.11 3.12 3.13 3.14").split() | ||
|
||
|
||
def shell(cmd: str, *, capture_output: bool = False, **kwargs: Any) -> str | None: | ||
"""Run a shell command.""" | ||
if capture_output: | ||
return subprocess.check_output(cmd, shell=True, text=True, **kwargs) # noqa: S602 | ||
subprocess.run(cmd, shell=True, check=True, stderr=subprocess.STDOUT, **kwargs) # noqa: S602 | ||
return None | ||
|
||
|
||
@contextmanager | ||
def environ(**kwargs: str) -> Iterator[None]: | ||
"""Temporarily set environment variables.""" | ||
original = dict(os.environ) | ||
os.environ.update(kwargs) | ||
try: | ||
yield | ||
finally: | ||
os.environ.clear() | ||
os.environ.update(original) | ||
|
||
|
||
def uv_install(venv: Path) -> None: | ||
"""Install dependencies using uv.""" | ||
with environ(UV_PROJECT_ENVIRONMENT=str(venv), PYO3_USE_ABI3_FORWARD_COMPATIBILITY="1"): | ||
if "CI" in os.environ: | ||
shell("uv sync --no-editable") | ||
else: | ||
shell("uv sync") | ||
|
||
|
||
def setup() -> None: | ||
"""Setup the project.""" | ||
if not shutil.which("uv"): | ||
raise ValueError("make: setup: uv must be installed, see https://github.com/astral-sh/uv") | ||
|
||
print("Installing dependencies (default environment)") | ||
default_venv = Path(".venv") | ||
if not default_venv.exists(): | ||
shell("uv venv") | ||
uv_install(default_venv) | ||
|
||
if PYTHON_VERSIONS: | ||
for version in PYTHON_VERSIONS: | ||
print(f"\nInstalling dependencies (python{version})") | ||
venv_path = Path(f".venvs/{version}") | ||
if not venv_path.exists(): | ||
shell(f"uv venv --python {version} {venv_path}") | ||
with environ(UV_PROJECT_ENVIRONMENT=str(venv_path.resolve())): | ||
uv_install(venv_path) | ||
|
||
|
||
def run(version: str, cmd: str, *args: str, no_sync: bool = False, **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") | ||
if version == "default": | ||
with environ(UV_PROJECT_ENVIRONMENT=".venv"): | ||
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510 | ||
else: | ||
with environ(UV_PROJECT_ENVIRONMENT=f".venvs/{version}", MULTIRUN="1"): | ||
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510 | ||
|
||
|
||
def multirun(cmd: str, *args: str, **kwargs: Any) -> None: | ||
"""Run a command for all configured Python versions.""" | ||
if PYTHON_VERSIONS: | ||
for version in PYTHON_VERSIONS: | ||
run(version, cmd, *args, **kwargs) | ||
else: | ||
run("default", cmd, *args, **kwargs) | ||
|
||
|
||
def allrun(cmd: str, *args: str, **kwargs: Any) -> None: | ||
"""Run a command in all virtual environments.""" | ||
run("default", cmd, *args, **kwargs) | ||
if PYTHON_VERSIONS: | ||
multirun(cmd, *args, **kwargs) | ||
|
||
|
||
def clean() -> None: | ||
"""Delete build artifacts and cache files.""" | ||
paths_to_clean = ["build", "dist", "htmlcov", "site", ".coverage*", ".pdm-build"] | ||
for path in paths_to_clean: | ||
shutil.rmtree(path, ignore_errors=True) | ||
|
||
cache_dirs = {".cache", ".pytest_cache", ".mypy_cache", ".ruff_cache", "__pycache__"} | ||
for dirpath in Path(".").rglob("*/"): | ||
if dirpath.parts[0] not in (".venv", ".venvs") and dirpath.name in cache_dirs: | ||
shutil.rmtree(dirpath, ignore_errors=True) | ||
|
||
|
||
def vscode() -> None: | ||
"""Configure VSCode to work on this project.""" | ||
shutil.copytree("config/vscode", ".vscode", dirs_exist_ok=True) | ||
|
||
|
||
def main() -> int: | ||
"""Main entry point.""" | ||
args = list(sys.argv[1:]) | ||
if not args or args[0] == "help": | ||
if len(args) > 1: | ||
run("default", "duty", "--help", args[1]) | ||
else: | ||
print( | ||
dedent( | ||
""" | ||
Available commands | ||
help Print this help. Add task name to print help. | ||
setup Setup all virtual environments (install dependencies). | ||
run Run a command in the default virtual environment. | ||
multirun Run a command for all configured Python versions. | ||
allrun Run a command in all virtual environments. | ||
3.x Run a command in the virtual environment for Python 3.x. | ||
clean Delete build artifacts and cache files. | ||
vscode Configure VSCode to work on this project. | ||
""", | ||
), | ||
flush=True, | ||
) | ||
if os.path.exists(".venv"): | ||
print("\nAvailable tasks", flush=True) | ||
run("default", "duty", "--list", no_sync=True) | ||
return 0 | ||
|
||
while args: | ||
cmd = args.pop(0) | ||
|
||
if cmd == "run": | ||
run("default", *args) | ||
return 0 | ||
|
||
if cmd == "multirun": | ||
multirun(*args) | ||
return 0 | ||
|
||
if cmd == "allrun": | ||
allrun(*args) | ||
return 0 | ||
|
||
if cmd.startswith("3."): | ||
run(cmd, *args) | ||
return 0 | ||
|
||
opts = [] | ||
while args and (args[0].startswith("-") or "=" in args[0]): | ||
opts.append(args.pop(0)) | ||
|
||
if cmd == "clean": | ||
clean() | ||
elif cmd == "setup": | ||
setup() | ||
elif cmd == "vscode": | ||
vscode() | ||
elif cmd == "check": | ||
multirun("duty", "check-quality", "check-types", "check-docs") | ||
run("default", "duty", "check-api") | ||
elif cmd in {"check-quality", "check-docs", "check-types", "test"}: | ||
multirun("duty", cmd, *opts) | ||
else: | ||
run("default", "duty", cmd, *opts) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
sys.exit(main()) | ||
except subprocess.CalledProcessError as process: | ||
if process.output: | ||
print(process.output, file=sys.stderr) | ||
sys.exit(process.returncode) |