-
Notifications
You must be signed in to change notification settings - Fork 12
/
installOptionalPackages.py
34 lines (26 loc) · 1.68 KB
/
installOptionalPackages.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
import subprocess
import sys
def tryInstallingPackage(packageName: str, errorMessage: str):
''' Function used to handle 'nice-to-have', but not required packages '''
try:
print("\nAttempting to install optional package: {}\n".format(packageName))
subprocess.check_call([sys.executable, "-m", "pip", "install", packageName])
print("\nInstalled {}\n".format(packageName))
return True
except subprocess.CalledProcessError:
# Output error, but continue installation if ray install fails
# Error message won't be visible unless running `python setup.py develop`
print("\nWARNING: Unable to install {}. {}\n".format(packageName, errorMessage))
return False
# ray and mayavi are optional dependencies that often cause issues, especially on Windows
tryInstallingPackage("ray", "MAPLEAF will only run single-threaded.")
# Three-step dance to try to install Mayavi
if sys.version_info[1] > 8:
print("Detected python v{}.{}".format(sys.version_info[0], sys.version_info[1]))
print("Mayavi won't work with Python version 3.9.X or above as of fall 2021. Try Python 3.8 for 3D renders. Otherwise, MAPLEAF will fall back to 2D Matplotlib outputs.\n")
else:
successPyQt = tryInstallingPackage("PyQT5", "MAPLEAF will not produce 3D renders of the earth. Will fall back to Matplotlib instead.")
if successPyQt:
successVTK901 = tryInstallingPackage("vtk==9.0.1", "MAPLEAF will not produce 3D renders of the earth. Will fall back to Matplotlib instead.")
if successVTK901:
tryInstallingPackage("mayavi", "MAPLEAF will not produce 3D renders of the earth. Will fall back to Matplotlib instead.")