Skip to content

Commit 38ea2da

Browse files
authored
Merge pull request #1921 from cmu-delphi/rzatserkovnyi/pkg-resources
Replace deprecated pkg_resources
2 parents a6ea003 + 195d7b2 commit 38ea2da

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

_delphi_utils_python/delphi_utils/geomap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Authors: Dmitry Shemetov @dshemetov, James Sharpnack @jsharpna, Maria Jahja
44
"""
55

6-
from os.path import join
76
from collections import defaultdict
7+
from os.path import join
88
from typing import Iterator, List, Literal, Optional, Set, Union
99

10+
import importlib_resources
1011
import pandas as pd
11-
import pkg_resources
1212
from pandas.api.types import is_string_dtype
1313

1414

@@ -153,7 +153,7 @@ def __init__(self, census_year: int = 2020):
153153
for from_code, to_codes in self.CROSSWALK_FILENAMES.items():
154154
for to_code, file_path in to_codes.items():
155155
self._crosswalks[from_code][to_code] = self._load_crosswalk_from_file(
156-
from_code, to_code, join(f"data/{census_year}", file_path)
156+
from_code, to_code, join("data", f"{census_year}", file_path)
157157
)
158158

159159
for geo_type in self._geos:
@@ -162,7 +162,7 @@ def __init__(self, census_year: int = 2020):
162162
def _load_crosswalk_from_file(
163163
self, from_code: str, to_code: str, data_path: str
164164
) -> pd.DataFrame:
165-
stream = pkg_resources.resource_stream(__name__, data_path)
165+
stream = importlib_resources.files(__name__) / data_path
166166
dtype = {
167167
from_code: str,
168168
to_code: str,

_delphi_utils_python/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"epiweeks",
1313
"freezegun",
1414
"gitpython",
15+
"importlib_resources>=1.3",
1516
"mock",
1617
"moto~=4.2.14",
1718
"numpy",

0 commit comments

Comments
 (0)