Coverage for /builds/ase/ase/ase/dependencies.py: 100.00%
21 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
1# fmt: off
3from typing import List, Tuple
5from ase.utils import (
6 get_python_package_path_description,
7 search_current_git_hash,
8)
11def format_dependency(modname: str) -> Tuple[str, str]:
12 """Return (name, info) for given module.
14 If possible, info is the path to the module's package."""
15 import importlib.metadata
17 try:
18 module = importlib.import_module(modname)
19 except ImportError:
20 return modname, 'not installed'
22 if modname == 'flask':
23 version = importlib.metadata.version('flask')
24 else:
25 version = getattr(module, '__version__', '?')
27 name = f'{modname}-{version}'
29 if modname == 'ase':
30 githash = search_current_git_hash(module)
31 if githash:
32 name += f'-{githash:.10}'
34 # (only packages have __path__, but we are importing packages.)
35 info = get_python_package_path_description(module)
36 return name, info
39def all_dependencies() -> List[Tuple[str, str]]:
40 names = ['ase', 'numpy', 'scipy', 'matplotlib', 'spglib',
41 'ase_ext', 'flask', 'psycopg2', 'pyamg']
42 return [format_dependency(name) for name in names]