generated from Justintime50/python-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
justfile
94 lines (71 loc) · 2.68 KB
/
justfile
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
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
# To use a specific Python interpreter, set the `python` variable to the path of the interpreter,
# e.g. "just --set python /usr/bin/python3.11 variables"
python := "python"
# The OS name is appended to the venv dir
# in case you're developing in an environment that exposes this directory
# to multiple OSes (e.g. WSL)
venv := "venv-" + os()
_venv_bin := if os_family() == "windows" { venv / "Scripts" } else { venv / "bin" }
# List all available recipes.
list:
@{{just_executable()}} --list
# List all variables that can be used to configure the recipes. (_leading_underscores are private)
vars:
@{{just_executable()}} --evaluate
# Show the help for just itself
help:
@{{just_executable()}} --help
# Scans the project for security vulnerabilities
bandit: _validate_venv
{{_venv_bin}}/bandit -c pyproject.toml -r src
# Builds the project in preparation for release
build: install
{{_venv_bin}}/python -m build
# Runs the Black Python formatter against the project
black: _validate_venv
{{_venv_bin}}/black src docs setup.py
# Checks if the project is formatted correctly against the Black rules
black-check: _validate_venv
{{_venv_bin}}/black src docs setup.py --check
# Cleans the project
clean:
git clean -xdf
# Run flake8 checks against the project
flake8: _validate_venv
{{_venv_bin}}/flake8 src
# Lints the project
lint: black-check isort-check flake8 mypy bandit
# Runs all formatting tools against the project
lint-fix: black isort
# Install the project locally and install all dependencies
install: venv
{{_venv_bin}}/pip install --editable ".[all]"
{{_venv_bin}}/pre-commit install
# Sorts imports throughout the project
isort: _validate_venv
{{_venv_bin}}/isort src
# Checks that imports throughout the project are sorted correctly
isort-check: _validate_venv
{{_venv_bin}}/isort src --check-only
# Run mypy type checking on the project
mypy: _validate_venv
{{_venv_bin}}/mypy src
# Generate the documentation and serve it locally. View it in a web browser.
serve-docs: _validate_venv
{{_venv_bin}}/sphinx-autobuild --jobs auto --ignore "./docs/api/*" --builder dirhtml --keep-going --watch src docs build/doc
[private]
[windows]
_validate_venv:
@if (-Not (Test-Path {{venv}})) { throw "Virtual environment not found. Run `just install` to create it." }
[private]
[unix]
_validate_venv:
@[ -d {{venv}} ] || { echo "Virtual environment not found. Run 'just install' to create it."; exit 1; }
# Create a virtual environment if necessary
[windows]
venv:
if (-Not (Test-Path {{venv}})) { {{python}} -m venv {{venv}} }
[unix]
venv:
[ -d {{venv}} ] || {{python}} -m venv {{venv}}