diff --git a/scripts/package.py b/scripts/package.py --- a/scripts/package.py +++ b/scripts/package.py @@ -25,18 +25,21 @@ for (dirpath, _dirname, files) in os.walk(sourcedir): for file in files: source = pathlib.Path(dirpath) / file - destination = pathlib.Path(new_name) / os.path.relpath(sourcedir, dirpath) / pathlib.Path(file) + destination = pathlib.Path(new_name) / os.path.relpath(dirpath, sourcedir) / pathlib.Path(file) print(source, destination) - if source.parent.is_dir() and not destination.parent.exists(): - # shutil.copytree(source.parent, destination.parent) + os.makedirs(destination.parent, exist_ok=True) + if destination.parent.is_dir() and not destination.parent.exists(): os.mkdir(destination.parent) elif source.is_dir() and not destination.exists(): + print("Copying whole directory!") shutil.copytree(source, destination) else: shutil.copy2(source, destination) + print(pathlib.Path(new_name) / "isometric-park-fna.exe", + pathlib.Path(new_name) / "isometric-park.exe") shutil.move(pathlib.Path(new_name) / "isometric-park-fna.exe", pathlib.Path(new_name) / "isometric-park.exe") @@ -45,10 +48,11 @@ with zipfile.ZipFile(new_zip_name, "w", #May be able to use something better on Linux: compression=zipfile.ZIP_DEFLATED) as f: - for (dirpath, _dirname, files) in os.walk(sourcedir): + for (dirpath, _dirname, files) in os.walk(new_name): for file in files: source = pathlib.Path(dirpath) / file - f.write(source) + f.write(source, pathlib.Path(os.path.relpath(sourcedir, dirpath)) / os.path.relpath(dirpath, sourcedir) / pathlib.Path(file)) + # f.write(source, pathlib.Path(os.path.relpath(sourcedir, dirpath)) / os.path.relpath(dirpath, sourcedir) / pathlib.Path(file)) def make_windows(suffix="new"): @@ -59,10 +63,11 @@ for (dirpath, _dirname, files) in os.walk(sourcedir): for file in files: source = pathlib.Path(dirpath) / file - destination = pathlib.Path(new_name) / os.path.relpath(sourcedir, dirpath) / pathlib.Path(file) + destination = pathlib.Path(new_name) / os.path.relpath(dirpath, sourcedir) / pathlib.Path(file) print(source, destination) + os.makedirs(destination.parent, exist_ok=True) if source.parent.is_dir() and not destination.parent.exists(): # shutil.copytree(source.parent, destination.parent) os.mkdir(destination.parent) @@ -80,11 +85,10 @@ #Windows doesn't natively support other formats #(besides uncompressed) in my testing: compression=zipfile.ZIP_DEFLATED) as f: - for (dirpath, _dirname, files) in os.walk(sourcedir): + for (dirpath, _dirname, files) in os.walk(new_name): for file in files: source = pathlib.Path(dirpath) / file - print(source, destination ) - f.write(source, os.path.relpath(sourcedir, dirpath)) + f.write(source, pathlib.Path(os.path.relpath(sourcedir, dirpath)) / os.path.relpath(dirpath, sourcedir) / pathlib.Path(file)) def make_macos(suffix="new"): @@ -146,6 +150,11 @@ make_windows(sys.argv[2]) else: make_windows() + elif command.lower() == "linux": + if len(sys.argv) > 2: + make_linux(sys.argv[2]) + else: + make_linux() elif command.lower() == "source": if len(sys.argv) > 2: make_source(sys.argv[2])