Skip to content

Commit aa89027

Browse files
Windows qol
1 parent f31daeb commit aa89027

File tree

2 files changed

+41
-29
lines changed

2 files changed

+41
-29
lines changed

Diff for: installer/exporter/Windows/build.bat

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
setlocal enabledelayedexpansion
33
setlocal
44

5+
where python >nul 2>&1
6+
IF %ERRORLEVEL% NEQ 0 (
7+
echo Python not found. Installing Python...
8+
curl -o python-installer.exe https://www.python.org/ftp/python/3.11.0/python-3.11.0-amd64.exe
9+
python-installer.exe /quiet InstallAllUsers=1 PrependPath=1
10+
del python-installer.exe
11+
)
12+
13+
python -m pip --version >nul 2>&1
14+
if %ERRORLEVEL% NEQ 0 (
15+
echo pip not found. Installing pip...
16+
python -m ensurepip
17+
python -m pip install --upgrade pip
18+
)
19+
20+
python -m pip install -r requirements.txt
21+
522
set "EXPORTER_SOURCE_DIR=..\..\..\exporter\SynthesisFusionAddin\"
623

724
mkdir tmp\synthesis.bundle\Contents\

Diff for: installer/exporter/Windows/installer.py

+24-29
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,49 @@
66
import ctypes
77

88

9-
def resource_path(relative_path):
9+
def getResourcePath(relativePath: str | os.PathLike[str]) -> None:
1010
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
11-
base_path = sys._MEIPASS
11+
basePath = sys._MEIPASS
1212
else:
13-
base_path = os.path.dirname(__file__)
13+
basePath = os.path.dirname(__file__)
1414

15-
return os.path.join(base_path, relative_path)
15+
return os.path.join(basePath, relativePath)
1616

1717

18-
def extract_file(resource_name, dest_folder):
19-
resource_full_path = resource_path(resource_name)
20-
if not os.path.exists(resource_full_path):
21-
raise FileNotFoundError(f"Resource '{resource_name}' not found.")
18+
def extractFile(resourceName: str | os.PathLike[str], destinationFolder: str | os.PathLike[str]) -> None:
19+
fullResourcePath = getResourcePath(resourceName)
20+
if not os.path.exists(fullResourcePath):
21+
raise FileNotFoundError(f"Resource '{resourceName}' not found.")
2222

23-
shutil.copy(resource_full_path, os.path.join(dest_folder, resource_name))
23+
shutil.copy(fullResourcePath, os.path.join(destinationFolder, resourceName))
2424

2525

26-
def move_folder(src_folder, dest_folder):
27-
if not os.path.exists(src_folder):
28-
print(f"Source folder '{src_folder}' does not exist.")
29-
return
26+
def move_folder(sourceFolder: str | os.PathLike[str], destinationFolder: str | os.PathLike[str]) -> None:
27+
if not os.path.exists(sourceFolder):
28+
raise FileNotFoundError(f"Source folder '{sourceFolder}' not found.")
3029

31-
if not os.path.exists(dest_folder):
32-
print(f"Destination folder '{dest_folder}' does not exist. Creating it.")
33-
os.makedirs(dest_folder)
34-
35-
dest_path = os.path.join(dest_folder, os.path.basename(src_folder))
30+
dest_path = os.path.join(destinationFolder, os.path.basename(sourceFolder))
3631
if os.path.exists(dest_path):
3732
print("Path exists, removing it...")
3833
shutil.rmtree(dest_path)
3934

40-
shutil.move(src_folder, dest_folder)
41-
print(f"Successfully moved '{src_folder}' to '{dest_folder}'.")
35+
shutil.move(sourceFolder, destinationFolder)
36+
print(f"Successfully moved '{sourceFolder}' to '{destinationFolder}'.")
4237

4338

44-
def main():
39+
def main() -> None:
4540
if not ctypes.windll.shell32.IsUserAnAdmin():
4641
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
4742

48-
destination_folder = os.path.expandvars(r"%appdata%\Autodesk\ApplicationPlugins")
49-
os.makedirs(destination_folder, exist_ok=True)
50-
with tempfile.TemporaryDirectory() as temp_dir:
51-
extract_file("SynthesisExporter.zip", temp_dir)
52-
with zipfile.ZipFile(os.path.join(temp_dir, "SynthesisExporter.zip"), "r") as zip_ref:
53-
zip_ref.extractall(temp_dir)
43+
destinationFolder = os.path.expandvars(r"%appdata%\Autodesk\ApplicationPlugins")
44+
os.makedirs(destinationFolder, exist_ok=True)
45+
with tempfile.TemporaryDirectory() as tempDir:
46+
extractFile("SynthesisExporter.zip", tempDir)
47+
with zipfile.ZipFile(os.path.join(tempDir, "SynthesisExporter.zip"), "r") as zip:
48+
zip.extractall(tempDir)
5449

55-
src_folder = os.path.join(temp_dir, "synthesis.bundle")
56-
move_folder(src_folder, destination_folder)
50+
sourceFolder = os.path.join(tempDir, "synthesis.bundle")
51+
move_folder(sourceFolder, destinationFolder)
5752

5853

5954
if __name__ == "__main__":

0 commit comments

Comments
 (0)