forked from espressif/idf-python-wheels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild-Wheels.ps1
74 lines (61 loc) · 2.42 KB
/
Build-Wheels.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
#!/usr/bin/env pwsh
param (
[string]$Branch="main",
[string]$Python="python3",
[string]$Arch="",
[string[]]$CompileWheels=@(),
[switch]$NoReq=$false
)
"Using Python: $Python"
$env:IDF_PATH=(Get-Location).Path
$BranchNum = ($Branch -replace "\D+[^0-9][^0-9]" , '')
if ($BranchNum -eq "") {
$BranchNum = "5.1" # master
}
if ($BranchNum -ge "5.0") {
$RequirementsUrl="https://dl.espressif.com/dl/esp-idf/espidf.constraints.v${BranchNum}.txt"
} else {
$RequirementsUrl="https://raw.githubusercontent.com/espressif/esp-idf/${Branch}/requirements.txt"
}
$FileBranch = ${Branch}.Replace('/', '_')
$RequirementsTxt="requirements-${FileBranch}.txt"
$OnlyBinary = ""
"Processing: $RequirementsUrl"
Invoke-WebRequest $RequirementsUrl -OutFile $RequirementsTxt
# Iterate over binaries which should be compiled.
# The build of next binary will receive list of previously build of binaries to avoid download
foreach ($wheelPrefix in $CompileWheels) {
$wheel=Get-Content $RequirementsTxt | % { if($_ -match "^$wheelPrefix") {$_}}
# If wheel is not defined in requirements.txt use the prefix as name
if ("$wheel" -eq "") {
$wheel = $wheelPrefix
}
if ($wheel.startswith('windows-curses')) {
$wheel = "windows-curses"
}
"Processing: $wheel"
# Split by default splits on each space, so empty args are passed as
# requirements to pip-wheel, which complains with
# ERROR: Invalid requirement: ''
# " ".Split() vs. " ".split() | where {$_}
$OnlyBinarySplitted = $OnlyBinary.Split(' ') | where {$_}
if ("$Arch" -eq "") {
&$Python -m pip wheel --find-links download --wheel-dir download $OnlyBinarySplitted $wheel
} else {
arch $Arch $Python -m pip wheel --find-links download --wheel-dir download $OnlyBinarySplitted $wheel
}
#$cache=pip cache dir
#Get-ChildItem -Path $cache "{$wheel}*.whl" -Recurse | % {Copy-Item -Path $_.FullName -Destination download -Container }
#ls download
$OnlyBinary += " --only-binary $wheel"
}
if ($NoReq) {
exit
}
$OnlyBinarySplitted = $OnlyBinary.Split(' ') | where {$_}
if ("$Arch" -eq "") {
&$Python -m pip download $OnlyBinarySplitted --find-links download --dest download -r $RequirementsTxt
} else {
arch $Arch $Python -m pip download $OnlyBinarySplitted --find-links download --dest download -r $RequirementsTxt
}
&$Python -m pip wheel --wheel-dir download --find-links download -r $RequirementsTxt