-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.ps1
40 lines (31 loc) · 1.14 KB
/
build.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
function Is-Admin() {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function main() {
if (-not (Is-Admin)) {
Write-Host "error: administrator privileges required"
return 1
}
if (Test-Path ".\build\") {
Remove-Item -Path ".\build\" -Recurse -Force
}
mkdir ".\build\"
# entrypoint relative to .\build\pyinstaller\
$entryPoint = "..\..\AutoGpuAffinity\main.py"
# create folder structure
mkdir ".\build\AutoGpuAffinity\"
# pack executable
mkdir ".\build\pyinstaller\"
Push-Location ".\build\pyinstaller\"
pyinstaller $entryPoint --onefile --name AutoGpuAffinity
Pop-Location
# create final package
Copy-Item ".\build\pyinstaller\dist\AutoGpuAffinity.exe" ".\build\AutoGpuAffinity\"
Copy-Item ".\AutoGpuAffinity\bin\" ".\build\AutoGpuAffinity\" -Recurse
Copy-Item ".\AutoGpuAffinity\config.ini" ".\build\AutoGpuAffinity\"
return 0
}
$_exitCode = main
Write-Host # new line
exit $_exitCode