-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.ps1
129 lines (116 loc) · 2.99 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
120
121
122
123
124
125
126
127
128
129
<#
.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` and `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
{
python -m pip install --upgrade --editable ".[dev, tests, docs]"
python -m pip install --upgrade pip-tools
cd requirements
pip-compile --resolver=backtracking requirements.in --output-file requirements.txt
pip-compile --resolver=backtracking requirements-dev.in --output-file requirements-dev.txt
pip-compile --resolver=backtracking requirements-tests.in --output-file requirements-tests.txt
pip-compile --resolver=backtracking requirements-docs.in --output-file requirements-docs.txt
}
function Invoke-Upgrade-Deps
{
python -m pip install --upgrade pip-tools pre-commit
pre-commit autoupdate
cd requirements
pip-compile --resolver=backtracking --upgrade requirements.in --output-file requirements.txt
pip-compile --resolver=backtracking --upgrade requirements-dev.in --output-file requirements-dev.txt
pip-compile --resolver=backtracking --upgrade requirements-tests.in --output-file requirements-tests.txt
pip-compile --resolver=backtracking --upgrade requirements-docs.in --output-file requirements-docs.txt
}
function Invoke-Lint
{
pre-commit run --all-files
python -m black .
python -m ruff --fix .
}
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
}
}