Skip to content

Commit

Permalink
Merge pull request #38686 from peterfpeterson/38654_launch_script_in_…
Browse files Browse the repository at this point in the history
…editor_ornlnext

Add mantidworkbench as an entry point for the mantidworkbench Conda package - ornl-next
  • Loading branch information
peterfpeterson authored Jan 23, 2025
2 parents f3399cf + 45937ae commit 6bb3712
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
7 changes: 3 additions & 4 deletions buildconfig/CMake/LinuxPackageScripts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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()
3 changes: 2 additions & 1 deletion conda/recipes/mantidworkbench/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
2 changes: 2 additions & 0 deletions docs/source/release/v6.12.0/Workbench/New_features/37538.rst
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions installers/conda/common/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion installers/conda/linux/create_tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions qt/applications/workbench/workbench/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="?")
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 6bb3712

Please sign in to comment.