Skip to content

Commit

Permalink
chore: Template upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Mar 23, 2024
1 parent 56cf7d5 commit ccbbbf1
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 1.0.8
_commit: 1.1.0
_src_path: gh:pawamoy/copier-uv
author_email: dev@pawamoy.fr
author_fullname: Timothée Mazzucotelli
Expand Down
1 change: 1 addition & 0 deletions .github/FUNDING.yml
@@ -1,4 +1,5 @@
github: pawamoy
ko_fi: pawamoy
polar: pawamoy
custom:
- https://www.paypal.me/pawamoy
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Expand Up @@ -109,10 +109,7 @@ jobs:
run: pip install uv

- name: Install dependencies
run: |
uv venv
uv pip install -r devdeps.txt
uv pip install "mkdocstrings @ ."
run: make setup

- name: Run the test suite
run: make test
27 changes: 17 additions & 10 deletions .gitignore
@@ -1,17 +1,24 @@
# editors
.idea/
.vscode/
__pycache__/
*.py[cod]
dist/

# python
*.egg-info/
build/
htmlcov/
*.py[cod]
.venv/
.venvs/
/build/
/dist/

# tools
.coverage*
pip-wheel-metadata/
/.pdm-build/
/htmlcov/
/site/

# cache
.cache/
.pytest_cache/
.mypy_cache/
.ruff_cache/
site/
.venv/
.venvs/
.cache/
__pycache__/
7 changes: 3 additions & 4 deletions config/ruff.toml
Expand Up @@ -4,7 +4,6 @@ line-length = 120
[lint]
exclude = [
"tests/fixtures/*.py",
"site",
]
select = [
"A", "ANN", "ARG",
Expand Down Expand Up @@ -78,8 +77,8 @@ known-first-party = ["mkdocstrings"]
convention = "google"

[format]
docstring-code-format = true
docstring-code-line-length = 80
exclude = [
"tests/fixtures/*.py",
]
]
docstring-code-format = true
docstring-code-line-length = 80
22 changes: 11 additions & 11 deletions duties.py
Expand Up @@ -157,17 +157,17 @@ def clean(ctx: Context) -> None:
Parameters:
ctx: The context instance (passed automatically).
"""
ctx.run("rm -rf .coverage*")
ctx.run("rm -rf .mypy_cache")
ctx.run("rm -rf .pytest_cache")
ctx.run("rm -rf tests/.pytest_cache")
ctx.run("rm -rf build")
ctx.run("rm -rf dist")
ctx.run("rm -rf htmlcov")
ctx.run("rm -rf pip-wheel-metadata")
ctx.run("rm -rf site")
ctx.run("find . -type d -name __pycache__ | xargs rm -rf")
ctx.run("find . -name '*.rej' -delete")

def _rm(*targets: str) -> None:
for target in targets:
ctx.run(f"rm -rf {target}")

def _find_rm(*targets: str) -> None:
for target in targets:
ctx.run(f"find . -type d -name '{target}' | xargs rm -rf")

_rm("build", "dist", ".coverage*", "htmlcov", "site", ".pdm-build")
_find_rm(".cache", ".pytest_cache", ".mypy_cache", ".ruff_cache", "__pycache__")


@duty
Expand Down
18 changes: 6 additions & 12 deletions scripts/gen_credits.py
Expand Up @@ -26,7 +26,7 @@
pyproject = tomllib.load(pyproject_file)
project = pyproject["project"]
project_name = project["name"]
with open("devdeps.txt") as devdeps_file:
with project_dir.joinpath("devdeps.txt").open() as devdeps_file:
devdeps = [line.strip() for line in devdeps_file if not line.startswith("-e")]

PackageMetadata = Dict[str, Union[str, Iterable[str]]]
Expand All @@ -47,13 +47,6 @@ def _norm_name(name: str) -> str:
return name.replace("_", "-").replace(".", "-").lower()


def _norm_spec(spec: str) -> set[str]:
clean_spec = spec.split("]", 1)[-1].split(";", 1)[0].replace("(", "").replace(")", "").replace(" ", "").strip()
if clean_spec:
return set(clean_spec.split(","))
return set()


def _requirements(deps: list[str]) -> dict[str, Requirement]:
return {_norm_name((req := Requirement(dep)).name): req for dep in deps}

Expand All @@ -74,6 +67,7 @@ def _get_metadata() -> Metadata:
metadata[name] = _merge_fields(pkg.metadata) # type: ignore[arg-type]
metadata[name]["spec"] = set()
metadata[name]["extras"] = set()
metadata[name].setdefault("summary", "")
_set_license(metadata[name])
return metadata

Expand Down Expand Up @@ -147,12 +141,12 @@ def _render_credits() -> str:
These projects were used to build *{{ project_name }}*. **Thank you!**
[`python`](https://www.python.org/) |
[`uv`](https://github.com/astral-sh/uv) |
[`copier-uv`](https://github.com/pawamoy/copier-uv)
[Python](https://www.python.org/) |
[uv](https://github.com/astral-sh/uv) |
[copier-uv](https://github.com/pawamoy/copier-uv)
{% macro dep_line(dep) -%}
[`{{ dep.name }}`](https://pypi.org/project/{{ dep.name }}/) | {{ dep.summary }} | {{ ("`" ~ dep.spec|sort(reverse=True)|join(", ") ~ "`") if dep.spec else "" }} | `{{ dep.version }}` | {{ dep.license }}
[{{ dep.name }}](https://pypi.org/project/{{ dep.name }}/) | {{ dep.summary }} | {{ ("`" ~ dep.spec|sort(reverse=True)|join(", ") ~ "`") if dep.spec else "" }} | `{{ dep.version }}` | {{ dep.license }}
{%- endmacro %}
{% if prod_dependencies -%}
Expand Down
10 changes: 7 additions & 3 deletions scripts/make
Expand Up @@ -11,7 +11,11 @@ prefix=""
# as well as current project in editable mode.
uv_install() {
uv pip compile pyproject.toml devdeps.txt | uv pip install -r -
uv pip install -e .
if [ -z "${CI}" ]; then
uv pip install -e .
else
uv pip install "mkdocstrings @ ."
fi
}


Expand All @@ -28,13 +32,13 @@ setup() {
if [ -n "${PYTHON_VERSIONS}" ]; then
for version in ${PYTHON_VERSIONS}; do
if [ ! -d ".venvs/${version}" ]; then
uv venv --seed --python "${version}" ".venvs/${version}"
uv venv --python "${version}" ".venvs/${version}"
fi
VIRTUAL_ENV="${PWD}/.venvs/${version}" uv_install
done
fi

if [ ! -d .venv ]; then uv venv --seed --python python; fi
if [ ! -d .venv ]; then uv venv --python python; fi
uv_install
}

Expand Down
5 changes: 4 additions & 1 deletion src/mkdocstrings/debug.py
Expand Up @@ -37,6 +37,8 @@ class Environment:
"""Python interpreter name."""
interpreter_version: str
"""Python interpreter version."""
interpreter_path: str
"""Path to Python executable."""
platform: str
"""Operating System."""
packages: list[Package]
Expand Down Expand Up @@ -83,6 +85,7 @@ def get_debug_info() -> Environment:
return Environment(
interpreter_name=py_name,
interpreter_version=py_version,
interpreter_path=sys.executable,
platform=platform.platform(),
variables=[Variable(var, val) for var in variables if (val := os.getenv(var))],
packages=[Package(pkg, get_version(pkg)) for pkg in packages],
Expand All @@ -93,7 +96,7 @@ def print_debug_info() -> None:
"""Print debug/environment information."""
info = get_debug_info()
print(f"- __System__: {info.platform}")
print(f"- __Python__: {info.interpreter_name} {info.interpreter_version}")
print(f"- __Python__: {info.interpreter_name} {info.interpreter_version} ({info.interpreter_path})")
print("- __Environment variables__:")
for var in info.variables:
print(f" - `{var.name}`: `{var.value}`")
Expand Down
2 changes: 1 addition & 1 deletion src/mkdocstrings/loggers.py
Expand Up @@ -17,7 +17,7 @@
except ImportError:
TEMPLATES_DIRS: Sequence[Path] = ()
else:
TEMPLATES_DIRS = tuple(mkdocstrings_handlers.__path__) # type: ignore[arg-type]
TEMPLATES_DIRS = tuple(mkdocstrings_handlers.__path__)


if TYPE_CHECKING:
Expand Down

0 comments on commit ccbbbf1

Please sign in to comment.