Skip to content

Commit e53990e

Browse files
Finish script
This script can now download, extract, build, and set environment variables, Linted whole document with autopep8. Added README with instructions to use script.
1 parent 5fbdd8a commit e53990e

File tree

2 files changed

+95
-3
lines changed

2 files changed

+95
-3
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
# wxWidgetsInstallScript
2+
3+
A small Python script to install wxWidgets 3.2.1 and build automatically.
4+
5+
Tested on Windows 10/11 with Visual Studio 2022 (17)
6+
7+
## Requirements
8+
9+
- Visual Studio with Desktop C++ installed
10+
- Python 3
11+
- Internet connection
12+
13+
## What does this script do?
14+
15+
This script downloads a specific release of wxWidgets and builds from that source and sets environment variables on the whole system.
16+
17+
Current configurations and architectures built are:
18+
19+
- Debug x64
20+
- Debug Win32
21+
- Release x64
22+
- Release Win32
23+
24+
## Steps to run
25+
26+
- Clone or download `setup.py`
27+
- Open an **administrative** Visual Studio PowerShell or Command Prompt
28+
- You may need to go to the Start Menu > Visual Studio (`Version`) > Developer ... > Right-click and Run as Administrator
29+
- `cd` to your downloaded `setup.py` file
30+
- `python .\setup.py`

setup.py

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,73 @@
1+
import ctypes
12
import urllib.request
23
import os
4+
import shutil
5+
6+
# Variables
7+
url = "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.1/wxWidgets-3.2.1.zip"
8+
filename = "wxWidgets-3.2.1.zip"
9+
finalpath = "C:\\wxWidgets-3.2.1"
10+
311

412
def main():
5-
url = "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.1/wxWidgets-3.2.1.zip"
6-
filename = "wxWidgets-3.2.1.zip"
13+
# Main
14+
downloadWxWidgets()
15+
extractWxWidgets()
16+
buildWxWidgets()
17+
setEnvironmentVariables()
18+
19+
20+
def downloadWxWidgets():
21+
# Download wxWidgets
22+
23+
print("[-] Downloading wxWidgets...")
724
urllib.request.urlretrieve(url, filename)
25+
print("[-] Download complete!")
26+
27+
28+
def extractWxWidgets():
29+
# Extract wxWidgets
30+
print("[-] Extracting wxWidgets...")
31+
shutil.unpack_archive(filename, finalpath)
32+
shutil.move(os.getcwd() + f"\\{filename}", f"{finalpath}.zip")
33+
print("[-] Extraction complete!")
34+
35+
36+
def buildWxWidgets():
37+
# Build wxWidgets
38+
# This is a bit of a hack, but it works
39+
print("[-] Building wxWidgets...")
40+
os.chdir(f"{finalpath}\\build\\msw")
41+
print("[-] Building wxWidgets Debug (x64)...")
42+
os.system("msbuild wx_vc17.sln /p:Configuration=Debug /p:Platform=x64")
43+
print("[-] Building wxWidgets Release (x64)...")
44+
os.system("msbuild wx_vc17.sln /p:Configuration=Release /p:Platform=x64")
45+
print("[-] Building wxWidgets Debug (Win32)...")
46+
os.system("msbuild wx_vc17.sln /p:Configuration=Debug /p:Platform=Win32")
47+
print("[-] Building wxWidgets Release (Win32)...")
48+
os.system("msbuild wx_vc17.sln /p:Configuration=Release /p:Platform=Win32")
49+
print("[-] Build complete!")
50+
51+
52+
def setEnvironmentVariables():
53+
# Set environment variables
54+
print("[-] Setting environment variables...")
55+
os.system(f"setx WXWIN \"{finalpath}\" /M")
56+
print("[-] Environment variables set!")
57+
58+
59+
def checkAdmin():
60+
# Check if running as admin
61+
try:
62+
return ctypes.windll.shell32.IsUserAnAdmin()
63+
except Exception:
64+
return False
65+
866

967
if __name__ == "__main__":
10-
main()
68+
print("[-] Checking for admin privileges...")
69+
if checkAdmin():
70+
main()
71+
else:
72+
print("[!] Please run as admin")
73+
exit(0)

0 commit comments

Comments
 (0)