Skip to content

Commit 739f2ef

Browse files
authored
Merge pull request #266 from hjwp/uv
switch to UV for python installs
2 parents 4505058 + 0680b2f commit 739f2ef

File tree

2 files changed

+67
-65
lines changed

2 files changed

+67
-65
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ jobs:
6868
tree \
6969
locales
7070
sudo locale-gen en_GB.UTF-8
71+
pip install uv
7172
7273
- name: Install Python requirements.txt globally
7374
shell: bash
7475
run: |
75-
pip install .
76+
uv pip install --system .
7677
7778
- name: Install Python requirements.txt into virtualenv
7879
shell: bash

Makefile

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ SHELL := /bin/bash
33
SOURCES := $(wildcard *.asciidoc)
44
HTML_PAGES := $(patsubst %.asciidoc, %.html, ${SOURCES})
55
TESTS := $(patsubst %.asciidoc, test_%, ${SOURCES})
6+
VENV ?= .venv
67

78
RUN_ASCIIDOCTOR = asciidoctor -a source-highlighter=pygments -a pygments-style=default -a stylesheet=asciidoctor.css -a linkcss -a icons=font -a compat-mode -a '!example-caption' -a last-update-label='License: Creative Commons <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode">CC-BY-NC-ND</a>. Last updated:'
89

@@ -41,129 +42,129 @@ book.html: $(SOURCES)
4142
build: $(HTML_PAGES) $(TMPDIR)
4243

4344

44-
.venv/bin:
45-
which uv && uv venv .venv || python3 -m venv .venv
46-
which uv && uv pip install -e . || .venv/bin/pip install -e .
45+
$(VENV)/bin:
46+
which uv && uv venv $(VENV)|| python3 -m venv $(VENV)
47+
which uv && uv pip install -e . || $(VENV)/bin/pip install -e .
4748

4849
.PHONY: install
49-
install: .venv/bin
50+
install: $(VENV)/bin
5051
which brew && brew install asciidoctor tree || apt install -y asciidoctor tree
5152

5253
.PHONY: update-submodules
5354
update-submodules:
5455
git submodule update --init --recursive
55-
.venv/bin/python tests/update_source_repo.py
56+
$(VENV)/bin/python tests/update_source_repo.py
5657

5758
# this is to allow for a git remote called "local" for eg ./source/feed-thru-cherry-pick.sh
5859
../book-example.git:
5960
mkdir -p ../book-example.git
6061
git init --bare ../book-example.git
6162

6263
.PHONY: test
63-
test: build update-submodules .venv/bin
64-
.venv/bin/pytest --tb=short --color=yes tests/
64+
test: build update-submodules $(VENV)/bin
65+
$(VENV)/bin/pytest --tb=short --color=yes tests/
6566

6667
.PHONY: testall
6768
testall: build
68-
.venv/bin/pytest --tb=short --color=yes --numprocesses=auto tests/test_chapter_*
69+
$(VENV)/bin/pytest --tb=short --color=yes --numprocesses=auto tests/test_chapter_*
6970

7071
.PHONY: testall4
7172
testall4: build
72-
.venv/bin/pytest --tb=short --color=yes --numprocesses=4 tests/test_chapter_*
73+
$(VENV)/bin/pytest --tb=short --color=yes --numprocesses=4 tests/test_chapter_*
7374

7475

7576
.PHONY: test_%
7677
test_%: %.html $(TMPDIR)
77-
.venv/bin/pytest -s --tb=short ./tests/$@.py
78+
$(VENV)/bin/pytest -s --tb=short ./tests/$@.py
7879

7980
# exhaustively list for nice tab-completion
8081
#
8182
.PHONY: test_chapter_01
82-
test_chapter_01: chapter_01.html $(TMPDIR) .venv/bin
83-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_01.py
83+
test_chapter_01: chapter_01.html $(TMPDIR) $(VENV)/bin
84+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_01.py
8485
.PHONY: test_chapter_02_unittest
85-
test_chapter_02_unittest: chapter_02_unittest.html $(TMPDIR) .venv/bin
86-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_02_unittest.py
86+
test_chapter_02_unittest: chapter_02_unittest.html $(TMPDIR) $(VENV)/bin
87+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_02_unittest.py
8788
.PHONY: test_chapter_03_unit_test_first_view
88-
test_chapter_03_unit_test_first_view: chapter_03_unit_test_first_view.html $(TMPDIR) .venv/bin
89-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_03_unit_test_first_view.py
89+
test_chapter_03_unit_test_first_view: chapter_03_unit_test_first_view.html $(TMPDIR) $(VENV)/bin
90+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_03_unit_test_first_view.py
9091
.PHONY: test_chapter_04_philosophy_and_refactoring
91-
test_chapter_04_philosophy_and_refactoring: chapter_04_philosophy_and_refactoring.html $(TMPDIR) .venv/bin
92-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_04_philosophy_and_refactoring.py
92+
test_chapter_04_philosophy_and_refactoring: chapter_04_philosophy_and_refactoring.html $(TMPDIR) $(VENV)/bin
93+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_04_philosophy_and_refactoring.py
9394
.PHONY: test_chapter_05_post_and_database
94-
test_chapter_05_post_and_database: chapter_05_post_and_database.html $(TMPDIR) .venv/bin
95-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_05_post_and_database.py
95+
test_chapter_05_post_and_database: chapter_05_post_and_database.html $(TMPDIR) $(VENV)/bin
96+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_05_post_and_database.py
9697
.PHONY: test_chapter_06_explicit_waits_1
97-
test_chapter_06_explicit_waits_1: chapter_06_explicit_waits_1.html $(TMPDIR) .venv/bin
98-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_06_explicit_waits_1.py
98+
test_chapter_06_explicit_waits_1: chapter_06_explicit_waits_1.html $(TMPDIR) $(VENV)/bin
99+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_06_explicit_waits_1.py
99100
.PHONY: test_chapter_07_working_incrementally
100-
test_chapter_07_working_incrementally: chapter_07_working_incrementally.html $(TMPDIR) .venv/bin
101-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_07_working_incrementally.py
101+
test_chapter_07_working_incrementally: chapter_07_working_incrementally.html $(TMPDIR) $(VENV)/bin
102+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_07_working_incrementally.py
102103
.PHONY: test_chapter_08_prettification
103-
test_chapter_08_prettification: chapter_08_prettification.html $(TMPDIR) .venv/bin
104-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_08_prettification.py
104+
test_chapter_08_prettification: chapter_08_prettification.html $(TMPDIR) $(VENV)/bin
105+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_08_prettification.py
105106
.PHONY: test_chapter_09_docker
106-
test_chapter_09_docker: chapter_09_docker.html $(TMPDIR) .venv/bin
107-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_09_docker.py
107+
test_chapter_09_docker: chapter_09_docker.html $(TMPDIR) $(VENV)/bin
108+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_09_docker.py
108109
.PHONY: test_chapter_10_production_readiness
109-
test_chapter_10_production_readiness: chapter_10_production_readiness.html $(TMPDIR) .venv/bin
110-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_10_production_readiness.py
110+
test_chapter_10_production_readiness: chapter_10_production_readiness.html $(TMPDIR) $(VENV)/bin
111+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_10_production_readiness.py
111112
.PHONY: test_chapter_11_ansible
112-
test_chapter_11_ansible: chapter_11_ansible.html $(TMPDIR) .venv/bin
113-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_11_ansible.py
113+
test_chapter_11_ansible: chapter_11_ansible.html $(TMPDIR) $(VENV)/bin
114+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_11_ansible.py
114115
.PHONY: test_chapter_12_organising_test_files
115-
test_chapter_12_organising_test_files: chapter_12_organising_test_files.html $(TMPDIR) .venv/bin
116-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_12_organising_test_files.py
116+
test_chapter_12_organising_test_files: chapter_12_organising_test_files.html $(TMPDIR) $(VENV)/bin
117+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_12_organising_test_files.py
117118
.PHONY: test_chapter_13_database_layer_validation
118-
test_chapter_13_database_layer_validation: chapter_13_database_layer_validation.html $(TMPDIR) .venv/bin
119-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_13_database_layer_validation.py
119+
test_chapter_13_database_layer_validation: chapter_13_database_layer_validation.html $(TMPDIR) $(VENV)/bin
120+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_13_database_layer_validation.py
120121
.PHONY: test_chapter_14_simple_form
121-
test_chapter_14_simple_form: chapter_14_simple_form.html $(TMPDIR) .venv/bin
122-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_14_simple_form.py
122+
test_chapter_14_simple_form: chapter_14_simple_form.html $(TMPDIR) $(VENV)/bin
123+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_14_simple_form.py
123124
.PHONY: test_chapter_15_advanced_forms
124-
test_chapter_15_advanced_forms: chapter_15_advanced_forms.html $(TMPDIR) .venv/bin
125-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_15_advanced_forms.py
125+
test_chapter_15_advanced_forms: chapter_15_advanced_forms.html $(TMPDIR) $(VENV)/bin
126+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_15_advanced_forms.py
126127
.PHONY: test_chapter_16_javascript
127-
test_chapter_16_javascript: chapter_16_javascript.html $(TMPDIR) .venv/bin
128-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_16_javascript.py
128+
test_chapter_16_javascript: chapter_16_javascript.html $(TMPDIR) $(VENV)/bin
129+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_16_javascript.py
129130
.PHONY: test_chapter_deploying_validation
130-
test_chapter_deploying_validation: chapter_deploying_validation.html $(TMPDIR) .venv/bin
131-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_deploying_validation.py
131+
test_chapter_deploying_validation: chapter_deploying_validation.html $(TMPDIR) $(VENV)/bin
132+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_deploying_validation.py
132133
.PHONY: test_chapter_spiking_custom_auth
133-
test_chapter_spiking_custom_auth: chapter_spiking_custom_auth.html $(TMPDIR) .venv/bin
134-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_spiking_custom_auth.py
134+
test_chapter_spiking_custom_auth: chapter_spiking_custom_auth.html $(TMPDIR) $(VENV)/bin
135+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_spiking_custom_auth.py
135136
.PHONY: test_chapter_mocking
136-
test_chapter_mocking: chapter_mocking.html $(TMPDIR) .venv/bin
137-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_mocking.py
137+
test_chapter_mocking: chapter_mocking.html $(TMPDIR) $(VENV)/bin
138+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_mocking.py
138139
.PHONY: test_chapter_fixtures_and_wait_decorator
139-
test_chapter_fixtures_and_wait_decorator: chapter_fixtures_and_wait_decorator.html $(TMPDIR) .venv/bin
140-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_fixtures_and_wait_decorator.py
140+
test_chapter_fixtures_and_wait_decorator: chapter_fixtures_and_wait_decorator.html $(TMPDIR) $(VENV)/bin
141+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_fixtures_and_wait_decorator.py
141142
.PHONY: test_chapter_server_side_debugging
142-
test_chapter_server_side_debugging: chapter_server_side_debugging.html $(TMPDIR) .venv/bin
143-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_server_side_debugging.py
143+
test_chapter_server_side_debugging: chapter_server_side_debugging.html $(TMPDIR) $(VENV)/bin
144+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_server_side_debugging.py
144145
.PHONY: test_chapter_outside_in
145-
test_chapter_outside_in: chapter_outside_in.html $(TMPDIR) .venv/bin
146-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_outside_in.py
146+
test_chapter_outside_in: chapter_outside_in.html $(TMPDIR) $(VENV)/bin
147+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_outside_in.py
147148
.PHONY: test_chapter_purist_unit_tests
148-
test_chapter_purist_unit_tests: chapter_purist_unit_tests.html $(TMPDIR) .venv/bin
149-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_purist_unit_tests.py
149+
test_chapter_purist_unit_tests: chapter_purist_unit_tests.html $(TMPDIR) $(VENV)/bin
150+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_purist_unit_tests.py
150151
.PHONY: test_chapter_CI
151-
test_chapter_CI: chapter_CI.html $(TMPDIR) .venv/bin
152-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_CI.py
152+
test_chapter_CI: chapter_CI.html $(TMPDIR) $(VENV)/bin
153+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_CI.py
153154
.PHONY: test_chapter_page_pattern
154-
test_chapter_page_pattern: chapter_page_pattern.html $(TMPDIR) .venv/bin
155-
.venv/bin/pytest -s --tb=short ./tests/test_chapter_page_pattern.py
155+
test_chapter_page_pattern: chapter_page_pattern.html $(TMPDIR) $(VENV)/bin
156+
$(VENV)/bin/pytest -s --tb=short ./tests/test_chapter_page_pattern.py
156157

157158

158159

159160
.PHONY: silent_test_%
160-
silent_test_%: %.html $(TMPDIR) .venv/bin
161-
.venv/bin/pytest --tb=short ./tests/$(subst silent_,,$@).py
161+
silent_test_%: %.html $(TMPDIR) $(VENV)/bin
162+
$(VENV)/bin/pytest --tb=short ./tests/$(subst silent_,,$@).py
162163

163164
.PHONY: unit-test
164-
unit-test: chapter_01.html .venv/bin
165+
unit-test: chapter_01.html $(VENV)/bin
165166
SKIP_CHAPTER_SUBMODULES=1 ./tests/update_source_repo.py
166-
source .venv/bin/activate && ./run_test_tests.sh
167+
source $(VENV)/bin/activate && ./run_test_tests.sh
167168

168169
.PHONY: clean
169170
clean:

0 commit comments

Comments
 (0)