-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathanaconda_packages.py
46 lines (42 loc) · 1.82 KB
/
anaconda_packages.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
import os
import sys
if sys.version_info[0] == 2:
PY2 = True
PY3 = False
else:
PY3 = True
PY2 = False
if PY2:
environ = {key : value for key, value in os.environ.iteritems() if value}
else:
environ = {key : value for key, value in os.environ.items() if value}
def main():
CONDA_PREFIX = os.path.join(os.path.abspath(environ["CONDA_PREFIX"]), 'conda-bld', "win-")
if environ["ARCH"] == "x86":
CONDA_PREFIX += "32"
else:
CONDA_PREFIX += "64"
if os.path.exists(CONDA_PREFIX):
environ["ANACONDA_SUCCESS_PACKAGES"] = " ".join(os.path.join(CONDA_PREFIX, package) for package in os.listdir(CONDA_PREFIX) if package.endswith(".tar.bz2"))
else:
environ["ANACONDA_SUCCESS_PACKAGES"] = ""
CONDA_PREFIX = os.path.join(os.path.abspath(environ["CONDA_PREFIX"]), 'conda-bld', "broken")
if os.path.exists(CONDA_PREFIX):
environ["ANACONDA_FAILURE_PACKAGES"] = " ".join(os.path.join(CONDA_PREFIX, package) for package in os.listdir(CONDA_PREFIX) if package.endswith(".tar.bz2"))
else:
environ["ANACONDA_FAILURE_PACKAGES"] = ""
with open("anaconda_packages.bat", "a+") as filehandler:
filehandler.write("\n")
if PY2:
for key, value in environ.iteritems():
if key not in os.environ or not os.environ[key] == environ[key]:
filehandler.write("set " + key + "=" + value.strip() + "\n")
filehandler.write("if errorlevel 1 exit 1")
else:
for key, value in environ.items():
if key not in os.environ or not os.environ[key] == environ[key]:
filehandler.write("set " + key + "=" + value.strip() + "\n")
filehandler.write("if errorlevel 1 exit 1")
filehandler.write("\n")
if __name__ == "__main__":
main()