Skip to content

Commit 6bb3712

Browse files
Merge pull request #38686 from peterfpeterson/38654_launch_script_in_editor_ornlnext
Add mantidworkbench as an entry point for the mantidworkbench Conda package - ornl-next
2 parents f3399cf + 45937ae commit 6bb3712

File tree

7 files changed

+37
-10
lines changed

7 files changed

+37
-10
lines changed

buildconfig/CMake/LinuxPackageScripts.cmake

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ set(PYTHON_ARGS " -Wdefault::DeprecationWarning -Werror:::mantid -Werror:::manti
109109
set(PYTHON_EXEC_LOCAL "\${CONDA_PREFIX}/bin/python")
110110
set(PREAMBLE "${CONDA_PREAMBLE_TEXT}")
111111
set(LOCAL_PYPATH "${CMAKE_CURRENT_BINARY_DIR}/bin/")
112+
# The python command to start workbench
113+
set(MANTIDWORKBENCH_EXEC "-c \"from workbench.app.main import main; main()\"")
112114

113115
# used by mantidworkbench
114116
if(ENABLE_WORKBENCH)
115-
set(MANTIDWORKBENCH_EXEC "-m workbench") # what the actual thing is called
116117
configure_file(
117118
${CMAKE_MODULE_PATH}/Packaging/launch_mantidworkbench.sh.in
118119
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launch_mantidworkbench.sh @ONLY
@@ -138,13 +139,11 @@ if(ENABLE_WORKBENCH)
138139
set(LOCAL_PYPATH "\${CONDA_PREFIX}/bin:\${CONDA_PREFIX}/lib:\${CONDA_PREFIX}/plugins")
139140
set(PYTHON_EXEC_LOCAL "\${CONDA_PREFIX}/bin/python")
140141
set(PREAMBLE "${CONDA_PREAMBLE_TEXT}")
141-
set(MANTIDWORKBENCH_EXEC "-m workbench") # what the actual thing is called
142142
set(DEST_FILENAME_SUFFIX "")
143143
elseif(${install_type} STREQUAL "standalone")
144144
set(LOCAL_PYPATH "\${INSTALLDIR}/bin:\${INSTALLDIR}/lib:\${INSTALLDIR}/plugins")
145145
set(PYTHON_EXEC_LOCAL "\${INSTALLDIR}/bin/python")
146146
set(PREAMBLE "${SYS_PREAMBLE_TEXT}")
147-
set(MANTIDWORKBENCH_EXEC "-m workbench")
148147
set(DEST_FILENAME_SUFFIX ".standalone")
149148
else()
150149
message(FATAL_ERROR "Unknown installation type '${install_type}' for workbench startup scripts")
@@ -157,7 +156,7 @@ if(ENABLE_WORKBENCH)
157156
install(
158157
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/launch_mantidworkbench.sh.install${DEST_FILENAME_SUFFIX}
159158
DESTINATION ${BIN_DIR}
160-
RENAME mantidworkbench${DEST_FILENAME_SUFFIX}
159+
RENAME launch_mantidworkbench${DEST_FILENAME_SUFFIX}
161160
)
162161
endforeach()
163162
endif()

conda/recipes/mantidworkbench/meta.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ source:
1010
build:
1111
number: 0
1212
entry_points:
13-
- workbench = workbench.app.main:main
13+
- workbench = workbench.app.mantidworkbench_launch_wrapper:launch
14+
- mantidworkbench = workbench.app.mantidworkbench_launch_wrapper:launch
1415
osx_is_app: true
1516
ignore_run_exports_from:
1617
- {{ compiler('cxx') }}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Add ``mantidworkbench`` as an entry point to launch the mantidworkbench Conda package.
2+
- Configure the Conda ``workbench`` and ``mantidworkbench`` entry points to launch workbench with jemalloc on Linux.

installers/conda/common/common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function trim_conda() {
2121
cp "$bundle_conda_prefix"/bin_tmp/Mantid.properties "$bundle_conda_prefix"/bin/
2222
cp "$bundle_conda_prefix"/bin_tmp/mantid-scripts.pth "$bundle_conda_prefix"/bin/
2323
cp "$bundle_conda_prefix"/bin_tmp/workbench "$bundle_conda_prefix"/bin/
24-
if [ -f "$bundle_conda_prefix"/bin_tmp/mantidworkbench.standalone ]; then
24+
if [ -f "$bundle_conda_prefix"/bin_tmp/launch_mantidworkbench.standalone ]; then
2525
# keep handwritten startup script used on Linux so that we use jemalloc
26-
cp "$bundle_conda_prefix"/bin_tmp/mantidworkbench.standalone "$bundle_conda_prefix"/bin/mantidworkbench
26+
cp "$bundle_conda_prefix"/bin_tmp/launch_mantidworkbench.standalone "$bundle_conda_prefix"/bin/launch_mantidworkbench
2727
fi
2828
# Heavily cut down share
2929
mv "$bundle_conda_prefix"/share "$bundle_conda_prefix"/share_tmp

installers/conda/linux/create_tarball.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function fixup_bundle() {
4343
echo "Fixing up bundle so it is self contained"
4444
# Fix absolute paths in Qt and our own startup script
4545
fixup_qt "$bundle_conda_prefix" "$HERE"/../common/qt.conf
46-
sed -i -e "s@$bundle_prefix_absolute/@\$INSTALLDIR/@" $bundle_prefix_absolute/bin/mantidworkbench
46+
sed -i -e "s@$bundle_prefix_absolute/@\$INSTALLDIR/@" $bundle_prefix_absolute/bin/launch_mantidworkbench
4747
}
4848

4949
# Create a tarball out of the installed conda environment

qt/applications/workbench/workbench/app/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import warnings
1313

1414

15-
def main():
15+
def main(args=None):
1616
# setup command line arguments
1717
parser = argparse.ArgumentParser(description="Mantid Workbench")
1818
parser.add_argument("script", nargs="?")
@@ -45,7 +45,7 @@ def main():
4545
pass # silently skip this
4646

4747
# parse the command line options
48-
options = parser.parse_args()
48+
options = parser.parse_args(args=args)
4949

5050
if options.error_on_warning:
5151
warnings.simplefilter("error") # Change the filter in this process
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Mantid Repository : https://github.com/mantidproject/mantid
2+
#
3+
# Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI,
4+
# NScD Oak Ridge National Laboratory, European Spallation Source,
5+
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6+
# SPDX - License - Identifier: GPL - 3.0 +
7+
# This file is part of the mantid workbench.
8+
import subprocess
9+
import sys
10+
11+
from workbench.app.main import main
12+
13+
14+
def launch(args=None):
15+
if args is None:
16+
args = sys.argv
17+
if sys.platform.startswith("linux"):
18+
command = ["launch_mantidworkbench"] + args[1:]
19+
subprocess.run(command)
20+
else:
21+
main(args[1:])
22+
23+
24+
if __name__ == "__main__":
25+
sys.exit(launch(sys.argv))

0 commit comments

Comments
 (0)