Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Drop distutils #3458

Merged
merged 6 commits into from
May 10, 2022
Merged

MNT: Drop distutils #3458

merged 6 commits into from
May 10, 2022

Conversation

effigies
Copy link
Member

Summary

FreeSurfer interfaces have some fairly deep LooseVersion integration that I didn't want to touch right now, so I just vendored LooseVersion in externals.

Fixes #3439.

List of changes proposed in this PR (pull-request)

@effigies effigies force-pushed the mnt/drop_distutils_take2 branch 3 times, most recently from 2952640 to 35d792c Compare April 28, 2022 18:26
@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #3458 (35d792c) into master (f662acf) will increase coverage by 0.00%.
The diff coverage is 66.19%.

❗ Current head 35d792c differs from pull request most recent head 1acd3fa. Consider uploading reports for the commit 1acd3fa to get more accurate results

@@           Coverage Diff           @@
##           master    #3458   +/-   ##
=======================================
  Coverage   65.24%   65.24%           
=======================================
  Files         309      309           
  Lines       40838    40827   -11     
  Branches     5377     5377           
=======================================
- Hits        26645    26639    -6     
+ Misses      13118    13114    -4     
+ Partials     1075     1074    -1     
Flag Coverage Δ
unittests 65.02% <63.38%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
nipype/__init__.py 52.17% <ø> (-1.02%) ⬇️
nipype/interfaces/niftyreg/base.py 55.95% <20.00%> (ø)
nipype/interfaces/dipy/tracks.py 29.60% <33.33%> (ø)
nipype/interfaces/fsl/preprocess.py 71.54% <33.33%> (ø)
nipype/interfaces/mrtrix3/connectivity.py 73.25% <33.33%> (+1.99%) ⬆️
nipype/interfaces/dipy/preprocess.py 25.42% <50.00%> (ø)
nipype/interfaces/dipy/reconstruction.py 30.69% <50.00%> (ø)
nipype/interfaces/dipy/registration.py 83.33% <50.00%> (ø)
nipype/interfaces/dipy/stats.py 83.33% <50.00%> (ø)
nipype/interfaces/fsl/model.py 55.14% <50.00%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f662acf...1acd3fa. Read the comment docs.

Copy link
Member

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much needed, thanks for pushing on this.

One thing - packaging.version.LegacyVersion might be a better fit for a lot of the non-Python tools, since they may not follow PEP440 (especially if using dev versions [this has bitten me before when working with dev FreeSurfer versions]). Or alternatively, we can use packaging.version.parse to produce either classes depending on the version string.

if path is None:
path = os.getenv(MRTRIX3_HOME, "/opt/mrtrix3")
else:
path = op.dirname(op.dirname(path))

self.inputs.in_config = op.join(
path,
"src/dwi/tractography/connectomics/" "example_configs/fs_default.txt",
"src/dwi/tractography/connectomics/example_configs/fs_default.txt",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be path expanded?

Suggested change
"src/dwi/tractography/connectomics/example_configs/fs_default.txt",
"src",
"dwi",
"tractography",
"connectomics",
"example_configs",
"fs_default.txt",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be, but I don't see much advantage to it. Windows interprets forward slashes as path separators, and this fits on one line.

@@ -28,6 +28,9 @@

related_filetype_sets = [(".hdr", ".img", ".mat"), (".nii", ".mat"), (".BRIK", ".HEAD")]

# Keep anybody who depended on the old hack from breaking
which = shutil.which
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note, the keyword args (which can also be positional) are different

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I guess we should keep and deprecate the old one instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you wrap calls to shutil.which in n/u/filemanip.py#which and keep the old function signature alive ?

I'd expect users who want to use shutil.which to import it directly instead of using nipype as a proxy for it anyway. However, anyone using nipype's which with named arguments would get an error which is sad. It depends how popular you think these utilities are in client code. I know Clinica uses some and we are trying to move away from them to reduce coupling.

Or a solution in between would be start with a DeprecationWarning advising to port to shutil.which and later remove or proxy it?

@effigies
Copy link
Member Author

I tried this for a bit... LegacyVersion has deprecation warnings.

@mgxd
Copy link
Member

mgxd commented Apr 29, 2022

I see, looks like they are adamant on removing it. It's a pity we're losing all these non PEP440 compliant checks.

@effigies
Copy link
Member Author

Maybe we should consider externals.version.LooseVersion a long term solution rather than a bridge. If it's Python, use Version, if it's not, use LooseVersion unless a custom method is needed

@mgxd
Copy link
Member

mgxd commented Apr 29, 2022

I think that sounds reasonable

@ghisvail
Copy link
Contributor

ghisvail commented May 10, 2022

Maybe we should consider externals.version.LooseVersion a long term solution rather than a bridge. If it's Python, use Version, if it's not, use LooseVersion unless a custom method is needed

Now that I have understood the needs a bit more, I believe that's the best you can do with what's available to you right now.

@effigies effigies force-pushed the mnt/drop_distutils_take2 branch from 35d792c to a012839 Compare May 10, 2022 16:53
@effigies effigies force-pushed the mnt/drop_distutils_take2 branch from a012839 to 1acd3fa Compare May 10, 2022 16:56
@effigies
Copy link
Member Author

Thanks for your input @ghisvail. I've decided to defer the deprecation of filemanip.which and converting what we sensibly can of LooseVersion to Version for a future release so we can just get this out the door, as I've held up 1.8.0 for too long. I will make issues of these things.

@effigies
Copy link
Member Author

Opened #3464 and #3465. Merging.

@effigies effigies merged commit e7daead into nipy:master May 10, 2022
@effigies effigies deleted the mnt/drop_distutils_take2 branch May 10, 2022 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop distutils
3 participants