Skip to content

Commit

Permalink
fix: Replace pkg_resources with acres
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 18, 2024
1 parent 8abddf9 commit ddfb69c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions nipype/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def get_nipype_gitversion():
"simplejson>=%s" % SIMPLEJSON_MIN_VERSION,
"traits>=%s" % TRAITS_MIN_VERSION,
"filelock>=3.0.0",
"acres",
"etelemetry>=0.3.1",
"looseversion!=1.2",
"puremagic",
Expand Down
9 changes: 4 additions & 5 deletions nipype/interfaces/base/tests/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import pytest

from pkg_resources import resource_filename as pkgrf
import acres

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

b = nib.Bunch(infile=json_pth, otherthing="blue", yat=True)
b = nib.Bunch(infile=str(json_pth), otherthing="blue", yat=True)
newbdict, bhash = b._get_bunch_hash()
assert bhash == "d1f46750044c3de102efc847720fc35f"
# Make sure the hash stored in the json file for `infile` is correct.
jshash = md5()
with open(json_pth) as fp:
jshash.update(fp.read().encode("utf-8"))
jshash.update(json_pth.read_bytes())
assert newbdict["infile"][0][1] == jshash.hexdigest()
assert newbdict["yat"] is True
12 changes: 3 additions & 9 deletions nipype/interfaces/fsl/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from shutil import rmtree
from string import Template

import acres
import numpy as np
from looseversion import LooseVersion
from nibabel import load
Expand Down Expand Up @@ -2547,12 +2548,5 @@ def load_template(name):
template : string.Template
"""
from pkg_resources import resource_filename as pkgrf

full_fname = pkgrf(
"nipype", os.path.join("interfaces", "fsl", "model_templates", name)
)
with open(full_fname) as template_file:
template = Template(template_file.read())

return template
loader = acres.Loader('nipype.interfaces.fsl')
return Template(loader.readable('model_templates', name).read_text())

0 comments on commit ddfb69c

Please sign in to comment.