Skip to content

Commit 514630c

Browse files
committed
switch from deprecated pkg_resources to importlib_resources
1 parent 251af56 commit 514630c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

bear/data_file.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pkg_resources
1+
import importlib_resources
22
import os
33

44

@@ -15,12 +15,12 @@ def get_path(file_url):
1515
# try to find the file in a couple of different places
1616
for package, prefix in ("bear", "data/"), ("visr_bear_data", ""):
1717
try:
18-
full_path = pkg_resources.resource_filename(package, prefix + path)
18+
full_path = importlib_resources.files(package) / prefix / path
1919
except ModuleNotFoundError:
2020
continue
2121

22-
if os.path.isfile(full_path):
23-
return full_path
22+
if full_path.is_file():
23+
return str(full_path)
2424
else:
2525
raise Exception(f"resource '{path}' not found")
2626
elif file_url.startswith("file:"):

nix/bear.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
python.pkgs.buildPythonPackage rec {
33
name = "bear";
44
inherit src;
5-
propagatedBuildInputs = with python.pkgs; [ numpy ear setuptools visr_python visr_bear ];
5+
propagatedBuildInputs = with python.pkgs; [ numpy ear importlib-resources visr_python visr_bear ];
6+
nativeBuildInputs = with python.pkgs; [ setuptools ];
67
nativeCheckInputs = [ python.pkgs.pytest numpy_quaternion ];
78
checkPhase = lib.optionalString (visr_bear != null) ''
89
pytest visr_bear/test

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
version="0.0.1",
77
install_requires=[
88
"ear~=2.1",
9+
"importlib_resources",
910
"numpy",
1011
],
1112
packages=find_packages(),

0 commit comments

Comments
 (0)