7
7
from tempfile import NamedTemporaryFile
8
8
9
9
10
+ def _envs_dir (base_dir ):
11
+ envs = next (os .walk (base_dir ))[1 ]
12
+ try :
13
+ envs .remove ("__pycache__" )
14
+ except ValueError :
15
+ pass
16
+
17
+ return envs
18
+
19
+
10
20
def _download_extract_zip (url , path ):
11
21
"""
12
22
Download a ZIP file and extract its contents in path
@@ -18,14 +28,17 @@ def _download_extract_zip(url, path):
18
28
zfile .extractall (path )
19
29
20
30
31
+ def _load_envs (base_dir , envs ):
32
+ module_prefix = "." .join (__name__ .split ("." )[:- 1 ]) + "."
33
+ env_modules = [module_prefix + e for e in envs ]
34
+ for modname in env_modules :
35
+ __import__ (modname )
36
+
37
+
21
38
def check_envs ():
22
39
base_dir = Path (os .path .dirname (os .path .abspath (__file__ )))
23
40
24
- envs = next (os .walk (base_dir ))[1 ]
25
- try :
26
- envs .remove ("__pycache__" )
27
- except ValueError :
28
- pass
41
+ envs = _envs_dir (base_dir )
29
42
30
43
if not envs :
31
44
tag = "v" + __version__
@@ -40,9 +53,13 @@ def check_envs():
40
53
_download_extract_zip (url , base_dir )
41
54
print ("..install complete." )
42
55
43
- if platform .system () == "Linux" :
56
+ if platform .system () == "Linux" :
44
57
import stat
45
58
46
59
for name in base_dir .rglob ("*.exe" ):
47
60
st = os .stat (name )
48
61
os .chmod (name , st .st_mode | stat .S_IEXEC )
62
+
63
+ envs = _envs_dir (base_dir )
64
+
65
+ _load_envs (base_dir , envs )
0 commit comments