Skip to content

Commit

Permalink
Fix deprecation warning in provenance, fixes #2592
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jul 19, 2024
1 parent 357f761 commit 22be05f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ctapipe/core/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,16 @@ def _get_reference_meta(self, url):


def _get_python_packages():
def _sortkey(dist):
"""Sort packages by name, case insensitive"""
# get is needed to avoid errors / deprecation warning
# in case packages with broken metadata are in the system
# see e.g. https://github.com/pypa/setuptools/issues/4482
return dist.metadata.get("Name", "").lower()

return [
{"name": p.name, "version": p.version}
for p in sorted(distributions(), key=lambda d: (d.name or "").lower())
for p in sorted(distributions(), key=_sortkey)
]


Expand Down

0 comments on commit 22be05f

Please sign in to comment.