-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.ps1
115 lines (94 loc) · 3.76 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
#!/usr/bin/env pwsh
# You have been bamboozled.
# This is not a real make file, but rather
# a build/install script written in powershell
$helptext = "Help menu for PyZ's make script
Commands
- build: Builds the program and nothing else
- install: Builds the program and installs it to %USERPROFILE%\Appdata\PyZ
- update: Updates the program
- installdeps: Installs dependencies
- all: Installs all dependencies
- dev: Installs dependencies only required for development/compiling
- runtime: Installs dependencies only required for runtime
- help: Shows this help menu
"
function installPython() {
if ("$(wmic os get osarchitecture)" -like '*64*' ) {
Invoke-WebRequest "https://www.python.org/ftp/python/3.10.4/python-3.10.4-amd64.exe" -OutFile "$Env:Temp\pythoninstaller.exe"
Invoke-Expression -Command "$Env:Temp\pythoninstaller.exe"
} else {
Invoke-WebRequest "https://www.python.org/ftp/python/3.10.4/python-3.10.4.exe" -OutFile "$Env:Temp\pythoninstaller.exe"
Invoke-Expression -Command "$Env:Temp\pythoninstaller.exe"
}
}
function makeShortcut () {
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($args[0])
$Shortcut.TargetPath = $args[1]
$Shortcut.Save()
}
function help () {
Write-Host "$helptext"
}
function build () {
mkdir -p bin\Windows
Set-Location bin\Windows
pyinstaller --onefile ..\..\src\main.py ..\..\src\shell\shell.py ..\..\src\shell\rccreator.py ..\..\src\pluginmgr\manager.py ..\..\src\shell\pluginimport.py ..\..\src\pluginmgr\installer.py ..\..\src\pluginmgr\mgrinit.py ..\..\src\pluginmgr\remover.py ..\..\src\pluginmgr\searcher.py ..\..\src\pluginmgr\updater.py ..\..\src\pyziniter\__init__.py ..\..\src\pyziniter\pyzinit.py ..\..\src\pyziniter\verJSONcreate.py ..\..\src\api\__init__.py ..\..\src\api\pyzprompt.py ..\..\src\api\pyzshell.py
Set-Location -Path dist
Rename-Item -Path main.exe pyz.exe
Move-Item -Path .\pyz.exe -Destination ..\pyz.exe
Set-Location -Path ..
Remove-Item -Confirm build
Remove-Item dist
Remove-Item main.spec
}
function install () {
build
New-Item -Path "$Env:USERPROFILE\AppData\Roaming" -Name "PyZ" -ItemType "directory"
Move-Item -Path .\pyz.exe -Destination "$Env:USERPROFILE\AppData\Roaming\PyZ\pyz.exe"
Copy-File -Path ..\..\version.json -Destination "$Env:USERPROFILE\AppData\Roaming\PyZ\version.json"
$Env:PATH += ";$Env:USERPROFILE\AppData\Roaming\PyZ"
makeShortcut "$Env:AppData\Microsoft\Windows\Start Menu\Programs\PyZ.lnk" "$Env:USERPROFILE\AppData\Roaming\PyZ\pyz.exe"
}
function update () {
build
Remove-Item -Path "$Env:AppData\PyZ\pyz.exe"
Copy-Item -Path ".\pyz.exe" -Destination "$Env:AppData\PyZ\pyz.exe"
Invoke-WebRequest "https://raw.githubusercontent.com/CodyMarkix/PyZ-shell/master/version.json" -OutFile "$Env:AppData\PyZ\version.json"
}
function uninstall () {
Remove-Item -Path "$Env:AppData\PyZ"
Remove-Item -Path "$Env:AppData\Microsoft\Windows\Start Menu\Programs\PyZ.lnk"
Write-Host "Uninstalled!"
# If anyone knows how to remove a path from PATH, lmk please
}
function installdeps () {
if ($args[0] -eq "all") {
installPython
pip install termcolor
pip install pyinstaller
} elseif ($args[0] -eq "dev") {
installPython
pip install pyinstaller
} elseif ($args[0] -eq "runtime") {
installPython
pip install termcolor
pip install pynput
}
}
if ($args[0] -eq "help") {
help
} elseif ($args[0] -eq "build") {
build
} elseif ($args[0] -eq "install") {
install
} elseif ($args[0] -eq "installdeps") {
installdeps $args[1]
} elseif ($args[0] -eq "uninstall") {
uninstall
} elseif ($args[0] -eq "update") {
update
} else {
help
}