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
>>>
```

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`f21294f`)](https://app.codecov.io/gh/scikit-hep/scikit-hep/commit/f21294fde0072fb49bd1d6effd3f61ed2a30142d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) 89.70% compared to head [(`52e4368`)](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) 89.70%.


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #333   +/-   ##
=======================================
  Coverage   89.70%   89.70%           
=======================================
  Files          10       10           
  Lines         962      962           
  Branches      197      197           
=======================================
  Hits          863      863           
  Misses         83       83           
  Partials       16       16           
```

| [Flag](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) | Coverage Δ | |
|---|---|---|
| [unittests-3.10](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) | `89.70% <ø> (ø)` | |
| [unittests-3.11](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) | `89.70% <ø> (ø)` | |
| [unittests-3.8](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) | `89.70% <ø> (ø)` | |
| [unittests-3.9](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep) | `89.70% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep#carryforward-flags-in-the-pull-request-comment) to find out more.


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/scikit-hep/scikit-hep/pull/333?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scikit-hep).


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()