/
_logging.py
40 lines (33 loc) · 1.12 KB
/
_logging.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
#!/usr/bin/env python
# @Author: Kelvin
# @Date: 2021-02-06 13:18:58
# @Last Modified by: Kelvin
# @Last Modified time: 2022-05-18 16:18:14
from typing import Union, Sequence, Tuple
modules = ['dandelion', 'pandas', 'numpy', 'matplotlib',
'networkx', 'scipy', 'distance', 'polyleven']
# borrowed from scanpy's logging module
def _versions_dependencies(dependencies: Sequence):
for mod in dependencies:
mod_name, dist_name = mod if isinstance(mod, tuple) else (mod, mod)
try:
imp = __import__(mod_name)
yield dist_name, imp.__version__
except (ImportError, AttributeError):
pass
def print_versions(dependencies: Sequence = modules):
'''
Versions that are essential for dandelion's operation.
'''
print(' '.join(
f'{mod}=={ver}'
for mod, ver in _versions_dependencies(dependencies)
))
def print_header(dependencies: Sequence = modules):
'''
Versions that are essential for dandelion's operation.
'''
print(' '.join(
f'{mod}=={ver}'
for mod, ver in _versions_dependencies(dependencies)
))