-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
68 lines (49 loc) · 2.09 KB
/
justfile
File metadata and controls
68 lines (49 loc) · 2.09 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
set shell := ["bash", "-lc"]
set dotenv-load := true
set dotenv-filename := ".env"
set export := true
## Config
HERE := justfile_directory()
MARKER_DIR := HERE
VERSION := `awk -F\" '/^version/{print $2}' pyproject.toml`
PYTHON_VERSION := trim(read(".python-version"))
PYTHON_VERSIONS := `awk -F'[^0-9]+' '/requires-python/{for(i=$3;i<$5;)printf(i-$3?" ":"")$2"."i++}' pyproject.toml`
BUILD_WHEEL_FILE := `ls dist/study_utils-*.whl 2>/dev/null | head -n 1`
## Recipes
@environment:
env | sort
echo $TERMUX_ENV
@version:
echo "{{ VERSION }}"
@python-versions:
echo "Development Python version: {{ PYTHON_VERSION }}"
echo "Supported Python versions: {{ PYTHON_VERSIONS }}"
@setup-dev:
if [ "$TERMUX_ENV" == "true" ];\
then uv pip install --link-mode=copy -e .[dev]\
&& uv sync --link-mode=copy --extra dev;\
else uv pip install -e .[dev]\
&& uv sync --extra dev;\
fi
@build-clean:
rm -rf dist build
@build:
just build-clean
uv build
@install:
if [ -z "{{ BUILD_WHEEL_FILE }}" ]; then echo "No wheel found. Run 'just build' first."; exit 1; fi
if [ "$TERMUX_ENV" == "true" ];\
then uv pip install --link-mode=copy --force-reinstall {{BUILD_WHEEL_FILE }}\
&& just build-clean;\
else uv pip install --force-reinstall {{ BUILD_WHEEL_FILE }}\
&& just build-clean;\
fi
@uninstall:
uv pip uninstall study_utils
@set-version version:
python -c "import pathlib, re, sys; version='{{version}}'; version or sys.exit('Provide a version, e.g. `just set-version 0.2.0`.'); path = pathlib.Path('pyproject.toml'); text = path.read_text(); pattern = r'(?m)^version\\s*=\\s*\"[^\"]+\"'; re.search(pattern, text) or sys.exit('Could not find version field in pyproject.toml.'); new_text, count = re.subn(pattern, 'version = \"' + version + '\"', text, count=1); count == 1 or sys.exit('Expected to update exactly one version field.'); path.write_text(new_text); print('Updated project version to ' + version + '.')"
test:
uv run pytest
lint:
uv run ruff check --fix src tests
uv run ruff format src tests