-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
122 lines (102 loc) · 3.36 KB
/
setup.py
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
import ctypes
import urllib.request
import os
import shutil
import hashlib
import progressbar
import subprocess
import vswhere
# Variables
url = "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.3/wxWidgets-3.2.3.zip"
filename = "wxWidgets-3.2.3.zip"
finalpath = "C:\\wxWidgets-3.2.3"
checksum = "8ecc70034bf7d6ab8725114eb745404553cdf8dc"
pbar = None
configuration = [ "Debug", "Release" ]
platform = [ "x64", "Win32" ]
def main():
# Main
download_wxwidgets()
extract_wxwidgets()
build_wxwidgets()
set_environment_variables()
def show_progress(block_num, block_size, total_size):
# Progress bar
global pbar
if pbar is None:
pbar = progressbar.ProgressBar(maxval=total_size)
pbar.start()
downloaded = block_num * block_size
if downloaded < total_size:
pbar.update(downloaded)
else:
pbar.finish()
pbar = None
def download_wxwidgets():
# Download wxWidgets
print("[-] Downloading wxWidgets...")
urllib.request.urlretrieve(url, filename, show_progress)
print("[-] Download complete!")
print("[-] Checking checksum...")
if hashlib.sha1(open(filename, "rb").read()).hexdigest() == checksum:
print("[-] Checksum matches!")
else:
print("[!] Checksum does not match!")
exit(0)
def extract_wxwidgets():
# Extract wxWidgets
print("[-] Extracting wxWidgets...")
shutil.unpack_archive(filename, finalpath)
shutil.move(os.getcwd() + f"\\{filename}", f"{finalpath}.zip")
print("[-] Extraction complete!")
def build_wxwidgets():
# Build wxWidgets
msbuild_path = find_msbuild()
vsversion = determine_msbuild_vs_version()
print(msbuild_path)
print("[-] Building wxWidgets...")
os.chdir(f"{finalpath}\\build\\msw")
for config in configuration:
for plat in platform:
print(f"[-] Building wxWidgets {config} ({plat})...")
subprocess.run([msbuild_path, f"wx_vc{vsversion}.sln", f"/p:Configuration={config}", f"/p:Platform={plat}"])
print("[-] Build complete!")
def set_environment_variables():
# Set environment variables
print("[-] Setting environment variables...")
os.system(f"setx WXWIN \"{finalpath}\" /M")
print("[-] Environment variables set!")
def find_msbuild():
# Find msbuild.exe
print("[-] Finding msbuild.exe...")
vspath = vswhere.get_latest_path()
print(vspath)
if vspath is not None:
print("[-] Found msbuild.exe!")
return vspath + "\\MSBuild\\Current\\Bin\\msbuild.exe"
else:
print("[!] Could not find msbuild.exe!")
exit(0)
def determine_msbuild_vs_version():
# Determine which version of Visual Studio is installed
print("[-] Determining which version of Visual Studio is installed...")
vsversion = vswhere.get_latest_major_version()
if vsversion is not None:
print(f"[-] Visual Studio {vsversion} is installed!")
return vsversion
else:
print("[!] Could not determine which version of Visual Studio is installed!")
exit(1)
def check_admin():
# Check if running as admin
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except Exception:
return False
if __name__ == "__main__":
print("[-] Checking for admin privileges...")
if check_admin():
main()
else:
print("[!] Please run as admin")
exit(1)