Skip to content

Commit e02a2a7

Browse files
committed
(wip)
1 parent 0ce1262 commit e02a2a7

File tree

5 files changed

+41
-46
lines changed

5 files changed

+41
-46
lines changed

.github/workflows/check.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ jobs:
137137
with:
138138
add-problem-matchers: 'false'
139139
- name: Install remaining dependencies
140-
run: make venv-system-site-packages
140+
run: make venv-system-site-packages VENV=.venv-site
141+
- name: Set VENV_PYTHON
142+
run: echo "VENV_PYTHON=.venv-site/bin/python" >> "$GITHUB_ENV"
141143
- name: flake8
142144
uses: liskin/gh-problem-matcher-wrap@v3
143145
with:

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ Other common tasks are available in the [Makefile](Makefile):
3333
-->
3434

3535
$ make help
36-
venv-system-site-packages: Setup ./.venv/ (--system-site-packages)
37-
venv: Setup ./.venv/
3836
check: Invoke all checks (lints, tests, readme)
3937
lint: Invoke lints
4038
lint-flake8:
@@ -46,11 +44,13 @@ Other common tasks are available in the [Makefile](Makefile):
4644
readme: Update usage/examples in *.md and fail if it differs from version control
4745
dist: Build distribution artifacts (sdist, wheel)
4846
publish: Publish to PyPI
49-
ipython: Invoke IPython in venv (not installed by default)
47+
ipython: Invoke IPython with the project and its dependencies available
5048
clean: Clean all gitignored files/directories
5149
template-update: Re-render cookiecutter template into the template branch
5250
template-merge: Re-render cookiecutter template and merge into the current branch
5351
smoke-dist: Smoke test the build artifacts in an isolated venv (i.e. check for unspecified dependencies)
52+
venv: Sync uv venv
53+
venv-system-site-packages: Setup $(VENV) (--system-site-packages)
5454
help: Display this help
5555
<!-- end include tests/readme/make-help.md -->
5656

Makefile

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
SHELL := bash
22
.SHELLFLAGS := -eu -o pipefail -c
33

4-
PYTHON = python3
4+
UV_RUN_SYNC_FLAGS = --exact --all-extras
5+
VENV_PYTHON = uv run $(UV_RUN_SYNC_FLAGS) python
56

6-
VENV = .venv
7-
VENV_PYTHON = $(VENV)/bin/python
8-
VENV_DONE = $(VENV)/.done
9-
VENV_SYSTEM_SITE_PACKAGES = $(VENV)/.venv-system-site-packages
10-
VENV_USE_SYSTEM_SITE_PACKAGES = $(wildcard $(VENV_SYSTEM_SITE_PACKAGES))
7+
VENV = $(or $(if $(filter 1,$(words $(VENV_PYTHON))),$(patsubst %/bin/,%,$(filter %/bin/,$(dir $(VENV_PYTHON))))),$(error Cannot determine VENV path))
118

129
TEMPLATES_DIR = $(HOME)/src
1310
TEMPLATE = $(eval TEMPLATE := $$(shell realpath --relative-to=. $$(TEMPLATES_DIR)/cookiecutter-python-cli))$(TEMPLATE)
1411

15-
.PHONY: venv-system-site-packages
16-
## Setup ./.venv/ (--system-site-packages)
17-
venv-system-site-packages:
18-
$(MAKE) VENV_USE_SYSTEM_SITE_PACKAGES=1 venv
19-
20-
.PHONY: venv
21-
## Setup ./.venv/
22-
venv: $(VENV_DONE)
23-
2412
.PHONY: check
2513
## Invoke all checks (lints, tests, readme)
2614
check: lint test readme
@@ -33,17 +21,17 @@ LINT_SOURCES = src/ tests/
3321

3422
.PHONY: lint-flake8
3523
##
36-
lint-flake8: $(VENV_DONE)
24+
lint-flake8:
3725
$(VENV_PYTHON) -m flake8 $(LINT_SOURCES)
3826

3927
.PHONY: lint-mypy
4028
##
41-
lint-mypy: $(VENV_DONE)
29+
lint-mypy:
4230
$(VENV_PYTHON) -m mypy --show-column-numbers $(LINT_SOURCES)
4331

4432
.PHONY: lint-isort
4533
##
46-
lint-isort: $(VENV_DONE)
34+
lint-isort:
4735
$(VENV_PYTHON) -m isort --check $(LINT_SOURCES)
4836

4937
.PHONY: test
@@ -52,16 +40,16 @@ test: test-pytest test-prysk
5240

5341
.PHONY: test-pytest
5442
##
55-
test-pytest: $(VENV_DONE)
43+
test-pytest:
5644
$(VENV_PYTHON) -m pytest $(PYTEST_FLAGS) tests/
5745

5846
.PHONY: test-prysk
5947
##
6048
test-prysk: PRYSK_INTERACTIVE=$(shell [ -t 0 ] && echo --interactive)
61-
test-prysk: $(VENV_DONE)
62-
PATH="$(CURDIR)/$(VENV)/bin:$$PATH" \
63-
XDG_DATA_HOME=/home/user/.local/share \
64-
XDG_CONFIG_HOME=/home/user/.config \
49+
test-prysk:
50+
$(if $(filter uv,$(firstword $(VENV_PYTHON))),\
51+
UV_ENV_FILE=tests/.xdg-user.env,\
52+
. $(VENV)/bin/activate && set -a && . tests/.xdg-user.env && set +a &&) \
6553
$(VENV_PYTHON) -m prysk --indent=4 --shell=/bin/bash $(PRYSK_INTERACTIVE) \
6654
$(wildcard tests/*.md tests/*/*.md tests/*/*/*.md)
6755

@@ -71,7 +59,7 @@ readme: $(wildcard *.md)
7159
git diff --exit-code $^
7260

7361
.PHONY: $(wildcard *.md)
74-
$(wildcard *.md) &: $(VENV_DONE) test-prysk
62+
$(wildcard *.md) &: test-prysk
7563
$(VENV_PYTHON) tests/include-preproc.py --comment-start="<!-- " --comment-end=" -->" $(wildcard *.md)
7664

7765
.PHONY: dist
@@ -85,9 +73,11 @@ publish: dist
8573
uv publish
8674

8775
.PHONY: ipython
88-
## Invoke IPython in venv (not installed by default)
89-
ipython: $(VENV_DONE)
90-
$(VENV_PYTHON) -m IPython
76+
## Invoke IPython with the project and its dependencies available
77+
ipython:
78+
uv run $(UV_RUN_SYNC_FLAGS) \
79+
--with ipython \
80+
python -m IPython
9181

9282
.PHONY: clean
9383
## Clean all gitignored files/directories
@@ -116,20 +106,21 @@ smoke-dist: dist
116106
-- python -m "$$package" --help; \
117107
done
118108

119-
define VENV_CREATE
120-
$(PYTHON) -m venv $(VENV)
121-
endef
122-
123-
define VENV_CREATE_SYSTEM_SITE_PACKAGES
124-
$(PYTHON) -m venv --system-site-packages --without-pip $(VENV)
125-
touch $(VENV_SYSTEM_SITE_PACKAGES)
126-
endef
109+
.PHONY: venv
110+
## Sync uv venv
111+
venv:
112+
uv sync $(UV_RUN_SYNC_FLAGS)
127113

128-
$(VENV_DONE): $(MAKEFILE_LIST) pyproject.toml
129-
$(if $(VENV_USE_SYSTEM_SITE_PACKAGES),$(VENV_CREATE_SYSTEM_SITE_PACKAGES),$(VENV_CREATE))
130-
$(VENV_PYTHON) -m pip install 'pip >= 25.1' # PEP-735 (dependency groups)
114+
.PHONY: venv-system-site-packages
115+
## Setup $(VENV) (--system-site-packages)
116+
venv-system-site-packages: VENV_PYTHON=$(VENV)/bin/python
117+
venv-system-site-packages: PYTHON=python3
118+
venv-system-site-packages:
119+
uv venv --system-site-packages --seed $(VENV)
131120
extras=$$(uvx --from yq -- tomlq -e -r '.project."optional-dependencies" // [] | keys | join(",")' pyproject.toml); \
132121
$(VENV_PYTHON) -m pip install --group dev -e ".[ $$extras ]"
133-
touch $@
122+
@echo
123+
@echo "Now use: make VENV_PYTHON=$(VENV_PYTHON)"
124+
# ^ uv's dependency solver ignores --system-site-packages, so we need to use pip
134125

135126
include _help.mk

tests/.xdg-user.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
XDG_DATA_HOME=/home/user/.local/share
2+
XDG_CONFIG_HOME=/home/user/.config

tests/readme/make-help.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
-->
88

99
$ make help
10-
venv-system-site-packages: Setup ./.venv/ (--system-site-packages)
11-
venv: Setup ./.venv/
1210
check: Invoke all checks (lints, tests, readme)
1311
lint: Invoke lints
1412
lint-flake8:
@@ -20,9 +18,11 @@
2018
readme: Update usage/examples in *.md and fail if it differs from version control
2119
dist: Build distribution artifacts (sdist, wheel)
2220
publish: Publish to PyPI
23-
ipython: Invoke IPython in venv (not installed by default)
21+
ipython: Invoke IPython with the project and its dependencies available
2422
clean: Clean all gitignored files/directories
2523
template-update: Re-render cookiecutter template into the template branch
2624
template-merge: Re-render cookiecutter template and merge into the current branch
2725
smoke-dist: Smoke test the build artifacts in an isolated venv (i.e. check for unspecified dependencies)
26+
venv: Sync uv venv
27+
venv-system-site-packages: Setup $(VENV) (--system-site-packages)
2828
help: Display this help

0 commit comments

Comments
 (0)