File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,14 @@ build-env: # Create a new environment with installed packages
6868# Handle arguments and set defaults
6969# name
7070 @$(eval name ?= $(PACKAGE_NAME))
71- # python version
72- @$(eval py ?= $(shell python -c "import json; versions = json.load(open('python_versions.json')); print(max(versions, key=lambda x: tuple(map(int, x.split('.')))))"))
71+ # python version - validate if specified, else get default from json file
72+ @if [ -n "$(py)" ] && ! python -c "import json; exit(0 if '$(py)' in json.load(open('python_versions.json')) else 1)" 2>/dev/null; then \
73+ echo "Error: Python version '$(py)' is not supported. Available: $$(python -c "import json; print(', '.join(json.load(open('python_versions.json'))))")" >&2; \
74+ exit 1; \
75+ fi
76+ @$(eval py ?= $(shell python -c "import json; print(max(json.load(open('python_versions.json')), key=lambda x: tuple(map(int, x.split('.')))))"))
7377
78+
7479 conda create -n $(name) python=$(py) --yes
7580# Bootstrap vivarium_build_utils into the new environment
7681 conda run -n $(name) pip install vivarium_build_utils
@@ -82,5 +87,5 @@ build-env: # Create a new environment with installed packages
8287 @echo " python version: $(py)"
8388 @echo
8489 @echo "Don't forget to activate it with:"
85- @echo "conda activate $(name)"
90+ @echo "conda activate $(name)"
8691 @echo
You can’t perform that action at this time.
0 commit comments