Repository: scikit-hep/scikit-hep

Issue:
skhep.show_versions() is broken
```python
(scikit-hep) [...]$ python
Python 3.11.6 | packaged by conda-forge | (main, Oct  3 2023, 10:40:35) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import skhep
>>> skhep.show_versions()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../micromamba/envs/scikit-hep/lib/python3.11/site-packages/skhep/utils/_show_versions.py", line 89, in show_versions
    deps_info = _get_deps_info(scipy_deps)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../micromamba/envs/scikit-hep/lib/python3.11/site-packages/skhep/utils/_show_versions.py", line 73, in _get_deps_info
    mod = importlib.import_module(modname)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../micromamba/envs/scikit-hep/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/.../micromamba/envs/scikit-hep/lib/python3.11/site-packages/setuptools/__init__.py", line 7, in <module>
    import _distutils_hack.override  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../micromamba/envs/scikit-hep/lib/python3.11/site-packages/_distutils_hack/override.py", line 1, in <module>
    __import__('_distutils_hack').do_override()
  File "/.../micromamba/envs/scikit-hep/lib/python3.11/site-packages/_distutils_hack/__init__.py", line 77, in do_override
    ensure_local_distutils()
  File "/.../micromamba/envs/scikit-hep/lib/python3.11/site-packages/_distutils_hack/__init__.py", line 64, in ensure_local_distutils
    assert '_distutils' in core.__file__, core.__file__
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: /.../micromamba/envs/scikit-hep/lib/python3.11/distutils/core.py
>>>
```

Comments:

Patch:
diff --git a/skhep/utils/_show_versions.py b/skhep/utils/_show_versions.py
index c552207..5d2108f 100644
--- a/skhep/utils/_show_versions.py
+++ b/skhep/utils/_show_versions.py
@@ -8,10 +8,10 @@ Heavily inspired from :func:`sklearn.show_versions`.
 
 import platform
 import sys
-import importlib
+import importlib.metadata
 
 
-scipy_deps = ["pip", "setuptools", "numpy", "scipy", "pandas", "matplotlib"]
+scipy_deps = ["setuptools", "pip", "numpy", "scipy", "pandas", "matplotlib"]
 
 
 skhep_deps = [
@@ -67,13 +67,8 @@ def _get_deps_info(pkgs_list):
 
     for modname in pkgs_list:
         try:
-            if modname in sys.modules:
-                mod = sys.modules[modname]
-            else:
-                mod = importlib.import_module(modname)
-            ver = mod.__version__
-            deps_info[modname] = ver
-        except ImportError:
+            deps_info[modname] = importlib.metadata.version(modname)
+        except ModuleNotFoundError:
             deps_info[modname] = None
 
     return deps_info


Test patch:
diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py
new file mode 100644
index 0000000..d6cfe41
--- /dev/null
+++ b/tests/utils/test_utils.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+from skhep import show_versions
+
+
+def test_show_versions():
+    show_versions()