add support for python importlib to locate MRtrix3 python libraries#2735
Merged
add support for python importlib to locate MRtrix3 python libraries#2735
Conversation
This also falls back to using the (deprecated) imp module to support Python < 3.5
Lestropie
approved these changes
Oct 25, 2023
Member
Lestropie
left a comment
There was a problem hiding this comment.
Confirmed working for me on both Python 2 and 3 also.
Member
|
Agree with comment in #2735 that it's ugly. But as long as it works I'm okay with it. With 3.1.0 this will reduce in two ways:
|
Lestropie
added a commit
that referenced
this pull request
Oct 25, 2023
- Move algorithm code from python/lib/mrtrix3/ to python/src/mrtrix3/. - Modify python/bin/mrtrix3.py to reflect reduction of number of ways in which the Python API could potentially be found following calling mrtrix3.execute() in an executable command. This additionally includes the transition from the imp module to use importlib due to deprecation; this is a subset of #2735. - For now, the capturing of the list of MRtrix3 executables in mrtrix3.EXE_LIST is disabled, as it is possible for MRtrix3 to be installed into a location that additionally includes other non-MRtrix3 executables. An alternative solution for this will need to be subsequently implemented.
This was referenced Oct 25, 2023
Lestropie
added a commit
that referenced
this pull request
May 9, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First attempt at addressing #2731...
Seems to work from my limited testing. Main idea is to use
importlib(following suggestions from StackOverflow) as long as Python version is 3.5 or newer andimportlibmodule can be loaded successfully. Otherwise fall back to the previousimpapproach. Seems to work on my system using either Python 3.10 (usingimportlib) or Python 2.7 (usingimp).