Skip to content

Commit 19e6567

Browse files
authored
Update Makefile
1 parent 73172b5 commit 19e6567

File tree

1 file changed

+21
-97
lines changed

1 file changed

+21
-97
lines changed

Makefile

Lines changed: 21 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,27 @@
1-
SHELL := /bin/bash
2-
this_makefile := $(lastword $(MAKEFILE_LIST)) # Used to automatically list targets
3-
.DEFAULT_GOAL := list # If someone runs "make", run "make list"
4-
5-
# Source files to format, lint, and type check.
6-
LOCATIONS=src tests
7-
8-
# Unless overridden, build conda environment using the package name.
9-
PACKAGE_NAME = vivarium
10-
SAFE_NAME = $(shell python -c "from pkg_resources import safe_name; print(safe_name(\"$(PACKAGE_NAME)\"))")
11-
12-
setup_file = $(shell find -name setup.py)
13-
version_line = $(shell grep "version = " ${setup_file})
14-
PACKAGE_VERSION = $(shell echo ${version_line} | cut -d "=" -f 2 | xargs)
15-
16-
# Use this URL to pull IHME Python packages and deploy this package to PyPi.
17-
IHME_PYPI := https://artifactory.ihme.washington.edu/artifactory/api/pypi/pypi-shared/
18-
19-
# If CONDA_ENV_PATH is set (from a Jenkins build), use the -p flag when making Conda env in
20-
# order to make env at specific path. Otherwise, make a named env at the default path using
21-
# the -n flag.
22-
PYTHON_VERSION ?= 3.11
23-
CONDA_ENV_NAME ?= ${PACKAGE_NAME}_py${PYTHON_VERSION}
24-
CONDA_ENV_CREATION_FLAG = $(if $(CONDA_ENV_PATH),-p ${CONDA_ENV_PATH},-n ${CONDA_ENV_NAME})
25-
26-
# These are the doc and source code files in this repo.
27-
# When one of these files changes, it means that Make targets need to run again.
28-
MAKE_SOURCES := $(shell find . -type d -name "*" ! -path "./.git*" ! -path "./.vscode" ! -path "./output" ! -path "./output/*" ! -path "./archive" ! -path "./dist" ! -path "./output/htmlcov*" ! -path "**/.pytest_cache*" ! -path "**/__pycache__" ! -path "./output/docs_build*" ! -path "./.pytype*" ! -path "." ! -path "./src/${PACKAGE_NAME}/legacy*" ! -path ./.history ! -path "./.history/*" ! -path "./src/${PACKAGE_NAME}.egg-info" ! -path ./.idea ! -path "./.idea/*" )
29-
30-
31-
# Phony targets don't produce artifacts.
32-
.PHONY: .list-targets build-env clean debug deploy-doc deploy-package full help install list quick
33-
34-
# List of Make targets is generated dynamically. To add description of target, use a # on the target definition.
35-
list help: debug .list-targets
36-
37-
.list-targets: # Print available Make targets
38-
@echo
39-
@echo "Make targets:"
40-
@grep -i "^[a-zA-Z][a-zA-Z0-9_ \.\-]*: .*[#].*" ${this_makefile} | sort | sed 's/:.*#/ : /g' | column -t -s:
41-
@echo
42-
43-
debug: # Print debug information (environment variables)
44-
@echo "'make' invoked with these environment variables:"
45-
@echo "CONDA_ENV_NAME: ${CONDA_ENV_NAME}"
46-
@echo "IHME_PYPI: ${IHME_PYPI}"
47-
@echo "LOCATIONS: ${LOCATIONS}"
48-
@echo "PACKAGE_NAME: ${PACKAGE_NAME}"
49-
@echo "PACKAGE_VERSION: ${PACKAGE_VERSION}"
50-
@echo "PYPI_ARTIFACTORY_CREDENTIALS_USR: ${PYPI_ARTIFACTORY_CREDENTIALS_USR} "
51-
@echo "Make sources: ${MAKE_SOURCES}"
52-
53-
build-env: # Make a new conda environment
54-
@[ "${CONDA_ENV_NAME}" ] && echo "" > /dev/null || ( echo "CONDA_ENV_NAME is not set"; exit 1 )
55-
conda create ${CONDA_ENV_CREATION_FLAG} python=${PYTHON_VERSION} --yes
56-
57-
install: # Install setuptools, install this package in editable mode
58-
pip install --upgrade pip setuptools
59-
pip install -e .[DEV]
60-
@cd ..
1+
# Check if we're running in Jenkins
2+
ifdef JENKINS_URL
3+
# Files are already in workspace from shared library
4+
MAKE_INCLUDES := .
5+
else
6+
# For local dev, search in parent directory
7+
MAKE_INCLUDES := ../vivarium_build_utils/resources/makefiles
8+
endif
9+
10+
PACKAGE_NAME = vivarium_testing_utils
11+
12+
.PHONY: install
13+
install: ## Install setuptools, package, and build utilities
14+
pip install uv
15+
uv pip install --upgrade pip setuptools
16+
uv pip install -e .[DEV]
6117
@echo "----------------------------------------"
62-
@if [ ! -d "vivarium_build_utils" ]; then \
18+
@if [ ! -d "../vivarium_build_utils" ]; then \
6319
# Clone the build utils repo if it doesn't exist. \
64-
git clone https://github.com/ihmeuw/vivarium_build_utils.git; \
20+
git clone https://github.com/ihmeuw/vivarium_build_utils.git ../vivarium_build_utils; \
6521
else \
6622
echo "vivarium_build_utils already exists. Skipping clone."; \
6723
fi
68-
@echo "Contents of install_dependency_branch.sh"
69-
@echo "----------------------------------------"
70-
@cat vivarium_build_utils/install_dependency_branch.sh
71-
@echo ""
72-
@echo "----------------------------------------"
73-
@sh vivarium_build_utils/install_dependency_branch.sh layered_config_tree ${GIT_BRANCH} jenkins
74-
75-
format: setup.py pyproject.toml $(MAKE_SOURCES) # Run the code formatter and import sorter
76-
black $(LOCATIONS)
77-
isort $(LOCATIONS)
78-
mypy $(LOCATIONS)
79-
@echo "Ignore, Created by Makefile, `date`" > $@
80-
81-
lint: .flake8 .bandit $(MAKE_SOURCES) # Run the code linter and package security vulnerability checker
82-
-flake8 $(LOCATIONS)
83-
-safety check
84-
@echo "Ignore, Created by Makefile, `date`" > $@
85-
86-
integration: $(MAKE_SOURCES) # Run the end-to-end tests
87-
export COVERAGE_FILE=./output/.coverage.integration
88-
pytest --runslow tests --cov --cov-report term --cov-report html:./output/htmlcov_integration
89-
@echo "Ignore, Created by Makefile, `date`" > $@
90-
91-
build-doc: $(MAKE_SOURCES) # Build the Sphinx docs
92-
$(MAKE) -C docs/ html
93-
@echo "Ignore, Created by Makefile, `date`" > $@
94-
95-
build-package: $(MAKE_SOURCES) # Build the package as a pip wheel
96-
pip install build
97-
python -m build
98-
@echo "Ignore, Created by Makefile, `date`" > $@
9924

100-
clean: # Delete build artifacts and do any custom cleanup such as spinning down services
101-
@rm -rf format lint build-doc build-package integration .pytest_cache
102-
@rm -rf dist output
103-
$(shell find . -type f -name '*py[co]' -delete -o -type d -name __pycache__ -delete)
25+
# Include the makefiles
26+
include $(MAKE_INCLUDES)/base.mk
27+
include $(MAKE_INCLUDES)/test.mk

0 commit comments

Comments
 (0)