Skip to content

Commit

Permalink
New EXTERNAL_PROJECT_COMMAND input for MakePythonExecutable.cmake
Browse files Browse the repository at this point in the history
To handle the installation of external Python commands, a new option for MakePythonExecutable is added to set a different location for the library files.
  • Loading branch information
daljit46 committed Jul 2, 2024
1 parent 362eb2f commit e967339
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmake/MakePythonExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# Inputs:
# - CMDNAME: Name of the command
# - OUTPUT_DIR: Directory in which to create the executable
# - EXTERNAL_PROJECT_COMMAND: Boolean indicating whether the command is part of an MRtrix3 external project

set(PYTHON_LIB_PATH "os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'lib'))")

# For external projects the python library sources are located in ../mrtrix3/lib
if(EXTERNAL_PROJECT_COMMAND)
set(PYTHON_LIB_PATH "os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'mrtrix3', 'lib'))")
endif()

set(BINPATH_CONTENTS
"#!/usr/bin/python3\n"
Expand All @@ -11,7 +19,7 @@ set(BINPATH_CONTENTS
"import os\n"
"import sys\n"
"\n"
"mrtrix_lib_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'lib'))\n"
"mrtrix_lib_path = ${PYTHON_LIB_PATH}\n"
"sys.path.insert(0, mrtrix_lib_path)\n"
"from mrtrix3.app import _execute\n"
"\n"
Expand Down

0 comments on commit e967339

Please sign in to comment.