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 13, 2024
1 parent 1a6955f commit f071d5d
Show file tree
Hide file tree
Showing 23 changed files with 447 additions and 321 deletions.
4 changes: 2 additions & 2 deletions .copier-answers.yml
@@ -1,6 +1,6 @@
# Changes here will be overwritten by Copier
_commit: 1.2.6
_src_path: gh:pawamoy/copier-pdm.git
_commit: 1.0.8
_src_path: gh:pawamoy/copier-uv
author_email: dev@pawamoy.fr
author_fullname: Timothée Mazzucotelli
author_username: pawamoy
Expand Down
1 change: 1 addition & 0 deletions .envrc
@@ -0,0 +1 @@
PATH_add scripts
41 changes: 22 additions & 19 deletions .github/workflows/ci.yml
Expand Up @@ -15,6 +15,7 @@ env:
LC_ALL: en_US.utf-8
PYTHONIOENCODING: UTF-8
PYTHONPATH: docs
PYTHON_VERSIONS: ""

jobs:

Expand All @@ -29,31 +30,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 @@ -79,7 +80,6 @@ jobs:

needs: exclude-test-jobs
strategy:
max-parallel: 4
matrix:
os:
- ubuntu-latest
Expand All @@ -99,17 +99,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- 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 "mkdocstrings @ ."
- name: Run the test suite
run: pdm run duty test
run: make test
10 changes: 3 additions & 7 deletions .gitignore
Expand Up @@ -9,13 +9,9 @@ htmlcov/
.coverage*
pip-wheel-metadata/
.pytest_cache/
.python-version
site/
pdm.lock
pdm.toml
.pdm-plugins/
.pdm-python
__pypackages__/
.mypy_cache/
.ruff_cache/
site/
.venv/
.venvs/
.cache/
2 changes: 1 addition & 1 deletion .gitpod.dockerfile
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
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Expand Up @@ -17,18 +17,18 @@ 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.

Expand All @@ -39,13 +39,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
57 changes: 15 additions & 42 deletions Makefile
@@ -1,54 +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

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

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

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

.PHONY: lock
lock:
@pdm lock --dev

.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
Expand Up @@ -8,7 +8,8 @@ source =
[coverage:paths]
equivalent =
src/
__pypackages__/
.venv/lib/*/site-packages/
.venvs/*/lib/*/site-packages/

[coverage:report]
ignore_errors = True
Expand Down
6 changes: 0 additions & 6 deletions config/pytest.ini
@@ -1,10 +1,4 @@
[pytest]
norecursedirs =
.git
.tox
.env
dist
build
python_files =
test_*.py
*_test.py
Expand Down
67 changes: 22 additions & 45 deletions config/ruff.toml
@@ -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 All @@ -91,18 +65,21 @@ 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 = ["mkdocstrings"]

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

[format]
docstring-code-format = true
docstring-code-line-length = 80
exclude = [
"tests/fixtures/*.py",
]
11 changes: 11 additions & 0 deletions config/vscode/launch.json
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

0 comments on commit f071d5d

Please sign in to comment.