Debian Codegraph @

justfile

raw
1 set dotenv-load := true
2
3 sphinx-sphinxbuild := "sphinx-build"
4 sphinx-sphinxopts := ""
5 sphinx-sourcedir := "docs"
6 sphinx-builddir := "_build"
7
8 # By default, run checks and tests, then format and lint
9 default:
10 if [ ! -d venv ]; then just install; fi
11 @just format
12 @just check
13 @just test
14 @just lint
15
16 #
17 # Installing, updating and upgrading dependencies
18 #
19
20 _venv:
21 if [ ! -d venv ]; then python3 -m venv venv; . ./venv/bin/activate && pip install pip pip-tools wheel; fi
22
23 _clean-venv:
24 rm -rf venv
25
26 # Install all dependencies
27 install:
28 @just _venv
29 @just compile
30 . ./venv/bin/activate && pip install -r requirements_dev.txt
31 . ./venv/bin/activate && pip install -e .
32
33 # Update all dependencies
34 update:
35 @just _venv
36 . ./venv/bin/activate && pip install pip pip-tools wheel --upgrade
37 @just _clean-compile
38 @just install
39
40 # Update all dependencies and rebuild the environment
41 upgrade:
42 if [ -d venv ]; then just update && just check && just _upgrade; else just update; fi
43
44 _upgrade:
45 @just _clean-venv
46 @just _venv
47 @just _clean-compile
48 @just compile
49 @just install
50
51 # Generate locked requirements files based on dependencies in pyproject.toml
52 compile:
53 . ./venv/bin/activate && python -m piptools compile --resolver=backtracking -o requirements.txt pyproject.toml --verbose
54 . ./venv/bin/activate && python -m piptools compile --resolver=backtracking --extra=dev -o requirements_dev.txt pyproject.toml --verbose
55
56 _clean-compile:
57 rm -f requirements.txt
58 rm -f requirements_dev.txt
59
60 #
61 # Development tooling - linting, formatting, etc
62 #
63
64 # Format with black and isort
65 format:
66 . ./venv/bin/activate && black ./docs './pyee' ./tests
67 . ./venv/bin/activate && isort --settings-file . ./docs './pyee' ./tests
68
69 # Lint with flake8
70 lint:
71 . ./venv/bin/activate && flake8 ./docs './pyee' ./tests
72 . ./venv/bin/activate && validate-pyproject ./pyproject.toml
73
74 # Check type annotations with pyright
75 check:
76 . ./venv/bin/activate && npx pyright@latest
77
78 # Check type annotations with mypy
79 mypy:
80 . ./venv/bin/activate && mypy .
81
82 # Run tests with pytest
83 test:
84 . ./venv/bin/activate && pytest ./tests
85 @just _clean-test
86
87 _clean-test:
88 rm -f pytest_runner-*.egg
89 rm -rf tests/__pycache__
90
91 # Run tests using tox
92 tox:
93 . ./venv/bin/activate && tox
94 @just _clean-tox
95
96 _clean-tox:
97 rm -rf .tox
98
99 #
100 # Shell and console
101 #
102
103 # Open a bash shell with the venv activated
104 shell:
105 . ./venv/bin/activate && bash
106
107 # Open a Jupyter console
108 console:
109 . ./venv/bin/activate && jupyter console
110
111 #
112 # Documentation
113 #
114
115 # Live generate docs and host on a development webserver
116 docs:
117 . ./venv/bin/activate && mkdocs serve
118
119 # Generate man page and open for preview
120 man: (sphinx 'man')
121 . ./venv/bin/activate && man -l _build/man/pyee.1
122
123 # Build the documentation
124 build-docs:
125 @just mkdocs
126 @just sphinx man
127
128 # Run mkdocs
129 mkdocs:
130 . ./venv/bin/activate && mkdocs build
131
132 # Run sphinx
133 sphinx TARGET:
134 . ./venv/bin/activate && {{ sphinx-sphinxbuild }} -M "{{ TARGET }}" "{{ sphinx-sourcedir }}" "{{ sphinx-builddir }}" {{ sphinx-sphinxopts }}
135
136 _clean-docs:
137 rm -rf site
138 rm -rf _build
139
140 #
141 # Package publishing
142 #
143
144 # Build the package
145 build:
146 . ./venv/bin/activate && python -m build
147
148 _clean-build:
149 rm -rf dist
150
151 # Tag the release in git
152 tag:
153 . ./venv/bin/activate && git tag -a "v$(python3 -c 'import toml; print(toml.load(open("pyproject.toml", "r"))["project"]["version"])')" -m "Release $(python3 -c 'import toml; print(toml.load(open("pyproject.toml", "r"))["project"]["version"])')"
154
155 # Upload built packages
156 upload:
157 . ./venv/bin/activate && twine upload dist/*
158
159 # Build the package and publish it to PyPI
160 publish: build upload
161
162 # Clean up loose files
163 clean: _clean-venv _clean-compile _clean-test _clean-tox _clean-docs
164 rm -rf pyee.egg-info
165 rm -f pyee/*.pyc
166 rm -rf pyee/__pycache__