Skip to content

Commit 5d338d8

Browse files
committed
stop-registry-importer dependency handling
1 parent 7323229 commit 5d338d8

3 files changed

Lines changed: 83 additions & 3 deletions

File tree

development.sh

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ DOCKER_COMPOSE_BUNDLE_REF=${BUNDLE_REF:-main}
1515
STOP_REGISTRY_IMPORTER_DIR="./stop-registry-importer"
1616
STOP_REGISTRY_VENV_DIR="${STOP_REGISTRY_IMPORTER_DIR}/.venv-stop-registry"
1717
STOP_REGISTRY_REQUIREMENTS_FILE="${STOP_REGISTRY_IMPORTER_DIR}/requirements.txt"
18+
STOP_REGISTRY_REQUIREMENTS_IN_FILE="${STOP_REGISTRY_IMPORTER_DIR}/requirements.in"
19+
20+
# Python/pip executables inside the stop-registry virtualenv. These are
21+
# populated by `ensure_python_venv` so that every Python-related command uses
22+
# the correct interpreter and isolated environment.
23+
STOP_REGISTRY_VENV_PYTHON="${STOP_REGISTRY_VENV_DIR}/bin/python"
1824

1925
# Define a Docker Compose project name to distinguish
2026
# the docker environment of this project from others
@@ -62,6 +68,11 @@ print_usage() {
6268
python:setup
6369
Creates/updates Python virtualenv for stop-registry importer and installs dependencies.
6470
71+
python:update-reqs
72+
Recompiles stop-registry-importer/requirements.txt from requirements.in using
73+
pip-tools (pip-compile). Run this after changing requirements.in. You must run python:setup
74+
to install the updated dependencies after review.
75+
6576
stop
6677
Stop the dependencies and the dockerized application.
6778
@@ -260,12 +271,49 @@ upload_zones() {
260271
}
261272

262273
setup_python() {
274+
ensure_python_venv
275+
276+
echo "Installing dependencies from ${STOP_REGISTRY_REQUIREMENTS_FILE}..."
277+
"$STOP_REGISTRY_VENV_PYTHON" -m pip install -r "$STOP_REGISTRY_REQUIREMENTS_FILE"
278+
}
279+
280+
# Ensures the stop-registry virtualenv exists and that pip is up to date.
281+
#
282+
# This is the common entry point for all Python commands: it guarantees that
283+
# subsequent calls to "$STOP_REGISTRY_VENV_PYTHON" use the correct interpreter
284+
# and isolated environment regardless of the host Python setup.
285+
ensure_python_venv() {
263286
if [ ! -d "$STOP_REGISTRY_VENV_DIR" ]; then
287+
echo "Creating Python virtualenv in ${STOP_REGISTRY_VENV_DIR}..."
264288
python3 -m venv "$STOP_REGISTRY_VENV_DIR"
265289
fi
266290

267-
"$STOP_REGISTRY_VENV_DIR/bin/pip" install --upgrade pip
268-
"$STOP_REGISTRY_VENV_DIR/bin/pip" install -r "$STOP_REGISTRY_REQUIREMENTS_FILE"
291+
if [ ! -x "$STOP_REGISTRY_VENV_PYTHON" ]; then
292+
echo "ERROR: Python executable not found in virtualenv: ${STOP_REGISTRY_VENV_PYTHON}" >&2
293+
echo "Try removing ${STOP_REGISTRY_VENV_DIR} and running 'python:setup' again." >&2
294+
exit 1
295+
fi
296+
297+
"$STOP_REGISTRY_VENV_PYTHON" -m pip install --upgrade pip
298+
}
299+
300+
# Recompiles requirements.txt from requirements.in using pip-tools and installs
301+
# the resolved dependency set into the virtualenv.
302+
update_python_requirements() {
303+
ensure_python_venv
304+
305+
if [ ! -f "$STOP_REGISTRY_REQUIREMENTS_IN_FILE" ]; then
306+
echo "ERROR: requirements input file not found: ${STOP_REGISTRY_REQUIREMENTS_IN_FILE}" >&2
307+
exit 1
308+
fi
309+
310+
"$STOP_REGISTRY_VENV_PYTHON" -m pip install --upgrade pip-tools
311+
312+
echo "Compiling ${STOP_REGISTRY_REQUIREMENTS_FILE} from ${STOP_REGISTRY_REQUIREMENTS_IN_FILE}..."
313+
"$STOP_REGISTRY_VENV_PYTHON" -m piptools compile \
314+
--strip-extras \
315+
--output-file "$STOP_REGISTRY_REQUIREMENTS_FILE" \
316+
"$STOP_REGISTRY_REQUIREMENTS_IN_FILE"
269317
}
270318

271319
### Control flow
@@ -301,6 +349,10 @@ case $COMMAND in
301349
setup_python
302350
;;
303351

352+
python:update-reqs)
353+
update_python_requirements
354+
;;
355+
304356
stop)
305357
stop
306358
;;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Top-level (direct) dependencies for the stop-registry importer.
2+
#
3+
# This file lists only the packages the importer directly imports/uses.
4+
# The fully pinned requirements.txt (including all transitive dependencies)
5+
# is generated from this file with pip-tools:
6+
#
7+
# ./development.sh python:update-reqs
8+
#
9+
# (equivalent to: pip-compile requirements.in)
10+
11+
django-environ
12+
pymssql
13+
requests
14+
simplejson
15+
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.14
3+
# by the following command:
4+
#
5+
# pip-compile --output-file=./stop-registry-importer/requirements.txt --strip-extras ./stop-registry-importer/requirements.in
6+
#
17
certifi==2026.5.20
8+
# via requests
29
charset-normalizer==3.4.7
10+
# via requests
311
django-environ==0.13.0
12+
# via -r stop-registry-importer/requirements.in
413
idna==3.17
14+
# via requests
515
pymssql==2.3.13
16+
# via -r stop-registry-importer/requirements.in
617
requests==2.34.2
18+
# via -r stop-registry-importer/requirements.in
719
simplejson==4.1.1
8-
typing_extensions==4.15.0
20+
# via -r stop-registry-importer/requirements.in
921
urllib3==2.7.0
22+
# via requests

0 commit comments

Comments
 (0)