Initial Python API changes for cmake adoption#2737
Conversation
- 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.
|
The logic for handling Python files is mostly encompassed in
Something like this should work: |
|
One thing I would like to comment on is that, in my opinion, setting the |
|
The issue we've had with Updating to a cmake universe: Perhaps if someone has gone through the cmake installation step, then it would be reasonable to have that added to Though I think you're later suggesting something else. If I'm following that correctly, it's not utilisation of |
|
Just to add a couple of comments on top of @Lestropie's:
We've discussed this quite a few times in the past, and always came to the conclusion that we shouldn't rely on it. We're far from alone in that particular conclusion by the way - see these blogs on the issues others have with
Personally, I think it should be avoided like the plague, for very similar reasons to why |
|
Superseded by #2920. |
@daljit46 Will need your assistance on this one.
Closes #2730.
Follows #2689, which has now been merged to
dev.Main changes implemented in first commit are:
Move Python algorithms code from
lib/intosrc/. This makes more sense to me than any other alternative I've come up with (including doing nothing).Remove some of the logic in
bin/mrtrix3.pyfor locating the API modules.For external projects, we previously had the option of having in the root directory of that project a softlink to the
buildscript of the main MRtrix3 repository. Where this was used,bin/mrtrix3.pywould read the contents of that softlink and use it to locate thelib/directory of the main repository. This is however no longer applicable asbuilddoes not even exist.My suspicion is that when we get to the point of dealing with external projects post-
cmake, the solution here is going to be construction of a softlink tobin/mrtrix3.py. I think the contents of this PR should work in that scenario, but it will need to be evaluated properly when a solution for external projects that also deals with C++ is constructed.PYTHONPATHwill also remain a viable backup.Resolve the
impmodule deprecation; similar to add support for python importlib to locate MRtrix3 python libraries #2735, except that ondevPython 2 support has been removed (Drop python2 support #2215) so that code branch is no longer required.Things to do:
Modify
cmaketo deal with the new location of the Python algorithms.I had a go at this about a week ago and struggled and ended up discarding my attempt. From memory there are baked-in named variables for bin and lib directories, but no corresponding variable for a src directory, so this needs to be constructed appropriately.
Find a solution to the issue of the
runmodule in particular wanting to know the comprehensive set of MRtrix3 executables.This can no longer be done reliably at runtime as the directory in which the Python executable resides following installation may contain non-MRtrix3 executables. See Python modifications for cmake #2730 point 3.
Test viability of creating a softlink to
bin/mrtrix3.py.Check again why the 5ttgen algorithms need to be placed in "_5ttgen/"; this traces back to f0bb21d, and I'm sure it was necessary at the time, but I don't recall exactly what was playing up that forced me to add that little hack.