11SHELL := 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
129TEMPLATES_DIR = $(HOME ) /src
1310TEMPLATE = $(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)
2614check : 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# #
6048test-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
135126include _help.mk
0 commit comments