-
Notifications
You must be signed in to change notification settings - Fork 197
Python modifications for cmake #2730
Description
Part of #2689, but wanted a clean page to contemplate how best to adapt the API / Python executables to the modified filesystem structure & installation process for cmake.
-
Some of the logic in
bin/mrtrix3.pyis tailored for running Python executables that are part of external MRtrix3 projects. Relevant documentation here. There, the logic proceeds something like: 1) If a symbolic link to the main repobin/mrtrix3.pyhas been made within the external project, that can be used to find the API. 2) Often external projects are built by constructing a softlink to thebuildscript in the main repo and running that directly; that softlink can therefore be used to find the API. Use ofPYTHONPATHis a fallback, but if used would kick in before any of this logic.This is being made redundant; indeed it's unclear at this point in time exactly what external projects will look like after the cmake changes.
Suggestion: Remove all support for external modules within the code.
PYTHONPATHwill remain a viable solution. At the point at which we address compilation of external C++ binaries we will also address external Python executables. -
It is intended to be possible for a user to define a symbolic link to the executable, and attempting to run that executable will still find the Python API based on a relative path from the resolved symbolic link.
-
The
runmodule includes logic to ensure that if an MRtrix3 executable is invoked, it is the coinciding version of that executable that is invoked rather than the first that appears inPATH, and also there are certain command-line options that may be added torun.command()invocations based on the availability of "standard" MRtrix3 command-line options.The logic behind this may need to be revised. Currently, it just looks at the contents of
../../bin/. So if the software is installed into a location that is shared with other software, eg./usr/local/, that logic will catch a large set of non-MRtrix3 commands.Suggestion: The build stage of cmake could collect a list of MRtrix3 executables, and write it to a text file within
lib/mrtrix3/in the build directory.lib/mrtrix3/__init__.pywould then read from this file. -
It was hypothesized that it would be nice to be able to:
-
Run MRtrix3 Python scripts from either an installed location or the build directory, and for point 3 above to still be satisfied.
-
Modify the contents of Python executables within the source directory, and have those changes reflected in the build directory without having to re-run the build step of cmake.
However on reflection it may be tricky to support both this feature and point 2 above. It would be treating softlinks in different ways, and also ideally this modify-without-build feature would apply to the API and script algorithms also.
Suggestions: For point i., as long as the directory structure is consistent between build and install, and there isn't any softlink trickery, it should work out of the box. For point ii., just rely on cmake build to copy any Python updates made in the source code into the build directory.
-
-
Already mentioned in Change build system to CMake #2689, but relevant here also: Placement of the script algorithms.
Before the
cmakechanges, there are executable Python scripts inbin/, APIs inlib/mrtrix3/, and algorithm source code inlib/mrtrix3/<exename>/*.py. Thus far for cmake this has all just been moved into new directorypython/*but the relative structure is unchanged.Suggestions: There's multiple options here. One I'm increasingly liking as suggested by @aaroncapon is to move the sub-directories of
python/lib/mrtrix3/(ie. the script algorithms) intopython/src/mrtrix3/, and within the build / installation directory populatesrc/mrtrix3/with these contents. @daljit46 do you see any issue with the build / installation containing asrc/mrtrix3/directory?