11# * Variables
22SHELL ?= /usr/bin/env bash
3- ACTIVEPYTHON = $(shell which python)
3+ PYTHON_PATH = $(shell which python)
4+ PYTHON_ROOT := $(dir $(PYTHON_PATH ) )
5+ # use the directory rather than the python binary to allow auto-discovery, which is more cross-platform compatible
6+ UV_PYTHON_PATH ?= $(UV_PYTHON_ROOT )
7+ # to actually reuse an existing virtual/conda environment, the 'UV_PROJECT_ENVIRONMENT' variable must be set to it
8+ # use this command:
9+ # UV_PROJECT_ENVIRONMENT=/path/to/env make [target]
10+ # consider exporting this variable in '/path/to/env/etc/conda/activate.d/env.sh' to enable it by default when
11+ # activating a conda environment, and reset it in '/path/to/env/etc/conda/deactivate.d/env.sh'
12+ UV_PROJECT_ENVIRONMENT ?= .venv
13+ # make sure every uv command employs the specified environment path
14+ UV_COMMAND ?= UV_PROJECT_ENVIRONMENT="$(UV_PROJECT_ENVIRONMENT ) " uv
415
516# * UV
617.PHONY : setup
@@ -9,35 +20,35 @@ setup:
920
1021.PHONY : publish
1122publish :
12- uv publish --build
23+ $( UV_COMMAND ) publish --build
1324
1425# * Installation
1526.PHONY : install
1627install : setup
17- uv export --format requirements-txt -o requirements.txt --no-dev
18- uv pip install --python $( ACTIVEPYTHON ) -r requirements.txt
28+ $( UV_COMMAND ) export --format requirements-txt -o requirements.txt --no-dev
29+ $( UV_COMMAND ) pip install --python " $( UV_PYTHON_ROOT ) " -r requirements.txt
1930
2031.PHONY : install-dev
2132install-dev : setup
22- uv export --format requirements-txt -o requirements-dev.txt
23- uv pip install --python $( ACTIVEPYTHON ) -r requirements-dev.txt
33+ $( UV_COMMAND ) export --format requirements-txt -o requirements-dev.txt
34+ $( UV_COMMAND ) pip install --python " $( UV_PYTHON_ROOT ) " -r requirements-dev.txt
2435
2536.PHONY : pre-commit-install
2637pre-commit-install : setup
27- uv run --python $( ACTIVEPYTHON ) pre-commit install
38+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " pre-commit install
2839
2940# * Formatters
3041.PHONY : codestyle
3142codestyle : setup
32- uv run --python $( ACTIVEPYTHON ) ruff format --config=pyproject.toml stac_model tests
43+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " ruff format --config=pyproject.toml stac_model tests
3344
3445.PHONY : format
3546format : codestyle
3647
3748# * Linting
3849.PHONY : test
3950test : setup
40- uv run --python $( ACTIVEPYTHON ) pytest -c pyproject.toml --cov-report=html --cov=stac_model tests/
51+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " pytest -c pyproject.toml --cov-report=html --cov=stac_model tests/
4152
4253.PHONY : check
4354check : check-examples check-markdown check-lint check-mypy check-safety check-citation
@@ -47,23 +58,23 @@ check-all: check
4758
4859.PHONY : mypy
4960mypy : setup
50- uv run --python $( ACTIVEPYTHON ) mypy --config-file pyproject.toml ./
61+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " mypy --config-file pyproject.toml ./
5162
5263.PHONY : check-mypy
5364check-mypy : mypy
5465
5566.PHONY : check-safety
5667check-safety : setup
57- uv run --python $( ACTIVEPYTHON ) safety check --full-report
58- uv run --python $( ACTIVEPYTHON ) bandit -ll --recursive stac_model tests
68+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " safety check --full-report
69+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " bandit -ll --recursive stac_model tests
5970
6071.PHONY : lint
6172lint : setup
62- uv run --python $( ACTIVEPYTHON ) ruff check --fix --config=pyproject.toml ./
73+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " ruff check --fix --config=pyproject.toml ./
6374
6475.PHONY : check-lint
6576check-lint : lint
66- uv run --python $( ACTIVEPYTHON ) ruff check --config=pyproject.toml ./
77+ $( UV_COMMAND ) run --python " $( UV_PYTHON_ROOT ) " ruff check --config=pyproject.toml ./
6778
6879.PHONY : format-lint
6980format-lint : lint
@@ -97,8 +108,8 @@ lint-all: lint mypy check-safety check-markdown
97108
98109.PHONY : update-dev-deps
99110update-dev-deps : setup
100- uv export --only-dev --format requirements-txt -o requirements-only-dev.txt
101- uv pip install --python $( ACTIVEPYTHON ) -r requirements-only-dev.txt
111+ $( UV_COMMAND ) export --only-dev --format requirements-txt -o requirements-only-dev.txt
112+ $( UV_COMMAND ) pip install --python " $( UV_PYTHON_ROOT ) " -r requirements-only-dev.txt
102113
103114# * Cleaning
104115.PHONY : pycache-remove
0 commit comments