-
Notifications
You must be signed in to change notification settings - Fork 3
/
make.ps1
119 lines (106 loc) · 2.22 KB
/
make.ps1
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
<#
.SYNOPSIS
Makefile
.DESCRIPTION
USAGE
.\make.ps1 <command>
COMMANDS
init install Python build tools
install-dev install local package in editable mode
update-deps update the dependencies
upgrade-deps upgrade the dependencies
lint run `pre-commit`, `black`, and `ruff`
test run `pytest`
build-dist run `python -m build`
clean delete generated content
help, -? show this help message
#>
param(
[Parameter(Position = 0)]
[ValidateSet("init", "install-dev", "update-deps", "upgrade-deps", "lint", "test", "build-dist", "clean", "help")]
[string]$Command
)
function Invoke-Help
{
Get-Help $PSCommandPath
}
function Invoke-Init
{
python -m pip install --upgrade pip wheel setuptools build
}
function Invoke-Install-Dev
{
python -m pip install --upgrade --editable ".[dev, tests, docs]"
}
function Invoke-Update-Deps
{
pip-compile --output-file requirements.txt --resolver=backtracking requirements.in
}
function Invoke-Upgrade-Deps
{
pre-commit autoupdate
pip-compile --output-file requirements.txt --resolver=backtracking --upgrade requirements.in
}
function Invoke-Lint
{
pre-commit run --all-files
python -m ruff --fix .
python -m ruff format .
python -m mypy --strict src/
}
function Invoke-Test
{
python -m pytest
}
function Invoke-Build-Dist
{
python -m pip install --upgrade build
python -m build
}
function Invoke-Clean
{
$folders = @("build", "dist")
foreach ($folder in $folders)
{
if (Test-Path $folder)
{
Write-Verbose "Deleting $folder"
Remove-Item $folder -Recurse -Force
}
}
}
switch ($Command)
{
"init" {
Invoke-Init
}
"install-dev" {
Invoke-Install-Dev
}
"lint" {
Invoke-Lint
}
"update-deps" {
Invoke-Update-Deps
}
"upgrade-deps" {
Invoke-Upgrade-Deps
}
"test" {
Invoke-Test
}
"build-dist" {
Invoke-Build-Dist
}
"clean" {
Invoke-Clean
}
"help" {
Invoke-Help
}
default
{
Invoke-Init
Invoke-Install-Dev
}
}