1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-25 20:22:39 +01:00

Fix godot download

This commit is contained in:
Elias Steurer 2023-11-16 09:41:11 +01:00
parent 6a9cda9df3
commit b72c9904b2
3 changed files with 33 additions and 25 deletions

View File

@ -37,20 +37,25 @@ VCPKG_BASE_PACKAGES = [
PYTHON_EXECUTABLE = "python" if sys.platform == "win32" else "python3" PYTHON_EXECUTABLE = "python" if sys.platform == "win32" else "python3"
FFMPEG_VERSION = "6.0" FFMPEG_VERSION = "6.0"
GODOT_VERSION = "4.2" GODOT_VERSION = "4.2"
GODOT_RELEASE_TYPE = "beta5" GODOT_RELEASE_TYPE = "beta6"
GODOT_DOWNLOAD_SERVER = "https://downloads.tuxfamily.org/godotengine" GODOT_DOWNLOAD_SERVER = "https://github.com/godotengine/godot-builds/releases/download"
if sys.platform == "win32": if sys.platform == "win32":
SCREENPLAYWALLPAPER_GODOT_EXECUTABLE = "ScreenPlayWallpaperGodot.exe" SCREENPLAYWALLPAPER_GODOT_EXECUTABLE = "ScreenPlayWallpaperGodot.exe"
GODOT_EDITOR_EXECUTABLE = f"Godot_v{GODOT_VERSION}-{GODOT_RELEASE_TYPE}_win64.exe" GODOT_EDITOR_EXECUTABLE = f"Godot_v{GODOT_VERSION}-{GODOT_RELEASE_TYPE}_win64.exe"
GODOT_EDITOR_DOWNLOAD_NAME = GODOT_EDITOR_EXECUTABLE + ".zip"
GODOT_TEMPLATES_PATH = os.path.join(os.getenv( GODOT_TEMPLATES_PATH = os.path.join(os.getenv(
'APPDATA'), f"Godot/templates/{GODOT_VERSION}.{GODOT_RELEASE_TYPE}") 'APPDATA'), f"Godot/templates/{GODOT_VERSION}.{GODOT_RELEASE_TYPE}")
elif sys.platform == "darwin": elif sys.platform == "darwin":
SCREENPLAYWALLPAPER_GODOT_EXECUTABLE = "ScreenPlayWallpaperGodot.app" SCREENPLAYWALLPAPER_GODOT_EXECUTABLE = "ScreenPlayWallpaperGodot.app"
GODOT_EDITOR_EXECUTABLE = f"Godot_v{GODOT_VERSION}-{GODOT_RELEASE_TYPE}_osx.universal" # Godot_v4.2-beta6_macos.universal.zip
GODOT_EDITOR_EXECUTABLE = "Godot.app"
GODOT_EDITOR_DOWNLOAD_NAME = f"Godot_v{GODOT_VERSION}-{GODOT_RELEASE_TYPE}_macos.universal.zip"
GODOT_TEMPLATES_PATH = "TODO" GODOT_TEMPLATES_PATH = "TODO"
elif sys.platform == "linux": elif sys.platform == "linux":
SCREENPLAYWALLPAPER_GODOT_EXECUTABLE = "ScreenPlayWallpaperGodot" SCREENPLAYWALLPAPER_GODOT_EXECUTABLE = "ScreenPlayWallpaperGodot"
GODOT_EDITOR_EXECUTABLE = f"Godot_v{GODOT_VERSION}-{GODOT_RELEASE_TYPE}_x11.64" # Godot_v4.2-beta6_linux.x86_64
GODOT_EDITOR_EXECUTABLE = f"Godot_v{GODOT_VERSION}-{GODOT_RELEASE_TYPE}_linux.x86_64"
GODOT_EDITOR_DOWNLOAD_NAME = GODOT_EDITOR_EXECUTABLE + ".zip"
# /home/eli/.local/share/godot/templates/ # /home/eli/.local/share/godot/templates/
GODOT_TEMPLATES_PATH = os.path.join( GODOT_TEMPLATES_PATH = os.path.join(
Path.home(), f".local/share/godot/templates/{GODOT_VERSION}.{GODOT_RELEASE_TYPE}") Path.home(), f".local/share/godot/templates/{GODOT_VERSION}.{GODOT_RELEASE_TYPE}")

View File

@ -117,7 +117,7 @@ def main():
vcpkg_path = project_source_parent_path.joinpath("vcpkg").resolve() vcpkg_path = project_source_parent_path.joinpath("vcpkg").resolve()
vcpkg_packages_list = defines.VCPKG_BASE_PACKAGES vcpkg_packages_list = defines.VCPKG_BASE_PACKAGES
if system() == "Windows" and args.setup_godot: if system() != "Darwin" and args.setup_godot:
if not setup_godot.execute(): if not setup_godot.execute():
raise RuntimeError("Unable to download godot") raise RuntimeError("Unable to download godot")

View File

@ -8,19 +8,22 @@ from pathlib import Path
import defines import defines
import util import util
def download_godot(version: str, exe_zip_filename: str, export_templates: str, download_destination_path: str) -> bool: def download_godot(exe_zip_filename: str, export_templates: str, download_destination_path: str) -> bool:
# https://downloads.tuxfamily.org/godotengine/4.2/beta4/Godot_v4.2-beta4_win64.exe.zip # https://github.com/godotengine/godot-builds/releases/download/4.2-beta6/Godot_v4.2-beta6_win64.exe.zip
# https://downloads.tuxfamily.org/godotengine/4.2/Godot_v4.2-beta4_win64.exe.zip subfolder = f"{defines.GODOT_VERSION}-{defines.GODOT_RELEASE_TYPE}"
download_export_templates = f"{defines.GODOT_DOWNLOAD_SERVER}/{version}/{defines.GODOT_RELEASE_TYPE}/{export_templates}" base_url = f"{defines.GODOT_DOWNLOAD_SERVER}/{subfolder}"
download_export_templates = f"{base_url}/{export_templates}"
exe_destination_filepath = os.path.join( exe_destination_filepath = os.path.join(
download_destination_path, exe_zip_filename) download_destination_path, exe_zip_filename)
export_templates_destination_path = os.path.join( export_templates_destination_path = os.path.join(
download_destination_path, export_templates) download_destination_path, export_templates)
# Godot adds ".stable" to the folder names for full releases: "AppData/Roaming/Godot/templates/3.4.stable": # Godot adds ".stable" to the folder names for full releases: "AppData/Roaming/Godot/templates/4.2.stable":
print(f"Downloading Godot from {defines.GODOT_DOWNLOAD_SERVER}/") download_editor = f"{base_url}/{exe_zip_filename}"
download_link = f"{defines.GODOT_DOWNLOAD_SERVER}/{version}/{defines.GODOT_RELEASE_TYPE}/{exe_zip_filename}" print(f"⬇️ Downloading Godot editor {download_editor}")
util.download(download_link, exe_destination_filepath, False) util.download(download_editor, exe_destination_filepath, False)
print(f"⬇️ Downloading Godot export templates {download_export_templates}")
util.download(download_export_templates, util.download(download_export_templates,
export_templates_destination_path, False) export_templates_destination_path, False)
@ -28,7 +31,7 @@ def download_godot(version: str, exe_zip_filename: str, export_templates: str, d
def unzip_godot(exe_zip_filepath: str, export_templates_filepath: str, destination_path: str) -> bool: def unzip_godot(exe_zip_filepath: str, export_templates_filepath: str, destination_path: str) -> bool:
print("Unzip Godot") print("🪛 Unzip Godot")
util.unzip(exe_zip_filepath, destination_path) util.unzip(exe_zip_filepath, destination_path)
# The export templates contain a templates subfolder in which the content is. This is bad because it clashes # The export templates contain a templates subfolder in which the content is. This is bad because it clashes
@ -38,10 +41,10 @@ def unzip_godot(exe_zip_filepath: str, export_templates_filepath: str, destinati
godot_templates_dir = "" godot_templates_dir = ""
if sys.platform == "win32": if sys.platform == "win32":
godot_templates_dir = os.path.join( godot_templates_dir = os.path.join(
os.getenv('APPDATA'), "Godot/templates/") os.getenv('APPDATA'), "Godot/templates")
elif sys.platform == "linux": elif sys.platform == "linux":
godot_templates_dir = os.path.join( godot_templates_dir = os.path.join(
str(Path.home()), ".local/share/godot/templates/") str(Path.home()), ".local/share/godot/templates")
os.makedirs(godot_templates_dir, exist_ok=True) os.makedirs(godot_templates_dir, exist_ok=True)
export_templates_destination_version = f"{godot_templates_dir}/{defines.GODOT_VERSION}.{defines.GODOT_RELEASE_TYPE}" export_templates_destination_version = f"{godot_templates_dir}/{defines.GODOT_VERSION}.{defines.GODOT_RELEASE_TYPE}"
@ -54,14 +57,14 @@ def unzip_godot(exe_zip_filepath: str, export_templates_filepath: str, destinati
os.rename(os.path.join(godot_templates_dir, "templates"), os.rename(os.path.join(godot_templates_dir, "templates"),
export_templates_destination_version) export_templates_destination_version)
print(f"Remove {exe_zip_filepath}") print(f"🚮 Remove {exe_zip_filepath}")
try: try:
os.remove(exe_zip_filepath) os.remove(exe_zip_filepath)
except OSError as error: except OSError as error:
print(f"Error deleting file: {error}") print(f"Error deleting file: {error}")
return False return False
print(f"Remove {export_templates_filepath}") print(f"🚮 Remove {export_templates_filepath}")
try: try:
os.remove(export_templates_filepath) os.remove(export_templates_filepath)
except OSError as error: except OSError as error:
@ -72,22 +75,22 @@ def unzip_godot(exe_zip_filepath: str, export_templates_filepath: str, destinati
def setup_godot() -> bool: def setup_godot() -> bool:
print(f"Set up GODOT version {defines.GODOT_VERSION} {defines.GODOT_RELEASE_TYPE}") print(f"🚀 Set up GODOT version {defines.GODOT_VERSION} {defines.GODOT_RELEASE_TYPE}")
destination_path = os.path.join(defines.THIRDPATH_PATH, "Godot") destination_path = os.path.join(defines.THIRDPATH_PATH, "Godot")
export_templates = f"Godot_v{defines.GODOT_VERSION}-{defines.GODOT_RELEASE_TYPE}_export_templates.tpz" export_templates = f"Godot_v{defines.GODOT_VERSION}-{defines.GODOT_RELEASE_TYPE}_export_templates.tpz"
export_templates_filepath = os.path.join( export_templates_filepath = os.path.join(
destination_path, export_templates) destination_path, export_templates)
exe_zip_filename = defines.GODOT_EDITOR_EXECUTABLE + '.zip' exe_zip_filepath = os.path.join(destination_path, defines.GODOT_EDITOR_DOWNLOAD_NAME)
exe_zip_filepath = os.path.join(destination_path, exe_zip_filename) download_godot( defines.GODOT_EDITOR_DOWNLOAD_NAME,
download_godot(defines.GODOT_VERSION, exe_zip_filename,
export_templates, destination_path) export_templates, destination_path)
if not unzip_godot(exe_zip_filepath, export_templates_filepath, destination_path): if not unzip_godot(exe_zip_filepath, export_templates_filepath, destination_path):
return False return False
# Linux needs to change file permission to be able to run godot # Linux needs to change file permission to be able to run godot
if sys.platform == "linux": if sys.platform == "linux":
execute(f"chmod +x {defines.GODOT_EDITOR_EXECUTABLE}", command = f"chmod +x {defines.GODOT_EDITOR_EXECUTABLE}"
destination_path, False) print(f"Make editor executable: {command} at {destination_path}")
util.run(command,destination_path)
return True return True