From f9362b8a11690baa0acf8b02fb833fd083683802 Mon Sep 17 00:00:00 2001 From: Nick Papior Date: Tue, 6 Aug 2024 21:20:37 +0200 Subject: [PATCH] amended debug-info with pip+conda install command Signed-off-by: Nick Papior --- tools/_debug_info.py.conf | 44 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/tools/_debug_info.py.conf b/tools/_debug_info.py.conf index 7b6e663e35..c34b46c0f3 100644 --- a/tools/_debug_info.py.conf +++ b/tools/_debug_info.py.conf @@ -54,14 +54,18 @@ def print_debug_info(): print(fmt.format("path", str((path / "..").resolve()))) def print_attr(module, attr: str = ""): + attr_val = None try: mod = importlib.import_module(module) if attr: - print(fmt.format(module, getattr(mod, attr))) + attr_val = getattr(mod, attr) + print(fmt.format(module, attr_val)) except BaseException as e: print(fmt.format(module, "not found")) print(fmt.format("", str(e))) + return attr_val + # regardless of whether it is on, or not, we try to import fortran extension print_attr("sisl.io.siesta._siesta") @@ -81,18 +85,28 @@ def print_debug_info(): print(fmt.format(d, v)) print("[runtime modules]") - for mod in ( - "numpy", - "scipy", - "xarray", - "netCDF4", - "pandas", - "matplotlib", - "dill", - "pathos", - "skimage", - "plotly", - "ase", - "pymatgen", + + pip_install = [] + conda_install = [] + for pip, conda, mod in ( + ("numpy", "numpy", "numpy"), + ("scipy", "scipy", "scipy"), + ("xarray", "xarray", "xarray"), + ("netCDF4", "netCDF4", "netCDF4"), + ("pandas", "pandas", "pandas"), + ("matplotlib", "matplotlib", "matplotlib"), + ("dill", "dill", "dill"), + ("pathos", "pathos", "pathos"), + ("scikit-image", "scikit-image", "skimage"), + ("plotly", "plotly", "plotly"), + ("ase", "ase", "ase"), + ("pymatgen", "pymatgen", "pymatgen"), ): - print_attr(mod, "__version__") + attr = print_attr(mod, "__version__") + if attr is not None: + pip_install.append(f"{pip}=={attr}") + conda_install.append(f"{conda}=={attr}") + + print("[env]") + print(fmt.format("pip", " ".join(pip_install))) + print(fmt.format("conda", " ".join(conda_install)))