Skip to content

Commit b705967

Browse files
authored
Merge pull request #403 from tangkong/mnt_dep_pkg_resources
MNT: replace deprecated pkg_resources with importlib.metadata.distributions
2 parents da51483 + a23d5c7 commit b705967

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
403 mnt_dep_pkg_resources
2+
#########################
3+
4+
API Changes
5+
-----------
6+
- N/A
7+
8+
Features
9+
--------
10+
- N/A
11+
12+
Bugfixes
13+
--------
14+
- N/A
15+
16+
Maintenance
17+
-----------
18+
- replace deprecated pkg_resources.working_set with importlib.metadata.distributions
19+
20+
Contributors
21+
------------
22+
- tangkong

hutch_python/env_version.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
"""
44
from __future__ import annotations
55

6+
import importlib.metadata
67
import logging
78
import os
89
import os.path
910
import pkgutil
1011

11-
import pkg_resources
12-
1312
logger = logging.getLogger(__name__)
1413

1514
_dev_ignore_list = ['ami', 'pdsapp']
@@ -42,10 +41,10 @@ def log_env() -> None:
4241
def dump_env() -> list[str]:
4342
"""
4443
Get all packages and versions from the current environment.
45-
conda list is slow, use pkg_resources instead
44+
conda list is slow, use importlib.metadata.distributions instead
4645
this might miss dev overrides
4746
"""
48-
return sorted(str(pkg) for pkg in pkg_resources.working_set)
47+
return sorted(str(dist.name) for dist in importlib.metadata.distributions())
4948

5049

5150
def get_conda_env_name() -> str:

0 commit comments

Comments
 (0)