-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathjustfile
More file actions
99 lines (83 loc) · 4.26 KB
/
justfile
File metadata and controls
99 lines (83 loc) · 4.26 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
mod common '../common.justfile'
USE_UV := env("USE_UV", "false")
VENV_BIN := ".venv/bin/"
PYTHON := VENV_BIN + "python3"
PIP := if USE_UV == "true" { "uv pip" } else { VENV_BIN + "pip" }
_default:
@just --list
# Install Python dependencies via virtualenv. This is not required for development, but can be used to set up a clean environment for testing.
[arg('module_resolution', pattern='|--resolution=lowest-direct')]
[group("install")]
install module_resolution="": install-venv (install-dependencies "dev,test,examples" module_resolution)
install-uv:
#!/bin/sh
if [ -x "$(command -v uv)" ]; then
echo "uv is already installed"
exit 0
fi
echo "Installing uv..."
python -m pip install --upgrade pip
python -m pip install uv
_venv-is-installed:
@test -d {{ VENV_BIN }} \
|| (echo "Virtual environment not found. Please run 'just python install-venv' to create a virtual environment." && exit 1)
# Create or replace a virtual environment in the .venv directory.
[arg('python-version', long='python')]
[group("install")]
install-venv python-version="": common::_clear
rm -rf .venv
{{ if USE_UV == "true" { "uv venv .venv" } else { "python3 -m venv .venv" } }} {{ if python-version == "" { "" } else { "--python " + python-version } }}
@-echo "To activate the virtual environment, run: source .venv/bin/activate"
# Install dependencies for dev, test and examples. This is required for development and testing.
[arg('features', pattern='dev|test|examples|dev,test|dev,examples|test,examples|dev,test,examples')]
[arg('module_resolution', pattern='|--resolution=lowest-direct')]
[group("install")]
install-dependencies features module_resolution="": common::_clear _venv-is-installed
{{ PIP }} install {{ module_resolution }} -e ../api-clients/python --config-settings editable_mode=compat
{{ PIP }} install {{ module_resolution }} -e .[{{ features }}]
# Check if Python code is formatted correctly, check for linting errors and type errors.
[group("lint")]
lint: lint-code lint-tests
# Check if Python code is formatted correctly, check for linting errors and type errors.
[group("lint")]
lint-code: common::_clear _venv-is-installed
{{ PYTHON }} -m ruff format --check
{{ PYTHON }} -m ruff check
{{ PYTHON }} -m mypy geoengine
# Check if Python code is formatted correctly, check for linting errors and type errors.
[group("lint")]
lint-tests: common::_clear _venv-is-installed
{{ PYTHON }} -m mypy tests
# Build the Python package. The package is built in the dist directory.
[group("build")]
build: common::_clear _venv-is-installed
{{ PYTHON }} -m build
# Run all Python tests.
[arg("build-type", long="build-type", pattern="debug|release")]
[arg("coverage", long="coverage", value="--cov=geoengine --cov-report=lcov")]
[arg("test-code-path", long="test-code-path")]
[group("test")]
test filter="" test-code-path="../geoengine" build-type="debug" coverage="": common::_clear _venv-is-installed
GEOENGINE_TEST_CODE_PATH={{ test-code-path }} \
GEOENGINE_TEST_BUILD_TYPE={{ build-type }} \
{{ VENV_BIN }}pytest {{ coverage }} {{ if filter == "" { "" } else { "-k '" + filter + "'" } }}
# Run all examples in the examples directory.
[arg("build-type", long="build-type", pattern="debug|release")]
[arg("coverage", long="coverage", value="--cov=geoengine --cov-report=lcov")]
[arg("test-code-path", long="test-code-path")]
[group("test")]
run-examples test-code-path="../geoengine" build-type="debug" coverage="": common::_clear _venv-is-installed
. {{ VENV_BIN }}activate && \
GEOENGINE_TEST_CODE_PATH={{ test-code-path }} \
GEOENGINE_TEST_BUILD_TYPE={{ build-type }} \
{{ if coverage == "" { "" } else { 'COVERAGE_COMMAND="' + coverage + '"' } }} \
{{ PYTHON }} test_all_notebooks.py
format-code: common::_clear _venv-is-installed
{{ PYTHON }} -m ruff format
{{ PYTHON }} -m ruff check --fix
# Publish the Python client to PyPI. Usage: `just python publish`. Use the `--dry-run` flag to publish to TestPyPI instead.
[arg("dry-run", long="dry-run", value="true", help="Whether to publish to testpypi instead.")]
[group('publish')]
publish dry-run="false": common::_clear
python -m pip install --upgrade pip twine
python -m twine upload --repository {{ if dry-run == "true" { "testpypi" } else { "pypi" } }} dist/*