-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.py
48 lines (43 loc) · 1.42 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import urllib.request
import os
import sys
import tempfile
import zipfile
import shutil
import sysconfig
import subprocess
plat = sysconfig.get_platform()
if plat.startswith("win"):
workflow = "windows"
name = f"python{sys.version_info.major}.{sys.version_info.minor}"
if plat == "win-amd64":
name += "-x64"
else:
name += "-x86"
elif plat.startswith("linux"):
workflow = "linux"
arch = plat.split("-", 1)[1]
name = f"python{sys.version_info.major}.{sys.version_info.minor}-{arch}"
elif plat.startswith("macos"):
workflow = "macos"
name = f"python{sys.version_info.major}.{sys.version_info.minor}"
print(f"Target artifact: {name}.zip")
tmp = tempfile.mkdtemp()
orig = os.getcwd()
os.chdir(tmp)
try:
urllib.request.urlretrieve(f"https://nightly.link/pyunity/pyunity/workflows/{workflow}/develop/{name}.zip", "artifact.zip")
with zipfile.ZipFile(os.path.join(tmp, "artifact.zip")) as zf:
files = zf.infolist()
name = files[0].filename
print(f"Target wheel: {name}")
zf.extract(name)
print("Installing wheel")
subprocess.call([sys.executable, "-m", "pip", "uninstall", "-y", "pyunity"],
stdout=sys.stdout, stderr=sys.stderr)
subprocess.call([sys.executable, "-m", "pip", "install", "-U", name],
stdout=sys.stdout, stderr=sys.stderr)
finally:
print("Cleaning up")
os.chdir(orig)
shutil.rmtree(tmp)