Skip to content

Commit ddfb69c

Browse files
committed
fix: Replace pkg_resources with acres
1 parent 8abddf9 commit ddfb69c

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

nipype/info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def get_nipype_gitversion():
145145
"simplejson>=%s" % SIMPLEJSON_MIN_VERSION,
146146
"traits>=%s" % TRAITS_MIN_VERSION,
147147
"filelock>=3.0.0",
148+
"acres",
148149
"etelemetry>=0.3.1",
149150
"looseversion!=1.2",
150151
"puremagic",

nipype/interfaces/base/tests/test_support.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import pytest
55

6-
from pkg_resources import resource_filename as pkgrf
6+
import acres
77

88
from ....utils.filemanip import md5
99
from ... import base as nib
@@ -42,14 +42,13 @@ def test_bunch_methods():
4242
def test_bunch_hash():
4343
# NOTE: Since the path to the json file is included in the Bunch,
4444
# the hash will be unique to each machine.
45-
json_pth = pkgrf("nipype", os.path.join("testing", "data", "realign_json.json"))
45+
json_pth = acres.Loader('nipype.testing').cached('data', 'realign_json.json')
4646

47-
b = nib.Bunch(infile=json_pth, otherthing="blue", yat=True)
47+
b = nib.Bunch(infile=str(json_pth), otherthing="blue", yat=True)
4848
newbdict, bhash = b._get_bunch_hash()
4949
assert bhash == "d1f46750044c3de102efc847720fc35f"
5050
# Make sure the hash stored in the json file for `infile` is correct.
5151
jshash = md5()
52-
with open(json_pth) as fp:
53-
jshash.update(fp.read().encode("utf-8"))
52+
jshash.update(json_pth.read_bytes())
5453
assert newbdict["infile"][0][1] == jshash.hexdigest()
5554
assert newbdict["yat"] is True

nipype/interfaces/fsl/model.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from shutil import rmtree
1010
from string import Template
1111

12+
import acres
1213
import numpy as np
1314
from looseversion import LooseVersion
1415
from nibabel import load
@@ -2547,12 +2548,5 @@ def load_template(name):
25472548
template : string.Template
25482549
25492550
"""
2550-
from pkg_resources import resource_filename as pkgrf
2551-
2552-
full_fname = pkgrf(
2553-
"nipype", os.path.join("interfaces", "fsl", "model_templates", name)
2554-
)
2555-
with open(full_fname) as template_file:
2556-
template = Template(template_file.read())
2557-
2558-
return template
2551+
loader = acres.Loader('nipype.interfaces.fsl')
2552+
return Template(loader.readable('model_templates', name).read_text())

0 commit comments

Comments
 (0)