Skip to content

Commit c79e769

Browse files
committed
MAINT: Fully embrace uv locally and on CI
1 parent 16b8e0e commit c79e769

File tree

4 files changed

+66
-48
lines changed

4 files changed

+66
-48
lines changed

.github/workflows/testing.yml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,10 @@ jobs:
2929
- name: Checkout Code
3030
uses: actions/checkout@v4
3131

32-
- name: Setup Python
33-
uses: actions/setup-python@v5
34-
with:
35-
python-version: ${{ matrix.python-version }}
36-
3732
- name: Install a specific version of uv
38-
uses: astral-sh/setup-uv@v3
33+
uses: astral-sh/setup-uv@v6
3934
with:
40-
version: "latest"
41-
42-
- name: Make uv use system python
43-
run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV
35+
python-version: ${{ matrix.python-version }}
4436

4537
- name: Install Packages
4638
# Install as an editable so that the coverage path is predicable
@@ -81,12 +73,9 @@ jobs:
8173
python-version: ${{ matrix.python-version }}
8274

8375
- name: Install a specific version of uv
84-
uses: astral-sh/setup-uv@v3
76+
uses: astral-sh/setup-uv@v6
8577
with:
86-
version: "latest"
87-
88-
- name: Make uv use system python
89-
run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV
78+
python-version: ${{ matrix.python-version }}
9079

9180
- name: Install Linting & Formatting Packages
9281
run: uv pip install ruff
@@ -121,12 +110,9 @@ jobs:
121110
python-version: ${{ matrix.python-version }}
122111

123112
- name: Install a specific version of uv
124-
uses: astral-sh/setup-uv@v3
113+
uses: astral-sh/setup-uv@v6
125114
with:
126-
version: "latest"
127-
128-
- name: Make uv use system python
129-
run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV
115+
python-version: ${{ matrix.python-version }}
130116

131117
- name: Install Packages
132118
run: uv pip install ".[extra, typing]"
@@ -158,12 +144,9 @@ jobs:
158144
python-version: ${{ matrix.python-version }}
159145

160146
- name: Install a specific version of uv
161-
uses: astral-sh/setup-uv@v3
147+
uses: astral-sh/setup-uv@v6
162148
with:
163-
version: "latest"
164-
165-
- name: Make uv use system python
166-
run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV
149+
python-version: ${{ matrix.python-version }}
167150

168151
- name: Install Packages
169152
run: uv pip install -e ".[doc]"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ doc/generated/
5959
# PyBuilder
6060
target/
6161

62+
# local dev things
63+
.local/
64+
6265
.DS_Store

Makefile

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
.PHONY: clean-pyc clean-build doc clean build
2-
BROWSER := python -mwebbrowser
2+
3+
# NOTE: Take care not to use tabs in any programming flow outside the
4+
# make target
5+
6+
# Use uv (if it is installed) to run all python related commands,
7+
# and prefere the active environment over .venv in a parent folder
8+
ifeq ($(OS),Windows_NT)
9+
HAS_UV := $(if $(shell where uv 2>NUL),true,false)
10+
else
11+
HAS_UV := $(if $(shell command -v uv 2>/dev/null),true,false)
12+
endif
13+
14+
ifeq ($(HAS_UV),true)
15+
PYTHON ?= uv run --active python
16+
PIP ?= uv pip
17+
UVRUN ?= uv run --active
18+
else
19+
PYTHON ?= python
20+
PIP ?= pip
21+
UVRUN ?=
22+
endif
23+
24+
BROWSER := $(PYTHON) -mwebbrowser
25+
26+
all:
27+
@echo "Using Python: $(PYTHON)"
328

429
help:
530
@echo "clean - remove all build, test, coverage and Python artifacts"
@@ -14,17 +39,18 @@ help:
1439
@echo "dist - package"
1540
@echo "install - install the package to the active Python's site-packages"
1641

17-
clean: clean-build clean-pyc clean-test
42+
clean: clean-build clean-cache clean-test
1843

1944
clean-build:
2045
rm -fr build/
2146
rm -fr dist/
2247
find . -name '*.egg-info' -exec rm -fr {} +
2348

24-
clean-pyc:
49+
clean-cache:
2550
find . -name '__pycache__' -exec rm -fr {} +
2651

2752
clean-test:
53+
$(UVRUN) coverage erase
2854
rm -f .coverage
2955
rm -f coverage.xml
3056
rm -fr htmlcov/
@@ -33,55 +59,61 @@ ruff:
3359
ruff check . $(args)
3460

3561
format:
36-
ruff format . --check
62+
$(UVRUN) ruff format --check .
3763

3864
format-fix:
39-
ruff format .
65+
$(UVRUN) ruff format .
4066

41-
lint: ruff
67+
lint:
68+
$(UVRUN) ruff check .
4269

4370
lint-fix:
44-
make lint args="--fix"
71+
$(UVRUN) ruff check --fix .
4572

4673
fix: format-fix lint-fix
4774

4875
typecheck:
49-
pyright
76+
$(UVRUN) pyright
5077

5178
test: clean-test
52-
pytest --runslow
79+
$(UVRUN) pytest --runslow
5380

5481
test-fast: clean-test
55-
pytest
82+
$(UVRUN) pytest
5683

5784
coverage:
58-
coverage report -m
59-
coverage html
85+
$(UVRUN) coverage report -m
86+
$(UVRUN) coverage html
6087
$(BROWSER) htmlcov/index.html
6188

89+
6290
doc:
6391
$(MAKE) -C doc clean
6492
$(MAKE) -C doc html
6593
$(BROWSER) doc/_build/html/index.html
6694

6795
release-major:
68-
@python ./tools/release-checklist.py major
96+
@$(PYTHON) ./tools/release-checklist.py major
6997

7098
release-minor:
71-
@python ./tools/release-checklist.py minor
99+
@$(PYTHON) ./tools/release-checklist.py minor
72100

73101
release-patch:
74-
@python ./tools/release-checklist.py patch
75-
76-
build: clean
77-
python -m build
102+
@$(PYTHON) ./tools/release-checklist.py patch
78103

79-
dist: build
104+
dist: clean-build
105+
$(PYTHON) -m build
80106
ls -l dist
81107

82-
develop: clean-pyc
83-
uv pip install -e ".[all]"
108+
build: dist
84109

85110
install: clean
86111
ls -l dist
87-
uv pip install .
112+
$(PIP) install .
113+
114+
develop: clean-cache
115+
$(PIP) install -e ".[all]"
116+
117+
develop-update: clean-cache
118+
$(PIP) install --upgrade -e ".[all]"
119+
$(UVRUN) pre-commit autoupdate

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line.
55
SPHINXOPTS =
6-
SPHINXBUILD = sphinx-build
6+
SPHINXBUILD = uv run sphinx-build
77
SPHINXPROJ = mizani
88
SOURCEDIR = .
99
PAPER =

0 commit comments

Comments
 (0)