Skip to content

Commit 278f925

Browse files
authored
refactor: simplify handling of the PYTHON environment variable by make (#1128)
1 parent b2c5b24 commit 278f925

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ SHELL := bash
77
PACKAGE_NAME := package
88
PACKAGE_VERSION := $(shell python -c $$'try: import $(PACKAGE_NAME); print($(PACKAGE_NAME).__version__);\nexcept: print("unknown");')
99

10+
# If a PYTHON environment variable exists then use that, else define it here.
11+
PYTHON ?= python3.13
12+
1013
# This variable contains the first goal that matches any of the listed goals
1114
# here, else it contains an empty string. The net effect is to filter out
1215
# whether this current run of `make` requires a Python virtual environment
@@ -69,13 +72,8 @@ venv:
6972
if [ -d .venv/ ]; then \
7073
echo "Found an inactive Python virtual environment, please activate or nuke it" && exit 1; \
7174
fi
72-
if [ -z "${PYTHON}" ]; then \
73-
echo "Creating virtual environment in .venv/ for python3.13"; \
74-
python3.13 -m venv --upgrade-deps --prompt . .venv; \
75-
else \
76-
echo "Creating virtual environment in .venv/ for ${PYTHON}"; \
77-
${PYTHON} -m venv --upgrade-deps --prompt . .venv; \
78-
fi
75+
echo "Creating virtual environment in .venv/ for ${PYTHON}"; \
76+
${PYTHON} -m venv --upgrade-deps --prompt . .venv; \
7977
touch .venv/pip.conf
8078

8179
# Set up a newly created virtual environment. Note: pre-commit uses the

0 commit comments

Comments
 (0)