diff --git a/buildconfig/CMake/LinuxPackageScripts.cmake b/buildconfig/CMake/LinuxPackageScripts.cmake index aa1a5c72c971..ab9a192fcf69 100644 --- a/buildconfig/CMake/LinuxPackageScripts.cmake +++ b/buildconfig/CMake/LinuxPackageScripts.cmake @@ -109,10 +109,11 @@ set(PYTHON_ARGS " -Wdefault::DeprecationWarning -Werror:::mantid -Werror:::manti set(PYTHON_EXEC_LOCAL "\${CONDA_PREFIX}/bin/python") set(PREAMBLE "${CONDA_PREAMBLE_TEXT}") set(LOCAL_PYPATH "${CMAKE_CURRENT_BINARY_DIR}/bin/") +# The python command to start workbench +set(MANTIDWORKBENCH_EXEC "-c \"from workbench.app.main import main; main()\"") # used by mantidworkbench if(ENABLE_WORKBENCH) - set(MANTIDWORKBENCH_EXEC "-m workbench") # what the actual thing is called configure_file( ${CMAKE_MODULE_PATH}/Packaging/launch_mantidworkbench.sh.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launch_mantidworkbench.sh @ONLY @@ -138,13 +139,11 @@ if(ENABLE_WORKBENCH) set(LOCAL_PYPATH "\${CONDA_PREFIX}/bin:\${CONDA_PREFIX}/lib:\${CONDA_PREFIX}/plugins") set(PYTHON_EXEC_LOCAL "\${CONDA_PREFIX}/bin/python") set(PREAMBLE "${CONDA_PREAMBLE_TEXT}") - set(MANTIDWORKBENCH_EXEC "-m workbench") # what the actual thing is called set(DEST_FILENAME_SUFFIX "") elseif(${install_type} STREQUAL "standalone") set(LOCAL_PYPATH "\${INSTALLDIR}/bin:\${INSTALLDIR}/lib:\${INSTALLDIR}/plugins") set(PYTHON_EXEC_LOCAL "\${INSTALLDIR}/bin/python") set(PREAMBLE "${SYS_PREAMBLE_TEXT}") - set(MANTIDWORKBENCH_EXEC "-m workbench") set(DEST_FILENAME_SUFFIX ".standalone") else() message(FATAL_ERROR "Unknown installation type '${install_type}' for workbench startup scripts") @@ -157,7 +156,7 @@ if(ENABLE_WORKBENCH) install( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/launch_mantidworkbench.sh.install${DEST_FILENAME_SUFFIX} DESTINATION ${BIN_DIR} - RENAME mantidworkbench${DEST_FILENAME_SUFFIX} + RENAME launch_mantidworkbench${DEST_FILENAME_SUFFIX} ) endforeach() endif() diff --git a/conda/recipes/mantidworkbench/meta.yaml b/conda/recipes/mantidworkbench/meta.yaml index d371bc47edf9..779e3bf28bbd 100644 --- a/conda/recipes/mantidworkbench/meta.yaml +++ b/conda/recipes/mantidworkbench/meta.yaml @@ -10,7 +10,8 @@ source: build: number: 0 entry_points: - - workbench = workbench.app.main:main + - workbench = workbench.app.mantidworkbench_launch_wrapper:launch + - mantidworkbench = workbench.app.mantidworkbench_launch_wrapper:launch osx_is_app: true ignore_run_exports_from: - {{ compiler('cxx') }} diff --git a/docs/source/release/v6.12.0/Workbench/New_features/37538.rst b/docs/source/release/v6.12.0/Workbench/New_features/37538.rst new file mode 100644 index 000000000000..d2e11f4f8e27 --- /dev/null +++ b/docs/source/release/v6.12.0/Workbench/New_features/37538.rst @@ -0,0 +1,2 @@ +- Add ``mantidworkbench`` as an entry point to launch the mantidworkbench Conda package. +- Configure the Conda ``workbench`` and ``mantidworkbench`` entry points to launch workbench with jemalloc on Linux. diff --git a/installers/conda/common/common.sh b/installers/conda/common/common.sh index b896be0e460b..1bcbfdd05bc4 100644 --- a/installers/conda/common/common.sh +++ b/installers/conda/common/common.sh @@ -21,9 +21,9 @@ function trim_conda() { cp "$bundle_conda_prefix"/bin_tmp/Mantid.properties "$bundle_conda_prefix"/bin/ cp "$bundle_conda_prefix"/bin_tmp/mantid-scripts.pth "$bundle_conda_prefix"/bin/ cp "$bundle_conda_prefix"/bin_tmp/workbench "$bundle_conda_prefix"/bin/ - if [ -f "$bundle_conda_prefix"/bin_tmp/mantidworkbench.standalone ]; then + if [ -f "$bundle_conda_prefix"/bin_tmp/launch_mantidworkbench.standalone ]; then # keep handwritten startup script used on Linux so that we use jemalloc - cp "$bundle_conda_prefix"/bin_tmp/mantidworkbench.standalone "$bundle_conda_prefix"/bin/mantidworkbench + cp "$bundle_conda_prefix"/bin_tmp/launch_mantidworkbench.standalone "$bundle_conda_prefix"/bin/launch_mantidworkbench fi # Heavily cut down share mv "$bundle_conda_prefix"/share "$bundle_conda_prefix"/share_tmp diff --git a/installers/conda/linux/create_tarball.sh b/installers/conda/linux/create_tarball.sh index eb9e1f24757a..242cf609345e 100755 --- a/installers/conda/linux/create_tarball.sh +++ b/installers/conda/linux/create_tarball.sh @@ -43,7 +43,7 @@ function fixup_bundle() { echo "Fixing up bundle so it is self contained" # Fix absolute paths in Qt and our own startup script fixup_qt "$bundle_conda_prefix" "$HERE"/../common/qt.conf - sed -i -e "s@$bundle_prefix_absolute/@\$INSTALLDIR/@" $bundle_prefix_absolute/bin/mantidworkbench + sed -i -e "s@$bundle_prefix_absolute/@\$INSTALLDIR/@" $bundle_prefix_absolute/bin/launch_mantidworkbench } # Create a tarball out of the installed conda environment diff --git a/qt/applications/workbench/workbench/app/main.py b/qt/applications/workbench/workbench/app/main.py index c268ed13a527..fa29cbdecd24 100644 --- a/qt/applications/workbench/workbench/app/main.py +++ b/qt/applications/workbench/workbench/app/main.py @@ -12,7 +12,7 @@ import warnings -def main(): +def main(args=None): # setup command line arguments parser = argparse.ArgumentParser(description="Mantid Workbench") parser.add_argument("script", nargs="?") @@ -45,7 +45,7 @@ def main(): pass # silently skip this # parse the command line options - options = parser.parse_args() + options = parser.parse_args(args=args) if options.error_on_warning: warnings.simplefilter("error") # Change the filter in this process diff --git a/qt/applications/workbench/workbench/app/mantidworkbench_launch_wrapper.py b/qt/applications/workbench/workbench/app/mantidworkbench_launch_wrapper.py new file mode 100644 index 000000000000..ef3ec64a929a --- /dev/null +++ b/qt/applications/workbench/workbench/app/mantidworkbench_launch_wrapper.py @@ -0,0 +1,25 @@ +# Mantid Repository : https://github.com/mantidproject/mantid +# +# Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, +# NScD Oak Ridge National Laboratory, European Spallation Source, +# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +# SPDX - License - Identifier: GPL - 3.0 + +# This file is part of the mantid workbench. +import subprocess +import sys + +from workbench.app.main import main + + +def launch(args=None): + if args is None: + args = sys.argv + if sys.platform.startswith("linux"): + command = ["launch_mantidworkbench"] + args[1:] + subprocess.run(command) + else: + main(args[1:]) + + +if __name__ == "__main__": + sys.exit(launch(sys.argv))