-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkversions.py
executable file
·41 lines (31 loc) · 962 Bytes
/
checkversions.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
#!/usr/bin/env python
import importlib
import platform as P
from argparse import ArgumentParser
def main():
p = ArgumentParser(description="list python module versions")
p.add_argument(
"-m",
"--modules",
help="list of modules whose versions you want to check",
default=["numpy", "matplotlib"],
)
p = p.parse_args()
vers = detect_versions(p.modules)
print(vers)
def detect_versions(modules):
mlist = []
# %% first let's log system info
versys = " ".join((P.node(), P.processor(), P.system(), P.platform()))
print(versys)
mlist.append((P.python_implementation(), P.python_version()))
# %% now we'll log module versions
for mod in modules:
try:
m = importlib.import_module(mod)
mlist.append((mod, m.__version__))
except ImportError:
print(mod + " not installed")
return mlist
if __name__ == "__main__":
main()