diff --git a/scripts/package.py b/scripts/package.py --- a/scripts/package.py +++ b/scripts/package.py @@ -8,14 +8,16 @@ import os import pathlib -macos_template = "isometric-park-fna/bin/isometric-park-template.app" -windows_template = "isometric-park-fna/bin/isometric-park-windows-template" +template_directory = pathlib.Path("PackageTemplates/") +macos_template = template_directory / "isometric-park-template.app" +windows_template = template_directory / "isometric-park-windows-template" sourcedir = "isometric-park-fna/bin/Release" +destination_directory = pathlib.Path("isometric-park-fna/bin/") def make_windows(suffix="new"): - new_name = windows_template[:-9] + "-" + suffix + new_name = destination_directory / (windows_template.name[:-9] + "-" + suffix) # shutil.rmtree(new_name) shutil.copytree(windows_template, new_name) @@ -34,7 +36,9 @@ shutil.move(pathlib.Path(new_name) / "isometric-park-fna.exe", pathlib.Path(new_name) / "isometric-park.exe") - with zipfile.ZipFile(new_name + ".zip", "w", + new_zip_name = new_name.parent / (new_name.name + ".zip") + + with zipfile.ZipFile(new_zip_name, "w", #Windows doesn't natively support other formats #(besides uncompressed) in my testing: compression=zipfile.ZIP_DEFLATED) as f: @@ -46,7 +50,7 @@ def make_macos(suffix="new"): - new_name = macos_template[:-4] + "-" + suffix + ".app" + "/" + new_name = destination_directory / (macos_template.name[:-4] + "-" + suffix + ".app" + "/") # shutil.rmtree(new_name) shutil.copytree(macos_template, new_name) @@ -54,7 +58,7 @@ for (dirpath, _dirname, files) in os.walk(sourcedir): for file in files: source = pathlib.Path(dirpath) / file - destination = pathlib.Path(new_name) / "Contents" / "Resources" / pathlib.Path(file) + destination = new_name / "Contents" / "Resources" / pathlib.Path(file) print(source, destination) @@ -69,12 +73,13 @@ def make_source(suffix="new"): - new_name = "isometric-park-fna/bin/isometric-park-source" + "-" + suffix + new_name = destination_directory / ("isometric-park-source" + "-" + suffix + + ".zip") with tempfile.TemporaryDirectory() as temp: print(subprocess.getoutput(f"hg clone . {temp}")) - with zipfile.ZipFile(new_name + ".zip", "w", + with zipfile.ZipFile(new_name, "w", #Windows doesn't natively support other formats #(besides uncompressed) in my testing: compression=zipfile.ZIP_DEFLATED) as f: @@ -82,7 +87,7 @@ for file in files: source = pathlib.Path(dirpath) / file print(os.path.relpath(source, temp)) - f.write(source, os.path.relpath(source, temp) ) + f.write(source, os.path.relpath(source, temp)) def main():