Coverage for eminus/version.py: 94.74%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-16 10:16 +0000

1# SPDX-FileCopyrightText: 2021 The eminus developers 

2# SPDX-License-Identifier: Apache-2.0 

3"""Package version number and version info function.""" 

4 

5import importlib.metadata 

6import platform 

7import sys 

8 

9__version__ = "3.0.2" 

10#: eminus ASCII logo. 

11LOGO = (" ___ _____ _ ___ _ _ ___ \n" 

12 "| -_| | | | | |_ -|\n" 

13 "|___|_|_|_|_|_|_|___|___|\n") # fmt: skip 

14 

15 

16def info(): 

17 """Print version numbers and availability of packages.""" 

18 dependencies = ("numpy", "scipy") 

19 extras = ("jax", "torch", "pyscf", "dftd3", "h5py", "plotly", "nglview") 

20 dev = ("matplotlib", "notebook", "pylibxc", "pytest", "sphinx", "furo") 

21 

22 sys.stdout.write(LOGO) 

23 sys.stdout.write( 

24 "\neminus - Pythonic electronic structure theory" 

25 "\n https://doi.org/10.1016/j.softx.2025.102035\n" 

26 "\n--- Platform infos ---" 

27 f"\nPlatform : {platform.system()} {platform.machine()}" 

28 f"\nRelease : {platform.release()} {platform.version()}" 

29 "\n\n--- Version infos ---" 

30 f"\npython : {sys.version.split()[0]}" 

31 f"\neminus : {__version__}\n" 

32 ) 

33 for pkg in dependencies + extras + dev: 

34 try: 

35 sys.stdout.write(f"{pkg:<11}: {importlib.metadata.version(pkg)}\n") 

36 except ModuleNotFoundError: # noqa: PERF203 

37 if pkg in dependencies: 

38 sys.stdout.write(f"{pkg:<11}: Dependency not installed\n") 

39 elif pkg in extras: 

40 sys.stdout.write(f"{pkg:<11}: Extra not installed\n")