mirror of
https://github.com/projectPiki/pikmin2.git
synced 2024-11-23 13:29:55 +00:00
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
import argparse
|
|
import urllib.request
|
|
import sys
|
|
import os
|
|
import stat
|
|
import platform
|
|
from pathlib import Path
|
|
|
|
if sys.platform == "cygwin":
|
|
sys.exit(
|
|
f"Cygwin/MSYS2 is not supported."
|
|
f"\nPlease use native Windows Python instead."
|
|
f"\nPlease run pacman -R python in msys2."
|
|
f"\n(Current path: {sys.executable})"
|
|
)
|
|
|
|
REPO = "https://github.com/encounter/decomp-toolkit"
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("tag_file", help="file containing GitHub tag")
|
|
parser.add_argument("output", type=Path, help="output file path")
|
|
args = parser.parse_args()
|
|
|
|
with open(args.tag_file, "r") as f:
|
|
tag = f.readline().rstrip()
|
|
|
|
uname = platform.uname()
|
|
suffix = ""
|
|
system = uname.system.lower()
|
|
if system == "darwin":
|
|
system = "macos"
|
|
elif system == "windows":
|
|
suffix = ".exe"
|
|
arch = uname.machine.lower()
|
|
if arch == "amd64":
|
|
arch = "x86_64"
|
|
|
|
url = f"{REPO}/releases/download/{tag}/dtk-{system}-{arch}{suffix}"
|
|
output = args.output
|
|
# print(f"Downloading {url} to {output}")
|
|
urllib.request.urlretrieve(url, output)
|
|
|
|
st = os.stat(output)
|
|
os.chmod(output, st.st_mode | stat.S_IEXEC)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|