Skip to content

Commit

Permalink
chore: Switch to Copier UV template
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Mar 19, 2024
1 parent e1216aa commit c29585a
Show file tree
Hide file tree
Showing 23 changed files with 446 additions and 320 deletions.
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changes here will be overwritten by Copier
_commit: 1.2.6
_src_path: gh:pawamoy/copier-pdm
_commit: 1.0.8
_src_path: gh:pawamoy/copier-uv
author_email: [email protected]
author_fullname: Timothée Mazzucotelli
author_username: pawamoy
Expand Down
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PATH_add scripts
41 changes: 22 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
LANG: en_US.utf-8
LC_ALL: en_US.utf-8
PYTHONIOENCODING: UTF-8
PYTHON_VERSIONS: ""

jobs:

Expand All @@ -28,31 +29,31 @@ jobs:
- name: Fetch all tags
run: git fetch --depth=1 --tags

- name: Set up PDM
uses: pdm-project/setup-pdm@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.11"

- name: Resolving dependencies
run: pdm lock -v --no-cross-platform -G ci-quality
- name: Install uv
run: pip install uv

- name: Install dependencies
run: pdm install -G ci-quality
run: make setup

- name: Check if the documentation builds correctly
run: pdm run duty check-docs
run: make check-docs

- name: Check the code quality
run: pdm run duty check-quality
run: make check-quality

- name: Check if the code is correctly typed
run: pdm run duty check-types
run: make check-types

- name: Check for vulnerabilities in dependencies
run: pdm run duty check-dependencies
run: make check-dependencies

- name: Check for breaking changes in the API
run: pdm run duty check-api
run: make check-api

exclude-test-jobs:
runs-on: ubuntu-latest
Expand All @@ -78,7 +79,6 @@ jobs:

needs: exclude-test-jobs
strategy:
max-parallel: 4
matrix:
os:
- ubuntu-latest
Expand All @@ -101,17 +101,20 @@ jobs:
- name: Fetch all tags
run: git fetch --depth=1 --tags

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

- name: Resolving dependencies
run: pdm lock -v --no-cross-platform -G ci-tests
- name: Install uv
run: pip install uv

- name: Install dependencies
run: pdm install --no-editable -G ci-tests
run: |
uv venv
uv pip install -r devdeps.txt
uv pip install "griffe @ ."
- name: Run the test suite
run: pdm run duty test
run: make test
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ htmlcov/
pip-wheel-metadata/
.pytest_cache/
.mypy_cache/
.ruff_cache/
site/
pdm.lock
pdm.toml
.pdm-plugins/
.pdm-python
__pypackages__/
.venv/
.venvs/
.cache/
profile.pstats
profile.svg
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ FROM gitpod/workspace-full
USER gitpod
ENV PIP_USER=no
RUN pip3 install pipx; \
pipx install pdm; \
pipx install uv; \
pipx ensurepath
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ make setup
> NOTE:
> If it fails for some reason,
> you'll need to install
> [PDM](https://github.com/pdm-project/pdm)
> [uv](https://github.com/astral-sh/uv)
> manually.
>
> You can install it with:
>
> ```bash
> python3 -m pip install --user pipx
> pipx install pdm
> pipx install uv
> ```
>
> Now you can try running `make setup` again,
> or simply `pdm install`.
> or simply `uv install`.
You now have the dependencies installed.
You can run the application with `pdm run griffe [ARGS...]`.
You can run the application with `make run griffe [ARGS...]`.
Run `make help` to see all the available actions!
Expand All @@ -41,13 +41,13 @@ Run `make help` to see all the available actions!
This project uses [duty](https://github.com/pawamoy/duty) to run tasks.
A Makefile is also provided. The Makefile will try to run certain tasks
on multiple Python versions. If for some reason you don't want to run the task
on multiple Python versions, you run the task directly with `pdm run duty TASK`.
on multiple Python versions, you run the task directly with `make run duty TASK`.
The Makefile detects if a virtual environment is activated,
so `make` will work the same with the virtualenv activated or not.
If you work in VSCode, we provide
[an action to configure VSCode](https://pawamoy.github.io/copier-pdm/work/#vscode-setup)
[an action to configure VSCode](https://pawamoy.github.io/copier-uv/work/#vscode-setup)
for the project.
## Development
Expand Down
59 changes: 15 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,27 @@
.DEFAULT_GOAL := help
SHELL := bash
DUTY := $(if $(VIRTUAL_ENV),,pdm run) duty
export PDM_MULTIRUN_VERSIONS ?= 3.8 3.9 3.10 3.11 3.12
export PDM_MULTIRUN_USE_VENVS ?= $(if $(shell pdm config python.use_venv | grep True),1,0)
# If you have `direnv` loaded in your shell, and allow it in the repository,
# the `make` command will point at the `scripts/make` shell script.
# This Makefile is just here to allow auto-completion in the terminal.

args = $(foreach a,$($(subst -,_,$1)_args),$(if $(value $a),$a="$($a)"))
check_quality_args = files
docs_args = host port
release_args = version
test_args = match
fuzz_args = seeds min_seed max_seed size

BASIC_DUTIES = \
actions = \
changelog \
check \
check-api \
check-dependencies \
check-docs \
check-quality \
check-types \
clean \
coverage \
docs \
docs-deploy \
format \
help \
release \
fuzz \
run \
setup \
test \
vscode

QUALITY_DUTIES = \
check-quality \
check-docs \
check-types \
test

.PHONY: help
help:
@$(DUTY) --list

.PHONY: lock
lock:
@pdm lock -G:all

.PHONY: setup
setup:
@bash scripts/setup.sh

.PHONY: check
check:
@pdm multirun duty check-quality check-types check-docs
@$(DUTY) check-dependencies check-api

.PHONY: $(BASIC_DUTIES)
$(BASIC_DUTIES):
@$(DUTY) $@ $(call args,$@)

.PHONY: $(QUALITY_DUTIES)
$(QUALITY_DUTIES):
@pdm multirun duty $@ $(call args,$@)
.PHONY: $(actions)
$(actions):
@bash scripts/make "$@"
3 changes: 0 additions & 3 deletions config/black.toml

This file was deleted.

3 changes: 2 additions & 1 deletion config/coverage.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ source =
[coverage:paths]
equivalent =
src/
__pypackages__/
.venv/lib/*/site-packages/
.venvs/*/lib/*/site-packages/

[coverage:report]
precision = 2
Expand Down
6 changes: 0 additions & 6 deletions config/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
[pytest]
norecursedirs =
.git
.tox
.env
dist
build
python_files =
test_*.py
*_test.py
Expand Down
64 changes: 19 additions & 45 deletions config/ruff.toml
Original file line number Diff line number Diff line change
@@ -1,53 +1,27 @@
target-version = "py38"
line-length = 120

[lint]
exclude = [
"fixtures",
"tests/fixtures/*.py",
"site",
]
select = [
"A",
"ANN",
"ARG",
"B",
"BLE",
"C",
"C4",
"A", "ANN", "ARG",
"B", "BLE",
"C", "C4",
"COM",
"D",
"DTZ",
"E",
"ERA",
"EXE",
"F",
"FBT",
"D", "DTZ",
"E", "ERA", "EXE",
"F", "FBT",
"G",
"I",
"ICN",
"INP",
"ISC",
"I", "ICN", "INP", "ISC",
"N",
"PGH",
"PIE",
"PL",
"PLC",
"PLE",
"PLR",
"PLW",
"PT",
"PYI",
"PGH", "PIE", "PL", "PLC", "PLE", "PLR", "PLW", "PT", "PYI",
"Q",
"RUF",
"RSE",
"RET",
"S",
"SIM",
"SLF",
"T",
"T10",
"T20",
"TCH",
"TID",
"TRY",
"RUF", "RSE", "RET",
"S", "SIM", "SLF",
"T", "T10", "T20", "TCH", "TID", "TRY",
"UP",
"W",
"YTT",
Expand All @@ -73,7 +47,7 @@ ignore = [
"TRY003", # Avoid specifying long messages outside the exception class
]

[per-file-ignores]
[lint.per-file-ignores]
"src/*/cli.py" = [
"T201", # Print statement
]
Expand Down Expand Up @@ -104,16 +78,16 @@ ignore = [
"S101", # Use of assert detected
]

[flake8-quotes]
[lint.flake8-quotes]
docstring-quotes = "double"

[flake8-tidy-imports]
[lint.flake8-tidy-imports]
ban-relative-imports = "all"

[isort]
[lint.isort]
known-first-party = ["griffe"]

[pydocstyle]
[lint.pydocstyle]
convention = "google"

[format]
Expand Down
11 changes: 11 additions & 0 deletions config/vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "docs",
"type": "debugpy",
"request": "launch",
"module": "mkdocs",
"justMyCode": false,
"args": [
"serve",
"-v"
]
},
{
"name": "test",
"type": "debugpy",
Expand Down
Loading

0 comments on commit c29585a

Please sign in to comment.