You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.4 KiB
57 lines
2.4 KiB
"""Install Godot 4.6.1 export templates and OpenXR vendors plugin v4.3.0."""
|
|
import zipfile
|
|
import os
|
|
import shutil
|
|
|
|
# 1. Install OpenXR vendors plugin v4.3.0
|
|
plugin_zip = r"C:\git\g1-teleop\build\godotopenxrvendors_v4.3.0.zip"
|
|
addons_dir = r"C:\git\g1-teleop\addons"
|
|
old_plugin = os.path.join(addons_dir, "godotopenxrvendors")
|
|
|
|
if os.path.exists(plugin_zip):
|
|
print(f"[1/2] Installing OpenXR vendors plugin v4.3.0...")
|
|
# Remove old plugin
|
|
if os.path.exists(old_plugin):
|
|
print(f" Removing old plugin at {old_plugin}")
|
|
shutil.rmtree(old_plugin)
|
|
# Extract new plugin - the zip contains addons/godotopenxrvendors/
|
|
with zipfile.ZipFile(plugin_zip, 'r') as z:
|
|
# List top-level to understand structure
|
|
names = z.namelist()
|
|
print(f" Zip contains {len(names)} files")
|
|
if names[0].startswith("addons/"):
|
|
# Extract directly to project root
|
|
z.extractall(r"C:\git\g1-teleop")
|
|
print(" Extracted to project root (addons/ prefix)")
|
|
else:
|
|
# Extract to addons dir
|
|
z.extractall(addons_dir)
|
|
print(f" Extracted to {addons_dir}")
|
|
print(" Done!")
|
|
else:
|
|
print(f"[1/2] Plugin zip not found: {plugin_zip}")
|
|
|
|
# 2. Install export templates
|
|
tpz_file = r"C:\Users\John\AppData\Roaming\Godot\export_templates\godot461_templates.tpz"
|
|
templates_dir = r"C:\Users\John\AppData\Roaming\Godot\export_templates\4.6.1.stable"
|
|
|
|
if os.path.exists(tpz_file):
|
|
print(f"[2/2] Installing export templates...")
|
|
os.makedirs(templates_dir, exist_ok=True)
|
|
with zipfile.ZipFile(tpz_file, 'r') as z:
|
|
names = z.namelist()
|
|
print(f" TPZ contains {len(names)} files")
|
|
# TPZ typically has templates/ prefix
|
|
for name in names:
|
|
if name.startswith("templates/") and not name.endswith("/"):
|
|
# Strip the templates/ prefix
|
|
dest_name = name[len("templates/"):]
|
|
dest_path = os.path.join(templates_dir, dest_name)
|
|
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
|
|
with z.open(name) as src, open(dest_path, 'wb') as dst:
|
|
shutil.copyfileobj(src, dst)
|
|
print(f" Extracted to {templates_dir}")
|
|
print(" Done!")
|
|
else:
|
|
print(f"[2/2] Export templates not yet downloaded: {tpz_file}")
|
|
print(" Run this script again after download completes.")
|