-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6eb09d9
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import sys | ||
import importlib | ||
|
||
OK = "\x1b[42m[ OK ]\x1b[0m" | ||
FAIL = "\x1b[41m[FAIL]\x1b[0m" | ||
|
||
try: | ||
from packaging.version import Version | ||
except ImportError: | ||
print(FAIL, "'packaging' package not installed, install it with conda or pip") | ||
sys.exit(1) | ||
|
||
# first check the python version | ||
print("Using python in", sys.prefix) | ||
print(sys.version) | ||
pyversion_str = f"{sys.version_info.major}.{sys.version_info.minor}" | ||
pyversion = Version(pyversion_str) | ||
|
||
if pyversion < Version("3.8"): | ||
print( | ||
FAIL, | ||
"Python version 3.8 or above is required," f" but {pyversion_str} is installed.", | ||
) | ||
sys.exit(1) | ||
print() | ||
|
||
|
||
def import_version(pkg, min_ver, fail_msg=""): | ||
mod = None | ||
try: | ||
mod = importlib.import_module(pkg) | ||
if pkg in {"PIL"}: | ||
try: | ||
ver = mod.__version__ | ||
except AttributeError: | ||
try: | ||
ver = mod.VERSION | ||
except AttributeError: | ||
try: | ||
ver = mod.PILLOW_VERSION | ||
except Exception: | ||
raise | ||
else: | ||
ver = mod.__version__ | ||
if Version(ver) < Version(min_ver): | ||
print( | ||
FAIL, | ||
f"{lib} version {min_ver} or higher required, but {ver} installed.", | ||
) | ||
else: | ||
print(OK, f"{pkg} version {ver}") | ||
except ImportError: | ||
print(FAIL, f"{pkg} not installed. {fail_msg}") | ||
return mod | ||
|
||
|
||
requirements = { | ||
"numpy": "1.16", | ||
"scipy": "1.2", | ||
"matplotlib": "3.0", | ||
"sklearn": "1.2", | ||
"pandas": "1", | ||
"seaborn": "0.11", | ||
"notebook": "5.7", | ||
"plotly": "5.10", | ||
} | ||
|
||
# now the dependencies | ||
for lib, required_version in list(requirements.items()): | ||
import_version(lib, required_version) |