Skip to content

Commit

Permalink
PY312: Drop implicit setuptools dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 20, 2023
1 parent b677172 commit c86508d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 6 additions & 4 deletions smriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,13 @@ def build_workflow(opts, retval):
import warnings
from time import strftime
from subprocess import check_call, CalledProcessError, TimeoutExpired
from pkg_resources import resource_filename as pkgrf

import json
from bids import BIDSLayout
from nipype import logging, config as ncfg
from niworkflows.utils.bids import collect_participants
from ..__about__ import __version__
from ..data import load_resource
from ..workflows.base import init_smriprep_wf

logger = logging.getLogger("nipype.workflow")
Expand Down Expand Up @@ -628,12 +628,14 @@ def build_workflow(opts, retval):
boilerplate,
)

boilerplate_bib = load_resource("boilerplate.bib")

# Generate HTML file resolving citations
cmd = [
"pandoc",
"-s",
"--bibliography",
pkgrf("smriprep", "data/boilerplate.bib"),
str(boilerplate_bib),
"--citeproc",
"--metadata",
'pagetitle="sMRIPrep citation boilerplate"',
Expand All @@ -651,7 +653,7 @@ def build_workflow(opts, retval):
"pandoc",
"-s",
"--bibliography",
pkgrf("smriprep", "data/boilerplate.bib"),
str(boilerplate_bib),
"--natbib",
str(log_dir / "CITATION.md"),
"-o",
Expand All @@ -662,7 +664,7 @@ def build_workflow(opts, retval):
except (FileNotFoundError, CalledProcessError, TimeoutExpired):
logger.warning("Could not generate CITATION.tex file:\n%s", " ".join(cmd))
else:
copyfile(pkgrf("smriprep", "data/boilerplate.bib"), str(log_dir / "CITATION.bib"))
copyfile(str(boilerplate_bib), str(log_dir / "CITATION.bib"))
return retval


Expand Down
11 changes: 5 additions & 6 deletions smriprep/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
"""Utilities to handle BIDS inputs."""
from pathlib import Path
from json import loads
from pkg_resources import resource_filename as pkgrf
from bids.layout import BIDSLayout

from ..data import load_resource


def collect_derivatives(derivatives_dir, subject_id, std_spaces, spec=None, patterns=None):
"""Gather existing derivatives and compose a cache."""
if spec is None or patterns is None:
_spec, _patterns = tuple(
loads(Path(pkgrf("smriprep", "data/io_spec.json")).read_text()).values()
)
_spec, _patterns = tuple(loads(load_resource("io_spec.json").read_text()).values())

Check warning on line 34 in smriprep/utils/bids.py

View check run for this annotation

Codecov / codecov/patch

smriprep/utils/bids.py#L34

Added line #L34 was not covered by tests

if spec is None:
spec = _spec
Expand Down Expand Up @@ -92,11 +91,11 @@ def write_derivative_description(bids_dir, deriv_dir):
.. testsetup::
>>> from pkg_resources import resource_filename
>>> from smriprep.data import load_resource
>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> tmpdir = TemporaryDirectory()
>>> bids_dir = resource_filename('smriprep', 'data/tests')
>>> bids_dir = load_resource('tests')
>>> deriv_desc = Path(tmpdir.name) / 'dataset_description.json'
.. doctest::
Expand Down
5 changes: 2 additions & 3 deletions smriprep/workflows/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
"""Anatomical reference preprocessing workflows."""
import typing as ty

from pkg_resources import resource_filename as pkgr

from nipype import logging
from nipype.pipeline import engine as pe
from nipype.interfaces import (
Expand All @@ -50,6 +48,7 @@
from niworkflows.utils.spaces import SpatialReferences, Reference
from niworkflows.utils.misc import add_suffix
from niworkflows.anat.ants import init_brain_extraction_wf, init_n4_only_wf
from ..data import load_resource
from ..interfaces import DerivativesDataSink
from ..utils.misc import apply_lut as _apply_bids_lut, fs_isRunning as _fs_isRunning
from .fit.registration import init_register_template_wf
Expand Down Expand Up @@ -1447,7 +1446,7 @@ def init_anat_template_wf(

if num_files == 1:
get1st = pe.Node(niu.Select(index=[0]), name="get1st")
outputnode.inputs.anat_realign_xfm = [pkgr("smriprep", "data/itkIdentityTransform.txt")]
outputnode.inputs.anat_realign_xfm = [str(load_resource("itkIdentityTransform.txt"))]

# fmt:off
workflow.connect([
Expand Down

0 comments on commit c86508d

Please sign in to comment.