Skip to content

Commit a4b1ab6

Browse files
Add 'make build-env' (#135)
1 parent 3231a46 commit a4b1ab6

File tree

3 files changed

+64
-5
lines changed

3 files changed

+64
-5
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**4.1.5 - 07/25/25**
2+
3+
- Feature: Support new environment creation via 'make build-env'
4+
15
**4.1.4 - 07/16/25**
26

37
- Support pinning of vivarium_build_utils; pin vivarium_build_utils>=1.1.0,<2.0.0

Makefile

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,69 @@
11
# Check if we're running in Jenkins
22
ifdef JENKINS_URL
3-
# Files are already in workspace from shared library
3+
# Files are already in workspace from shared library
44
MAKE_INCLUDES := .
55
else
6-
# For local dev, use the installed vivarium_build_utils package
7-
MAKE_INCLUDES := $(shell python -c "from vivarium_build_utils.resources import get_makefiles_path; print(get_makefiles_path())")
6+
# For local dev, use the installed vivarium_build_utils package if it exists
7+
# First, check if we can import vivarium_build_utils and assign 'yes' or 'no'.
8+
# We do this by importing the package in python and redirecting stderr to the null device.
9+
# If the import is successful (&&), it will print 'yes', otherwise (||) it will print 'no'.
10+
VIVARIUM_BUILD_UTILS_AVAILABLE := $(shell python -c "import vivarium_build_utils" 2>/dev/null && echo "yes" || echo "no")
11+
# If vivarium_build_utils is available, get the makefiles path or else set it to empty
12+
ifeq ($(VIVARIUM_BUILD_UTILS_AVAILABLE),yes)
13+
MAKE_INCLUDES := $(shell python -c "from vivarium_build_utils.resources import get_makefiles_path; print(get_makefiles_path())")
14+
else
15+
MAKE_INCLUDES :=
16+
endif
817
endif
918

10-
PACKAGE_NAME = gbd_mapping
19+
# Set the package name as the last part of this file's parent directory path
20+
PACKAGE_NAME = $(notdir $(CURDIR))
1121

22+
ifneq ($(MAKE_INCLUDES),) # not empty
1223
# Include makefiles from vivarium_build_utils
1324
include $(MAKE_INCLUDES)/base.mk
1425
include $(MAKE_INCLUDES)/test.mk
26+
else # empty
27+
# Use this help message (since the vivarium_build_utils version is not available)
28+
help:
29+
@echo
30+
@echo "For Make's standard help, run 'make --help'."
31+
@echo
32+
@echo "Most of our Makefile targets are provided by the vivarium_build_utils"
33+
@echo "package. To access them, you need to create a development environment first."
34+
@echo
35+
@echo "make build-env"
36+
@echo
37+
@echo "USAGE:"
38+
@echo " make build-env name=<environment_name> [py=<python_version>]"
39+
@echo
40+
@echo "ARGUMENTS:"
41+
@echo " name [required] Name of the conda environment to create"
42+
@echo " py [optional] Python version (defaults to latest supported)"
43+
@echo
44+
@echo "EXAMPLE:"
45+
@echo " make build-env name=vivarium_dev"
46+
@echo " make build-env name=vivarium_dev py=3.9"
47+
@echo
48+
@echo "After creating the environment:"
49+
@echo " 1. Activate it: 'conda activate <environment_name>'"
50+
@echo " 2. Run 'make help' again to see all newly available targets"
51+
@echo
52+
endif
53+
54+
build-env: # Create a new environment with installed packages
55+
ifndef name
56+
@echo "Error: name is required and must be passed in as a keyword argument."
57+
@echo "Usage: make build-env name=<ENV_NAME> py=<PYTHON_VERSION>"
58+
@exit 1
59+
endif
60+
# Check if py is set, otherwise use the latest supported version
61+
@$(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('.')))))"))
62+
conda create -n $(name) python=$(py) --yes
63+
# Bootstrap vivarium_build_utils into the new environment
64+
conda run -n $(name) pip install vivarium_build_utils
65+
conda run -n $(name) make install
66+
@echo
67+
@echo "Environment built ($(name))"
68+
@echo "Don't forget to activate it with: 'conda activate $(name)'"
69+
@echo

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
long_description = f.read()
4444

4545
install_requirements = [
46-
"vivarium_build_utils>=1.1.0,<2.0.0",
46+
"vivarium_build_utils>=2.0.0,<3.0.0",
4747
"click",
4848
"numpy",
4949
"pandas",

0 commit comments

Comments
 (0)