Coverage for /builds/kinetik161/ase/ase/dependencies.py: 100.00%
19 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1import importlib
2from typing import List, Tuple
4from ase.utils import (get_python_package_path_description,
5 search_current_git_hash)
8def format_dependency(modname: str) -> Tuple[str, str]:
9 """Return (name, info) for given module.
11 If possible, info is the path to the module's package."""
12 try:
13 module = importlib.import_module(modname)
14 except ImportError:
15 return modname, 'not installed'
17 version = getattr(module, '__version__', '?')
18 name = f'{modname}-{version}'
19 if modname == 'ase':
20 githash = search_current_git_hash(module)
21 if githash:
22 name += f'-{githash:.10}'
24 # (only packages have __path__, but we are importing packages.)
25 info = get_python_package_path_description(module)
26 return name, info
29def all_dependencies() -> List[Tuple[str, str]]:
30 names = ['ase', 'numpy', 'scipy', 'matplotlib', 'spglib',
31 'ase_ext', 'flask', 'psycopg2', 'pyamg']
32 return [format_dependency(name) for name in names]