Skip to content

Commit c6e3ee0

Browse files
authored
feat: replace pip install by uv and lock file (#529)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent e44d30c commit c6e3ee0

7 files changed

Lines changed: 1294 additions & 40 deletions

File tree

.github/workflows/run-unit-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jobs:
5656
sudo ln -s /etc/apparmor.d/usr.sbin.slapd /etc/apparmor.d/disable/
5757
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.slapd
5858
59+
- name: Install uv from vendored wheel
60+
run: pip install --no-index --find-links=./thirdparty/dist uv
61+
5962
- name: Install dependencies
6063
run: make dev envfile
6164

Makefile

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
# See https://aboutcode.org for more information about AboutCode FOSS projects.
77
#
88

9-
PYTHON_EXE=python3.14
109
VENV_LOCATION=.venv
1110
ACTIVATE?=. ${VENV_LOCATION}/bin/activate;
1211
MANAGE=${VENV_LOCATION}/bin/python manage.py
1312
# Do not depend on Python to generate the SECRET_KEY
1413
GET_SECRET_KEY=`head -c50 /dev/urandom | base64 | head -c50`
15-
PIP_ARGS=--find-links=./thirdparty/dist/ --no-index --no-cache-dir
1614
# Customize with `$ make envfile ENV_FILE=/etc/dejacode/.env`
1715
ENV_FILE=.env
1816
DOCS_LOCATION=./docs
@@ -36,18 +34,44 @@ else
3634
endif
3735

3836
virtualenv:
39-
@echo "-> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE}"
40-
${PYTHON_EXE} -m venv ${VENV_LOCATION}
37+
@echo "-> Bootstrap the virtualenv with uv"
38+
uv venv --allow-existing ${VENV_LOCATION}
4139

4240
conf: virtualenv
4341
@echo "-> Install dependencies"
44-
@${ACTIVATE} pip install ${PIP_ARGS} --editable .
42+
uv sync --frozen
4543
@echo "-> Create the var/ directory"
4644
@mkdir -p var
4745

4846
dev: virtualenv
4947
@echo "-> Configure and install development dependencies"
50-
@${ACTIVATE} pip install ${PIP_ARGS} --editable .[dev]
48+
uv sync --frozen --extra dev
49+
50+
outdated:
51+
@echo "-> Check for outdated packages (with 7 days cooldown)"
52+
uv pip list --outdated \
53+
--no-config \
54+
--index-url https://pypi.org/simple \
55+
--exclude-newer "7 days"
56+
57+
upgrade:
58+
@if [ -z "$(PACKAGE)" ]; then \
59+
echo "Usage: make upgrade PACKAGE=django==x.x.x"; \
60+
exit 1; \
61+
fi
62+
@echo "-> Download $(PACKAGE) wheels"
63+
@${ACTIVATE} pip download $(PACKAGE) \
64+
--only-binary=:all: \
65+
--platform macosx_11_0_arm64 \
66+
--platform manylinux2014_x86_64 \
67+
--python-version 3.14 \
68+
--dest ./thirdparty/dist/
69+
@echo "-> Update pyproject.toml and uv.lock"
70+
uv add $(PACKAGE)
71+
72+
lock:
73+
@echo "-> Regenerate uv.lock from local wheels"
74+
uv lock
5175

5276
envfile:
5377
@echo "-> Create the .env file and generate a secret key"
@@ -59,14 +83,9 @@ envfile_dev: envfile
5983
@echo "-> Update the .env file for development"
6084
@echo DATABASE_PASSWORD=\"dejacode\" >> ${ENV_FILE}
6185

62-
doc_dependencies: virtualenv
63-
@echo "-> Configure and install documentation dependencies"
64-
@${ACTIVATE} pip install --editable .[docs]
65-
6686
doc8:
6787
@echo "-> Run documentation .rst validation"
68-
@$(MAKE) doc_dependencies > /dev/null 2>&1
69-
@${ACTIVATE} doc8 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
88+
uvx doc8==2.0.0 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
7089

7190
valid:
7291
@echo "-> Run Ruff format"
@@ -116,11 +135,6 @@ migrate:
116135
@echo "-> Apply database migrations"
117136
${MANAGE} migrate
118137

119-
upgrade:
120-
@echo "-> Upgrade local git checkout"
121-
@git pull
122-
@$(MAKE) migrate
123-
124138
postgresdb:
125139
@echo "-> Configure PostgreSQL database"
126140
@echo "-> Create database user ${DB_NAME}"
@@ -152,9 +166,8 @@ test:
152166
docs:
153167
@echo "-> Builds the documentation"
154168
rm -rf ${DOCS_LOCATION}/_build/
155-
@$(MAKE) doc_dependencies > /dev/null 2>&1
156-
@${ACTIVATE} sphinx-build -b singlehtml ${DOCS_LOCATION} ${DOCS_LOCATION}/_build/singlehtml/
157-
@${ACTIVATE} sphinx-build -b html ${DOCS_LOCATION} ${DOCS_LOCATION}/_build/html/
169+
uvx --from sphinx==9.1.0 --with furo==2025.12.19 sphinx-build -b singlehtml ${DOCS_LOCATION} ${DOCS_LOCATION}/_build/singlehtml/
170+
uvx --from sphinx==9.1.0 --with furo==2025.12.19 sphinx-build -b html ${DOCS_LOCATION} ${DOCS_LOCATION}/_build/html/
158171

159172
build:
160173
@echo "-> Build the Docker image"
@@ -176,4 +189,4 @@ log:
176189
createsuperuser:
177190
${DOCKER_EXEC} web ./manage.py createsuperuser
178191

179-
.PHONY: virtualenv conf dev envfile envfile_dev doc_dependencies check doc8 valid check-deploy clean initdb postgresdb postgresdb_clean migrate upgrade run test docs build psql bash shell log createsuperuser
192+
.PHONY: virtualenv conf dev lock upgrade envfile envfile_dev check outdated doc8 valid check-deploy clean initdb postgresdb postgresdb_clean migrate run test docs build psql bash shell log createsuperuser

etc/git_hooks/pre-commit

Lines changed: 0 additions & 14 deletions
This file was deleted.

pyproject.toml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ dev = [
167167
# Parallel testing
168168
"tblib==3.2.2"
169169
]
170-
docs = [
171-
"Sphinx",
172-
"furo",
173-
"doc8",
174-
]
175170

176171
[project.urls]
177172
Homepage = "https://github.com/aboutcode-org/dejacode"
@@ -186,6 +181,21 @@ dejacode = "dejacode:command_line"
186181
[tool.setuptools.packages.find]
187182
where = ["."]
188183

184+
[tool.uv]
185+
# Disable PyPI and any remote index, only use local sources
186+
no-index = true
187+
# Look for wheels in this local directory only
188+
find-links = ["./thirdparty/dist"]
189+
# Copy files instead of hardlinking, works across all filesystems
190+
link-mode = "copy"
191+
# Ignore package versions published in the last 7 days for safety
192+
exclude-newer = "7 days"
193+
# Only resolve for Linux and macOS
194+
environments = [
195+
"sys_platform == 'linux'",
196+
"sys_platform == 'darwin'",
197+
]
198+
189199
[tool.ruff]
190200
line-length = 100
191201
target-version = "py313"
20.7 MB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)