diff --git a/rpm/nsd-app-wrap.spec b/rpm/nsd-app-wrap.spec index 3cf8a528d16eb37d79c0341c6e9d6b15f67aa2e7..d6a7bf2e114a00f5f4ef684f77332c719c544bd3 100644 --- a/rpm/nsd-app-wrap.spec +++ b/rpm/nsd-app-wrap.spec @@ -1,5 +1,5 @@ Name: nsd-app-wrap -Version: 2.11 +Version: 2.12 Release: 1%{?dist} Summary: Wrapper scripts to launch python applications installed via anaconda Vendor: Peter F. Peterson @@ -27,7 +27,8 @@ mkdir -p %{buildroot}%{_bindir}/ install -m 755 addie %{buildroot}%{_bindir}/ install -m 755 data2config %{buildroot}%{_bindir}/ install -m 755 drtsans %{buildroot}%{_bindir}/ -install -m 755 gsas2 %{buildroot}%{_bindir}/ +# no pixi environment exists yet +#install -m 755 gsas2 {buildroot}{_bindir}/ install -m 755 hyspecppt %{buildroot}%{_bindir}/ install -m 755 ibeatles %{buildroot}%{_bindir}/ install -m 755 inspired %{buildroot}%{_bindir}/ @@ -41,7 +42,8 @@ install -m 755 mantidpython %{buildroot}%{_bindir}/ install -m 755 mantidworkbench %{buildroot}%{_bindir}/ install -m 755 mantidtotalscattering %{buildroot}%{_bindir}/ install -m 755 mcstas %{buildroot}%{_bindir}/ -install -m 755 neutron-imaging %{buildroot}%{_bindir}/ +# not used right now - things that look like scriptlets cannot be in comments +#install -m 755 neutron-imaging {buildroot}{_bindir}/ install -m 755 nr_launcher %{buildroot}%{_bindir}/ install -m 755 nsd-app-wrap.sh %{buildroot}%{_bindir}/ install -m 755 nsd-conda-wrap.sh %{buildroot}%{_bindir}/ diff --git a/src/addie b/src/addie index ba8b45967c3f9b506f1137141a24faa9fd20346b..001003526d4153f2b61ea351e923643be8c22432 100644 --- a/src/addie +++ b/src/addie @@ -31,9 +31,9 @@ fi # put together arguments - conda_env, application, argv if [ -n "${mode_arg}" ]; then - args=("${PIXI_ENVIRON}" "start_gui" "${mode_arg}" "${@}") + args=("${PIXI_ENVIRON}" "addie" "${mode_arg}" "${@}") else - args=("${PIXI_ENVIRON}" "start_gui" "${@}") + args=("${PIXI_ENVIRON}" "addie" "${@}") fi # launch the tool pixi_launch "${args[@]}" diff --git a/src/gsas2 b/src/gsas2 index 729d7e598c3df3b46efddf05fb9210defe8d3ac4..65168c9aa2fb0e633724d194e5e4813f3174f8ed 100644 --- a/src/gsas2 +++ b/src/gsas2 @@ -1,14 +1,11 @@ #!/bin/sh -# select the environment to use -PIXI_ENVIRON=gsas2 - -# import library to do the real work -. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" \ - || . /bin/nsd-app-wrap.sh - -# put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") -# launch the tool -pixi_launch "${args[@]}" - +###################################################################### +# Currently this scipt is not used +###################################################################### +exit 1 + +###################################################################### +# remove a single # from each of the following lines +###################################################################### +#"$(dirname "$(realpath "$0")")/nsd-conda-wrap.sh" gsas2 --classic /path/to/GSASII.py diff --git a/src/hyspecppt b/src/hyspecppt index 25d718150a3c7f4aa67649dd5caf13a73677f438..10d02d3afbac7bf77e1357f26026137bfad07778 100644 --- a/src/hyspecppt +++ b/src/hyspecppt @@ -19,6 +19,6 @@ fi || . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "hyspecppt" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/ibeatles b/src/ibeatles index 3f07b20a1d70b8884cd735c591ac8066bb47d03a..567f8997e967de6b31ad3c3639e75890855e75bd 100644 --- a/src/ibeatles +++ b/src/ibeatles @@ -10,7 +10,6 @@ PIXI_ENVIRON=ibeatles || . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "start" "$@") # launch the tool pixi_launch "${args[@]}" - diff --git a/src/inspired b/src/inspired index 6fc766016d8fd3711f6800c94b51a270857aaa60..c50ccaef51fcdf02df566bd7504e8432eea9c6e2 100644 --- a/src/inspired +++ b/src/inspired @@ -19,6 +19,6 @@ fi . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "inspired" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/licorne b/src/licorne index 1a1e9a36a31e4605f075be9e2adcbeeca0c1980e..756a3a79e1efe7d539f99b7b05c97e36480a23d1 100644 --- a/src/licorne +++ b/src/licorne @@ -10,6 +10,6 @@ PIXI_ENVIRON=licorne . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "licorne" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/mantidtotalscattering b/src/mantidtotalscattering index 450994668d03225abc03bf9daf7e1c4e45d6578d..fadeffaeb9cb3421609e9945d89fb18813b6b8a5 100644 --- a/src/mantidtotalscattering +++ b/src/mantidtotalscattering @@ -18,6 +18,6 @@ fi . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "mantidtotalscattering" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/mantidworkbench b/src/mantidworkbench old mode 100644 new mode 100755 index aa719f6302b061e2a5f38ca95b0ccc7fab472c7e..5489bc8e356d9f19e143a99cb9e9a140bd85326f --- a/src/mantidworkbench +++ b/src/mantidworkbench @@ -4,26 +4,23 @@ . "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" || . /bin/nsd-app-wrap.sh +# default conda environment if it was not specified +PIXI_ENV="mantid" + # look for a supplied argument for var in "$@"; do case "$var" in --env=*) PIXI_ENV=$(echo "${var}" | awk -F"=" '{print $2}') - PIXI_TASK="start_mantid" shift 1 # remove this argument ;; --env) PIXI_ENV="$2" # look ahead by one - PIXI_TASK="start_mantid" shift 2 # remove the flag and value ;; esac done -# default conda environment if it was not specified -if [ -z "${PIXI_ENV}" ]; then - PIXI_ENV="mantid" - PIXI_TASK="start_gui" -fi +PIXI_TASK="mantidworkbench" # put together arguments - conda_env, application, argv args=("${PIXI_ENV}" "${PIXI_TASK}" "$@") diff --git a/src/mantidworkbenchnightly b/src/mantidworkbenchnightly index 6eb4827cd73531c8e67ad7f7f0279c857ececb38..02cb3318bef4d1e6439de56c2255e695ef0bf0e3 100644 --- a/src/mantidworkbenchnightly +++ b/src/mantidworkbenchnightly @@ -1,11 +1,4 @@ #!/bin/bash -# import library to do the real work -# shellcheck disable=SC1091 -. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" || - . /bin/nsd-app-wrap.sh - -# put together arguments - conda_env, application, argv +# call the main mantidworkbench with an environment PIXI_ENV="mantid_dev" -args=("${PIXI_ENV}" "start_gui" "$@") -# launch the tool -pixi_launch "${args[@]}" +"$(dirname "$(realpath "$0")")/mantidworkbench" --env "${PIXI_ENV}" diff --git a/src/mantidworkbenchqa b/src/mantidworkbenchqa index c51b591f3c9cb407ac25edbe42a110aaf26f869a..9c0aceee8c36c48969cd289ba65c83c96110b18a 100644 --- a/src/mantidworkbenchqa +++ b/src/mantidworkbenchqa @@ -1,11 +1,4 @@ #!/bin/bash -# import library to do the real work -# shellcheck disable=SC1091 -. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" || - . /bin/nsd-app-wrap.sh - -# put together arguments - conda_env, application, argv +# call the main mantidworkbench with an environment PIXI_ENV="mantid_qa" -args=("${PIXI_ENV}" "start_gui" "$@") -# launch the tool -pixi_launch "${args[@]}" +"$(dirname "$(realpath "$0")")/mantidworkbench" --env "${PIXI_ENV}" diff --git a/src/mcstas b/src/mcstas index 08387a60c8af932a84ef267fdd52f2c3f16acf7f..a2c2e2d9895e5d0881ea653f672c1b6e45246bb7 100644 --- a/src/mcstas +++ b/src/mcstas @@ -10,6 +10,6 @@ PIXI_ENVIRON=mctsas || . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "mcgui" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/neutron-imaging b/src/neutron-imaging index d1f47938989d8b30ebe45e5e90fe317026e01b03..a09e712abb6c17f2f3d89497609bcf4708505f84 100644 --- a/src/neutron-imaging +++ b/src/neutron-imaging @@ -1,29 +1,38 @@ #!/bin/sh -# select the environment to use -CONDA_ENVIRON=neutron-imaging -NOTEBOOK_DIR=~/notebooks/IPTS_notebooks -if [ -n "$1" ]; then - if [ "--dev" = "$1" ]; then - CONDA_ENVIRON=neutron-imaging-dev - NOTEBOOK_DIR=~/notebooks/IPTS_notebooks_testing - shift # drop this argument - fi -fi +###################################################################### +# Currently this scipt is not used +###################################################################### +echo "Contact Jean Bilheux for alternate method of running the notebooks" +exit 1 -# import library to do the real work -. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" - -# activate the environment - will be deactivated on exit -activate_conda_environment "${CONDA_ENVIRON}" - -# start the application -echo "Update the notebooks..." -rsync --exclude '.git*' -a /SNS/software/share/jupyter/notebooks/ ~/notebooks/ -echo "Done!" - -cd $NOTEBOOK_DIR || exit 1 - -echo "Starting Jupyter... (be patient please while we set up your system!)" -# assumes the correct jupyter is in the path -jupyter notebook notebooks +###################################################################### +# remove a single # from each of the following lines +###################################################################### +## select the environment to use +#CONDA_ENVIRON=neutron-imaging +#NOTEBOOK_DIR=~/notebooks/IPTS_notebooks +#if [ -n "$1" ]; then +# if [ "--dev" = "$1" ]; then +# CONDA_ENVIRON=neutron-imaging-dev +# NOTEBOOK_DIR=~/notebooks/IPTS_notebooks_testing +# shift # drop this argument +# fi +#fi +# +## import library to do the real work +#. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" +# +## activate the environment - will be deactivated on exit +#activate_conda_environment "${CONDA_ENVIRON}" +# +## start the application +#echo "Update the notebooks..." +#rsync --exclude '.git*' -a /SNS/software/share/jupyter/notebooks/ ~/notebooks/ +#echo "Done!" +# +#cd $NOTEBOOK_DIR || exit 1 +# +#echo "Starting Jupyter... (be patient please while we set up your system!)" +## assumes the correct jupyter is in the path +#jupyter notebook notebooks diff --git a/src/nsd-app-wrap.sh b/src/nsd-app-wrap.sh index cbcd315edbd5671e2b502f7f9ff6a4f374e29edd..c75a94e32b3af7934f3e07c344a0dd99e3847853 100755 --- a/src/nsd-app-wrap.sh +++ b/src/nsd-app-wrap.sh @@ -1,9 +1,8 @@ #!/bin/bash -CONDA_PREFIX_CENTRAL="/opt/anaconda" -CONDA_ACTIVATE_SCRIPT="${CONDA_PREFIX_CENTRAL}/bin/activate" -# several places have conda installed in /usr/local and link it over -CONDA_PREFIX_ALT="/usr/local/anaconda" +# overwrite this value with environment injection e.g. +# PIXI_PREFIX=/path/to/pixitoml/parent/dir nsd-app-wrap.sh +PIXI_PREFIX="${PIXI_PREFIX:=/usr/local/pixi}" ########## Utility functions _remove_font_cache() { @@ -14,114 +13,58 @@ _remove_font_cache() { fi } -########## Connect to central conda command -_activate_conda_cmd() { - if [ -f "${CONDA_ACTIVATE_SCRIPT}" ]; then - # shellcheck disable=SC1090,SC1091,SC2039 - . "${CONDA_ACTIVATE_SCRIPT}" "" # don't let command line arguments in - else - echo "\"${CONDA_ACTIVATE_SCRIPT}\" not found" - exit 255 - fi -} - -_activate_central_anaconda() { - if [ "$(command -v conda)" ]; then - if [ "${CONDA_ACTIVATE_SCRIPT}" != "$(which conda)" ]; then - echo "Switching to central anaconda install in \"${CONDA_PREFIX_CENTRAL}\"" - _activate_conda_cmd - fi - else - echo "Activating central anaconda install in \"${CONDA_PREFIX_CENTRAL}\"" - _activate_conda_cmd - fi - - # make sure that conda is found in the correct place - if [ "${CONDA_PREFIX}" != "${CONDA_PREFIX_CENTRAL}" ] && [ "${CONDA_PREFIX}" != "${CONDA_PREFIX_ALT}" ]; then - echo "Found conda at \"${CONDA_PREFIX}\" rather than \"${CONDA_PREFIX_CENTRAL}\"" - exit 255 - fi -} +########## Generate the path to the manifest directory +# if the +_get_pixi_manifest_path() { + # pixi environment + PIXI_ENV="${1}" -# this should be included in scripts after activate_conda_environment -# but before the actual command to be activated using a trap -# -# trap deactivate_conda_environment EXIT -# -# this will preserve the exit code from the main command -_deactivate_conda_environment() { - echo "Deactivate conda environment" - conda deactivate + echo "${PIXI_PREFIX%/}/${PIXI_ENV}" } -########## Activate the environment in the central conda install -activate_conda_environment () { - CONDA_EXP_ENV="${1}" - - # verify that central conda install is the one being used - _activate_central_anaconda - - # activate the environment - conda activate "${CONDA_EXP_ENV}" - - # verify that the correct one was activated - if [ ! "$CONDA_DEFAULT_ENV" == "$CONDA_EXP_ENV" ]; then - echo "Failed to activate \"${CONDA_EXP_ENV}\" conda environment" - exit 255 - else - echo "Activated \"$CONDA_EXP_ENV\" conda environment" +########## Activate the environment in the central pixi install +# this assumes that "pixi" is in the user's path +activate_pixi_environment () { + # pixi environment + PIXI_ENV="${1}" + + _path_to_manifest=$(_get_pixi_manifest_path "${PIXI_ENV}") + # check the directory exists + if [ ! -d "${_path_to_manifest}" ]; then + echo "Manfest path does not exist: ${_path_to_manifest}" + exit 1 # error ends the script fi - # unload the environment on exit - trap _deactivate_conda_environment EXIT + # activate the environment + pixi shell --frozen --manifest-path "${_path_to_manifest}" } ########## Activate the environment and start the application -# The arguments are (conda_env, command, argv) and can be put +# The arguments are (pixi_env, command, argv) and can be put # together and supplied like # # args=("mantid-dev" "mantidworkbench" "$@") -# activate_and_launch "${args[@]}" -activate_and_launch() { - # first argument is conda environment - CONDA_EXP_ENV="${1}" - shift - # second argument is startup command - COMMAND="${1}" - shift - # the rest is passed to the command being started - - _remove_font_cache - activate_conda_environment "${CONDA_EXP_ENV}" - - echo "Execute: ${COMMAND} $*" - "${COMMAND}" "$@" -} - +# pixi_launch "${args[@]}" +# +# This assumes that "pixi" is in the user's path pixi_launch() { - PIXI_PREFIX="/usr/local/pixi" - PIXI_ENV="${1}" - shift - # This grabs everything past the first argument - PIXI_TASK="${*}" - - path_to_manifest="${PIXI_PREFIX%/}/${PIXI_ENV}" - - # Verify path_to_manifest directory exists - if [ ! -d "${path_to_manifest}" ]; then - echo "No pixi environment found at ${path_to_manifest}" - exit 1 - fi - - #echo "P: $PIXI_PREFIX, E: $PIXI_ENV, T: $PIXI_TASK - ptm: $path_to_manifest." - - _remove_font_cache - - pixi_run="pixi run --frozen --manifest-path $path_to_manifest $PIXI_TASK" - - #echo "pixi command: $pixi_run" - - $pixi_run + # first argument is pixi environment + PIXI_ENV="${1}" + shift + # second argument is startup command + COMMAND="${1}" + shift + # the rest is passed to the command being started + + _path_to_manifest=$(_get_pixi_manifest_path "${PIXI_ENV}") + # check the directory exists + if [ ! -d "${_path_to_manifest}" ]; then + echo "Manfest path does not exist: ${_path_to_manifest}" + exit 1 # error ends the script + fi + _remove_font_cache + # activate the environment and run the command + echo "run \"${COMMAND} $*\" in the \"${PIXI_ENV}\" pixi environment" + pixi run --frozen --manifest-path "${_path_to_manifest}" "${COMMAND}" "$@" } - diff --git a/src/nsd-conda-wrap.sh b/src/nsd-conda-wrap.sh index ee47dad6d563b0fcab6e01388dc14d73d8f77708..f6e7c63ce9f00b129a046dd855629a5c7565e419 100755 --- a/src/nsd-conda-wrap.sh +++ b/src/nsd-conda-wrap.sh @@ -33,8 +33,7 @@ fi . "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" || . /bin/nsd-app-wrap.sh -# launch pixi # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "$STARTUP" "$@") -# launch the tool +args=("${PIXI_ENVIRON}" "$STARTUP" "$@") +# launch pixi pixi_launch "${args[@]}" diff --git a/src/paraview b/src/paraview old mode 100644 new mode 100755 index 40ae384a988b8aaf8d2ad2b23a211cccf0314513..8da352122e628580c3f4b45fd85b2aa397d6b1d4 --- a/src/paraview +++ b/src/paraview @@ -4,8 +4,9 @@ # current default is system version PIXI_ENVIRON=paraview # import library to do the real work -. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" \ - || . /bin/nsd-app-wrap.sh +# shellcheck disable=SC1091 +. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" || + . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv args=("${PIXI_ENVIRON}" "paraview" "$@") diff --git a/src/pdfgui2 b/src/pdfgui2 index a9c248dcc16ed9bfa3279009e962f6cc548c4e57..af8209f018d2f480a01f938d7a0e74e939654657 100644 --- a/src/pdfgui2 +++ b/src/pdfgui2 @@ -9,7 +9,7 @@ PIXI_ENVIRON=pdfgui . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "pdfgui" "$@") # start the application pixi_launch "${args[@]}" diff --git a/src/quicknxs b/src/quicknxs index c01d79cd8347c7efbca9702d187436304a9fafa0..05599904357fd5e82f67c4c23dac53928ee93c33 100644 --- a/src/quicknxs +++ b/src/quicknxs @@ -18,7 +18,6 @@ fi . "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" \ || . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "quicknxs-gui" "$@") # launch the tool pixi_launch "${args[@]}" - diff --git a/src/refl1d b/src/refl1d index 97b2d469817e6df5fe271756e010845ee08d263a..728c657637ad555bc275c445bb8b48fa7c99bc5c 100644 --- a/src/refl1d +++ b/src/refl1d @@ -24,6 +24,6 @@ fi . /bin/nsd-app-wrap.sh # Resolves to /bin/nsd-app-wrap.sh ? # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "refl1d" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/refred b/src/refred index f188dced09e06a9e9679611b6ed904c4351f25b4..2987cb9217c7ac3a955dbbb8f624364bfc264168 100644 --- a/src/refred +++ b/src/refred @@ -18,6 +18,6 @@ fi . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "refred-gui" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/sasview b/src/sasview index 9d85dca8c8975260d605b357f5e8ddc3e65bfe16..71149898a94fe4b4a891ddedc5b8b4a853633901 100644 --- a/src/sasview +++ b/src/sasview @@ -10,6 +10,6 @@ PIXI_ENVIRON=sasview . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "sasview" "$@") # launch the tool pixi_launch "${args[@]}" diff --git a/src/shiver b/src/shiver index 31778001e77a71b346df9660239e5645ff30754b..dec673fc777fe4cea82f00b98b7cea8c24f10ff9 100644 --- a/src/shiver +++ b/src/shiver @@ -18,6 +18,6 @@ fi . /bin/nsd-app-wrap.sh # put together arguments - conda_env, application, argv -args=("${PIXI_ENVIRON}" "start_gui" "$@") +args=("${PIXI_ENVIRON}" "shiver" "$@") # launch the tool pixi_launch "${args[@]}"