-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathjustfile
162 lines (126 loc) · 3.64 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
set dotenv-load := true
sphinx-sphinxbuild := "sphinx-build"
sphinx-sphinxopts := ""
sphinx-sourcedir := "docs"
sphinx-builddir := "_build"
# By default, run checks and tests, then format and lint
default:
if [ ! -d venv ]; then just install; fi
@just format
@just check
@just test
@just lint
#
# Installing, updating and upgrading dependencies
#
_venv:
if [ ! -d venv ]; then python3 -m venv venv; . ./venv/bin/activate && pip install pip pip-tools wheel; fi
_clean-venv:
rm -rf venv
# Install all dependencies
install:
@just _venv
@just compile
. ./venv/bin/activate && pip install -r requirements_dev.txt
. ./venv/bin/activate && pip install -e .
# Update all dependencies
update:
@just _venv
. ./venv/bin/activate && pip install pip pip-tools wheel --upgrade
@just _clean-compile
@just install
# Update all dependencies and rebuild the environment
upgrade:
if [ -d venv ]; then just update && just check && just _upgrade; else just update; fi
_upgrade:
@just _clean-venv
@just _venv
@just _clean-compile
@just compile
@just install
# Generate locked requirements files based on dependencies in pyproject.toml
compile:
. ./venv/bin/activate && python -m piptools compile --resolver=backtracking -o requirements.txt pyproject.toml --verbose
. ./venv/bin/activate && python -m piptools compile --resolver=backtracking --extra=dev -o requirements_dev.txt pyproject.toml --verbose
_clean-compile:
rm -f requirements.txt
rm -f requirements_dev.txt
#
# Development tooling - linting, formatting, etc
#
# Format with black and isort
format:
. ./venv/bin/activate && black ./docs './pyee' ./tests
. ./venv/bin/activate && isort --settings-file . ./docs './pyee' ./tests
# Lint with flake8
lint:
. ./venv/bin/activate && flake8 ./docs './pyee' ./tests
. ./venv/bin/activate && validate-pyproject ./pyproject.toml
# Check type annotations with pyright
check:
. ./venv/bin/activate && npx pyright@latest
# Run tests with pytest
test:
. ./venv/bin/activate && pytest ./tests
@just _clean-test
_clean-test:
rm -f pytest_runner-*.egg
rm -rf tests/__pycache__
# Run tests using tox
tox:
. ./venv/bin/activate && tox
@just _clean-tox
_clean-tox:
rm -rf .tox
#
# Shell and console
#
# Open a bash shell with the venv activated
shell:
. ./venv/bin/activate && bash
# Open a Jupyter console
console:
. ./venv/bin/activate && jupyter console
#
# Documentation
#
# Live generate docs and host on a development webserver
docs:
. ./venv/bin/activate && mkdocs serve
# Generate man page and open for preview
man: (sphinx 'man')
. ./venv/bin/activate && man -l _build/man/pyee.1
# Build the documentation
build-docs:
@just mkdocs
@just sphinx man
# Run mkdocs
mkdocs:
. ./venv/bin/activate && mkdocs build
# Run sphinx
sphinx TARGET:
. ./venv/bin/activate && {{ sphinx-sphinxbuild }} -M "{{ TARGET }}" "{{ sphinx-sourcedir }}" "{{ sphinx-builddir }}" {{ sphinx-sphinxopts }}
_clean-docs:
rm -rf site
rm -rf _build
#
# Package publishing
#
# Build the package
build:
. ./venv/bin/activate && python -m build
_clean-build:
rm -rf dist
# Tag the release in git
tag:
. ./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"])')"
# Upload built packages
upload:
. ./venv/bin/activate && twine upload dist/*
# Build the package and publish it to PyPI
publish: build upload
# Clean up loose files
clean: _clean-venv _clean-compile _clean-test _clean-tox _clean-docs
rm -rf pyee.egg-info
rm -f pyee/*.pyc
rm -rf pyee/__pycache__