-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
59 lines (49 loc) · 1.94 KB
/
setup.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
49
50
51
52
53
54
55
56
57
58
59
import os
import platform
import urllib.request
import zipfile
import setuptools.command.build_py
from setuptools import setup
import logging
VERSION = "9999"
if not VERSION.replace("9",""):
branch = "main"
else:
branch = f"v{VERSION}"
JAR_URL = f"https://github.com/colomoto/ERODE-CoLoMoTo/raw/{branch}/it.sssa.erode.colomoto/distr/erode4Colomoto.jar"
PLATFORM_DEPS = {
"Darwin": "https://github.com/IMTAltiStudiLucca/ERODE-Libraries/raw/master/z3SourceLibraries/mac.zip",
"Linux": "https://github.com/IMTAltiStudiLucca/ERODE-Libraries/raw/master/z3SourceLibraries/linux64.zip",
"Windows": "https://github.com/IMTAltiStudiLucca/ERODE-Libraries/raw/master/z3SourceLibraries/windows64.zip",
}
class build_erode_lib(setuptools.command.build_py.build_py):
def run(self):
target_dir = os.path.join(self.build_lib, 'erode')
self.mkpath(target_dir)
logging.info(f"Downloading {JAR_URL}")
urllib.request.urlretrieve(JAR_URL,
os.path.join(target_dir, "erode4Colomoto.jar"))
target_dir = os.path.join(self.build_lib, 'erode/lib')
self.mkpath(target_dir)
dep_url = PLATFORM_DEPS[platform.system()]
logging.info(f"Downloading {dep_url}")
dep_zip, _= urllib.request.urlretrieve(dep_url)
try:
with zipfile.ZipFile(dep_zip) as z:
for name in z.namelist():
bname = os.path.basename(name)
if bname.startswith(".") or name.startswith("_") \
or "." not in bname:
continue
logging.info(f"Extracting {name}")
with z.open(name) as src,\
open(os.path.join(target_dir, bname), "wb") as dst:
dst.write(src.read())
finally:
os.unlink(dep_zip)
super().run()
setup(version =VERSION,
cmdclass={
'build_py': build_erode_lib,
}
)