Skip to content

Commit

Permalink
chore: Template upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Oct 17, 2024
1 parent 8fc381f commit 329b3ff
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 157 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.4.0
_commit: 1.5.1
_src_path: gh:pawamoy/copier-uv
author_email: dev@pawamoy.fr
author_fullname: Timothée Mazzucotelli
Expand Down
34 changes: 22 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Fetch all tags
run: git fetch --depth=1 --tags

- name: Set up Python
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install uv
run: pip install uv
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml

- name: Install dependencies
run: make setup
Expand All @@ -61,12 +64,12 @@ jobs:
- macos-latest
- windows-latest
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
resolution:
- highest
- lowest-direct
Expand All @@ -76,20 +79,27 @@ jobs:
- os: windows-latest
resolution: lowest-direct
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.python-version == '3.13' }}
continue-on-error: ${{ matrix.python-version == '3.14' }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Set up Python
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install uv
run: pip install uv
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
cache-suffix: py${{ matrix.python-version }}

- name: Install dependencies
env:
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch all tags
run: git fetch --depth=1 --tags
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Python
uses: actions/setup-python@v4
- name: Install git-changelog
run: pip install git-changelog
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Setup uv
uses: astral-sh/setup-uv@v3
- name: Prepare release notes
run: git-changelog --release-notes > release-notes.md
run: uv tool run git-changelog --release-notes > release-notes.md
- name: Create release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
body_path: release-notes.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/.pdm-build/
/htmlcov/
/site/
uv.lock

# cache
.cache/
Expand Down
6 changes: 0 additions & 6 deletions .gitpod.dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions .gitpod.yml

This file was deleted.

5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ make setup
> You can install it with:
>
> ```bash
> python3 -m pip install --user pipx
> pipx install uv
> curl -LsSf https://astral.sh/uv/install.sh | sh
> ```
>
> Now you can try running `make setup` again,
> or simply `uv install`.
> or simply `uv sync`.
You now have the dependencies installed.
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ Inspired by [Invoke](https://github.com/pyinvoke/invoke).

## Installation

With `pip`:

```bash
pip install duty
```

With [`pipx`](https://github.com/pipxproject/pipx):
With [`uv`](https://docs.astral.sh/uv/):

```bash
python3.8 -m pip install --user pipx
pipx install duty
uv tool install duty
```

## Quick start
Expand Down
2 changes: 1 addition & 1 deletion config/ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
target-version = "py38"
target-version = "py39"
line-length = 120

[lint]
Expand Down
32 changes: 0 additions & 32 deletions devdeps.txt

This file was deleted.

14 changes: 10 additions & 4 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from contextlib import contextmanager
from importlib.metadata import version as pkgversion
from pathlib import Path
from typing import TYPE_CHECKING, Iterator
from typing import TYPE_CHECKING

from duty import duty, tools

if TYPE_CHECKING:
from collections.abc import Iterator

from duty.context import Context


Expand Down Expand Up @@ -53,7 +55,7 @@ def changelog(ctx: Context, bump: str = "") -> None:
ctx.run(tools.git_changelog(bump=bump or None), title="Updating changelog")


@duty(pre=["check_quality", "check_types", "check_docs", "check-api"])
@duty(pre=["check-quality", "check-types", "check-docs", "check-api"])
def check(ctx: Context) -> None:
"""Check it all!"""

Expand Down Expand Up @@ -115,8 +117,12 @@ def docs(ctx: Context, *cli_args: str, host: str = "127.0.0.1", port: int = 8000


@duty
def docs_deploy(ctx: Context) -> None:
"""Deploy the documentation to GitHub pages."""
def docs_deploy(ctx: Context, *, force: bool = False) -> None:
"""Deploy the documentation to GitHub pages.
Parameters:
force: Whether to force deployment, even from non-Insiders version.
"""
os.environ["DEPLOY"] = "true"
with material_insiders() as insiders:
if not insiders:
Expand Down
6 changes: 4 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ plugins:
show_root_heading: true
show_root_full_path: false
show_signature_annotations: true
show_source: true
show_symbol_type_heading: true
show_symbol_type_toc: true
signature_crossrefs: true
summary: true
- git-committers:
- git-revision-date-localized:
enabled: !ENV [DEPLOY, false]
repository: pawamoy/duty
enable_creation_date: true
type: timeago
- minify:
minify_html: !ENV [DEPLOY, false]
- group:
Expand Down
42 changes: 39 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "A simple task runner."
authors = [{name = "Timothée Mazzucotelli", email = "dev@pawamoy.fr"}]
license = {text = "ISC"}
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
keywords = ["task-runner", "task", "runner", "cross-platform"]
dynamic = ["version"]
classifiers = [
Expand All @@ -17,12 +17,12 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Documentation",
"Topic :: Software Development",
"Topic :: Utilities",
Expand Down Expand Up @@ -60,7 +60,6 @@ source-includes = [
"scripts",
"share",
"tests",
"devdeps.txt",
"duties.py",
"mkdocs.yml",
"*.md",
Expand All @@ -71,3 +70,40 @@ source-includes = [
data = [
{path = "share/**/*", relative-to = "."},
]

[tool.uv]
dev-dependencies = [
# dev
"editables>=0.5",

# maintenance
"build>=1.2",
"git-changelog>=2.5",
"twine>=5.1",

# ci
"duty>=1.4",
"ruff>=0.4",
"pytest>=8.2",
"pytest-cov>=5.0",
"pytest-randomly>=3.15",
"pytest-xdist>=3.6",
"mypy>=1.10",
"types-markdown>=3.6",
"types-pyyaml>=6.0",

# docs
"black>=24.4",
"markdown-callouts>=0.4",
"markdown-exec>=1.8",
"mkdocs>=1.6",
"mkdocs-coverage>=1.0",
"mkdocs-gen-files>=0.5",
"mkdocs-git-revision-date-localized-plugin>=1.2",
"mkdocs-literate-nav>=0.6",
"mkdocs-material>=9.5",
"mkdocs-minify-plugin>=0.8",
"mkdocstrings[python]>=0.25",
# YORE: EOL 3.10: Remove line.
"tomli>=2.0; python_version < '3.11'",
]
12 changes: 6 additions & 6 deletions scripts/gen_credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
import os
import sys
from collections import defaultdict
from collections.abc import Iterable
from importlib.metadata import distributions
from itertools import chain
from pathlib import Path
from textwrap import dedent
from typing import Dict, Iterable, Union
from typing import Union

from jinja2 import StrictUndefined
from jinja2.sandbox import SandboxedEnvironment
from packaging.requirements import Requirement

# TODO: Remove once support for Python 3.10 is dropped.
# YORE: EOL 3.10: Replace block with line 2.
if sys.version_info >= (3, 11):
import tomllib
else:
Expand All @@ -26,11 +27,10 @@
pyproject = tomllib.load(pyproject_file)
project = pyproject["project"]
project_name = project["name"]
with project_dir.joinpath("devdeps.txt").open() as devdeps_file:
devdeps = [line.strip() for line in devdeps_file if line.strip() and not line.strip().startswith(("-e", "#"))]
devdeps = [dep for dep in pyproject["tool"]["uv"]["dev-dependencies"] if not dep.startswith("-e")]

PackageMetadata = Dict[str, Union[str, Iterable[str]]]
Metadata = Dict[str, PackageMetadata]
PackageMetadata = dict[str, Union[str, Iterable[str]]]
Metadata = dict[str, PackageMetadata]


def _merge_fields(metadata: dict) -> PackageMetadata:
Expand Down
Loading

0 comments on commit 329b3ff

Please sign in to comment.