-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (95 loc) · 3.79 KB
/
Makefile
File metadata and controls
120 lines (95 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Common python Makefile rules, these must be included in
# the application Makefile and setup with the correct variables like:
#
# # Important Paths
# base_dir ?= $(shell git rev-parse --show-toplevel)
# app_dir ?= $(shell git rev-parse --show-prefix)
#
# # Service variables
# docker_service_name := nucleus-test-service
# docker_group := big-bend
# service_name := nucleus_test_service-api
# app_name := nucleus_test_service
#
# # Conda-related paths
# conda_env_dir ?= ./env
# # Commands
# CONDA_EXE ?= conda
# conda_run := $(CONDA_EXE) run --live-stream --prefix $(conda_env_dir)
#
# Then include the help make file and python make file in order:
#
# # Include the help command and make this the default rule.
# include $(base_dir)/shared/help.mk
# # Include python standard commands
# include $(base_dir)/shared/python.mk
#
# Important Paths
base_dir ?= $(shell git rev-parse --show-toplevel)
app_dir ?= $(shell git rev-parse --show-prefix)
conda_env_dir ?= $(base_dir)/env
conda_bin ?= $(conda_env_dir)/bin
# Export environment variables
export PYTHONPATH = $(base_dir)/src
# Tell pip not to install any deps conda lock does that
export PIP_NO_DEPS = 1
# Tell pip not to create a venv to build... just use the existing env tools
export PIP_NO_BUILD_ISOLATION=1
# Setup conda lock
CONDA_EXE ?= conda
CONDA_LOCK := $(CONDA_EXE) lock
CONDA_LOCK_FILE ?= conda-lock.yml
CONDA_LOCK_EXTRAS ?= "dev,all"
# Commands
conda_run := $(CONDA_EXE) run --live-stream --prefix $(conda_env_dir)
check-env:
@if [ -z "$(CONDA_EXE)" ]; then \
echo "Error: Please install 'conda' first"; \
exit 1; \
fi
@if ! $(CONDA_LOCK) --help >/dev/null 2>&1; then \
echo "Error: 'conda lock' command not available. Please install conda-lock plugin"; \
exit 1; \
fi
$(CONDA_LOCK_FILE): pyproject.toml
$(CONDA_LOCK) --check-input-hash --file pyproject.toml --extras $(CONDA_LOCK_EXTRAS)
lock: check-env $(CONDA_LOCK_FILE) ## Lock Conda dependencies in project
lock-force: check-env ## Force lock Conda dependencies in project
$(CONDA_LOCK) --file pyproject.toml --extras $(CONDA_LOCK_EXTRAS)
setup: check-env $(CONDA_LOCK_FILE) ## Setup local environment
$(CONDA_LOCK) install -E all --log-level ERROR -p $(conda_env_dir) $(CONDA_LOCK_FILE)
$(conda_bin)/pip install -e .
type-check: ## Run mypy to check static types
$(conda_run) mypy $(args)
test: ## Run all the unit tests
$(conda_run) pytest -vv $(ARGS) $(args) tests/
test-pdb: ## Run all the unit tests, start the Python debugger on errros
$(conda_run) pytest -vv $(ARGS) $(args) tests/ --log-cli-level=warning --pdb
test-integration: ## Run the integration tests
$(conda_run) pytest --no-cov -vv $(ARGS) $(args) tests/ --integration -m integration
test-all: ## Run all the tests, including integration tests
$(conda_run) pytest -vv $(ARGS) $(args) tests/ --integration
test-failed: ## Run tests that failed or all if none failed
$(conda_run) pytest -vv --lf --no-cov $(ARGS) $(args) tests/
test-only: ## Run only the tests specified (make test-only args=tests/api/endpoints)
$(conda_run) pytest -vv --no-cov $(ARGS) $(args)
install-hooks: ## Install pre-commit hooks
pre-commit install-hooks
pre-commit: ## Run pre-commit on the repo
pre-commit run --verbose --show-diff-on-failure --color=always --all-files
dev: ## Run example
cd examples && $(conda_run) python app.py
dev-forms: ## Run example
cd examples && $(conda_run) python forms.py
repl: ## Get a python repl that is configured properly
$(conda_run) python
fmt: ## Format code with ruff
$(conda_run) ruff format
clean: ## Clean up cache and temporary files and stop containers
find . -name \*.py[cod] -delete
rm -rf .pytest_cache .mypy_cache .coverage coverage.xml htmlcov junit dist
build: ## Run uv build
rm -rf dist
uv build
publist: ## Run uv publish
uv publish