diff --git a/cmake/MakePythonExecutable.cmake b/cmake/MakePythonExecutable.cmake index b20cbbb878..616dd4fbe5 100644 --- a/cmake/MakePythonExecutable.cmake +++ b/cmake/MakePythonExecutable.cmake @@ -17,21 +17,13 @@ set(BINPATH_CONTENTS "\n" ) -# Three possible interfaces: +# Two possible interfaces: # 1. Standalone file residing in commands/ # 2. File stored in location commands//.py, which will contain usage() and execute() functions -# 3. Two files stored at commands//usage.py and commands//execute.py, defining the two corresponding functions if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}/__init__.py") - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}/usage.py" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}/execute.py") - string(APPEND BINPATH_CONTENTS - "module_usage = importlib.import_module('.usage', 'mrtrix3.commands.${CMDNAME}')\n" - "module_execute = importlib.import_module('.execute', 'mrtrix3.commands.${CMDNAME}')\n" - "_execute(module_usage.usage, module_execute.execute)\n" - ) - elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}/${CMDNAME}.py") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}/${CMDNAME}.py") string(APPEND BINPATH_CONTENTS "module = importlib.import_module('.${CMDNAME}', 'mrtrix3.commands.${CMDNAME}')\n" - "_execute(module.usage, module.execute)\n" ) else() message(FATAL_ERROR "Malformed filesystem structure for Python command ${CMDNAME}") @@ -39,11 +31,14 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}/__init__.py") elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CMDNAME}.py") string(APPEND BINPATH_CONTENTS "module = importlib.import_module('.${CMDNAME}', 'mrtrix3.commands')\n" - "_execute(module.usage, module.execute)\n" ) else() message(FATAL_ERROR "Malformed filesystem structure for Python command ${CMDNAME}") endif() +string(APPEND BINPATH_CONTENTS + "_execute(module.usage, module.execute)\n" +) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19) file(WRITE ${OUTPUT_DIR}/${CMDNAME} ${BINPATH_CONTENTS}) diff --git a/python/mrtrix3/commands/population_template/population_template.py b/python/mrtrix3/commands/population_template/population_template.py new file mode 100644 index 0000000000..85d487efe8 --- /dev/null +++ b/python/mrtrix3/commands/population_template/population_template.py @@ -0,0 +1,23 @@ +# Copyright (c) 2008-2024 the MRtrix3 contributors. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# Covered Software is provided under this License on an "as is" +# basis, without warranty of any kind, either expressed, implied, or +# statutory, including, without limitation, warranties that the +# Covered Software is free of defects, merchantable, fit for a +# particular purpose or non-infringing. +# See the Mozilla Public License v. 2.0 for more details. +# +# For more details, see http://www.mrtrix.org/. + +from .usage import usage as my_usage +from .execute import execute as my_execute + +def usage(cmdline): #pylint: disable=unused-variable + return my_usage(cmdline) + +def execute(): #pylint: disable=unused-variable + return my_execute()