diff --git a/README.md b/README.md index 81b00e4a..4374a77e 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ MaCh3 is predominantly C++ software, although some functionality is available th 2. [Sigma Variations](#sigma-variations) ## How to Start? -To compile simply +To compile try ```bash git clone https://github.com/mach3-software/MaCh3Tutorial.git mkdir build; @@ -51,11 +51,63 @@ then source bin/setup.MaCh3.sh source bin/setup.MaCh3Tutorial.sh ``` -alternatively you can use containers by + +If this does not work, check out the [Requirements](https://github.com/mach3-software/MaCh3/tree/Charlotte-Knight/tidy/MaCh3-on-Mac?tab=readme-ov-file#system-requirements) for MaCh3 in case you are missing something. + +One of the suggestions in [Requirements](https://github.com/mach3-software/MaCh3/tree/Charlotte-Knight/tidy/MaCh3-on-Mac?tab=readme-ov-file#system-requirements) is to use a conda/micromamba environment. You can install everything you need and build the tutorial using these commands: + +
+Click to see commands + +To install micromamba and the environment needed to build MaCh3: +```bash +mkdir MaCh3Things && cd MaCh3Things + +echo "" | BIN_FOLDER=".micromamba" INIT_YES="n" CONDA_FORGE_YES="y" "${SHELL}" <(curl -L micro.mamba.pm/install.sh) + +cat > env.sh <<'EOF' +export MAMBA_ROOT_PREFIX="$(pwd)/.micromamba" +command="$(${MAMBA_ROOT_PREFIX}/micromamba shell hook -s posix)" +eval "$command" +EOF + +source env.sh + +micromamba env create -n MaCh3 -c conda-forge root cmake -y +micromamba activate MaCh3 +``` +and then to build MaCh3: +```bash +git clone https://github.com/mach3-software/MaCh3Tutorial.git +cd MaCh3Tutorial + +mkdir build && cd build +cmake ../ +make -j8 +make install + +source bin/setup.MaCh3.sh +source bin/setup.MaCh3Tutorial.sh +``` + +> **Note:** To run the tutorial from a fresh terminal after this installation you must source and activate the relevant scripts and environments: +>```bash +> cd MaCh3Things +> source env.sh # source micromamba +> micromamba activate MaCh3 +> +> cd MaCh3Tutorial/build +> source bin/setup.MaCh3.sh +> source bin/setup.MaCh3Tutorial.sh +>``` +
+ + +Alternatively you can use containers by ```bash docker pull ghcr.io/mach3-software/mach3tutorial:alma9latest ``` -To read more about how to use containers, check our wiki [here](https://github.com/mach3-software/MaCh3/wiki/12.-Containers) +To read more about how to use containers, check our wiki [here](https://github.com/mach3-software/MaCh3/wiki/12.-Containers). ## How to run MCMC To run MCMC simply diff --git a/cmake/Templates/setup.MaCh3Tutorial.sh.in b/cmake/Templates/setup.MaCh3Tutorial.sh.in index 150455c5..db250e63 100755 --- a/cmake/Templates/setup.MaCh3Tutorial.sh.in +++ b/cmake/Templates/setup.MaCh3Tutorial.sh.in @@ -49,21 +49,62 @@ function add_to_LD_LIBRARY_PATH () { fi +if ! type add_to_DYLD_LIBRARY_PATH &> /dev/null; then + +function add_to_DYLD_LIBRARY_PATH () { + for d; do + + d=$(cd -- "$d" && { pwd -P || pwd; }) 2>/dev/null # canonicalize symbolic links + if [ -z "$d" ]; then continue; fi # skip nonexistent directory + + if [[ "$d" == "/usr/lib" ]] || [[ "$d" == "/usr/lib64" ]] || [[ "$d" == "/usr/local/lib" ]] || [[ "$d" == "/usr/local/lib64" ]]; then + case ":$DYLD_LIBRARY_PATH:" in + *":$d:"*) :;; + *) export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$d;; + esac + else + case ":$DYLD_LIBRARY_PATH:" in + *":$d:"*) :;; + *) export DYLD_LIBRARY_PATH=$d:$DYLD_LIBRARY_PATH;; + esac + fi + done +} + +fi + +if [ -n "$BASH_VERSION" ]; then + SCRIPT_PATH="${BASH_SOURCE[0]}" +elif [ -n "$ZSH_VERSION" ]; then + SCRIPT_PATH="${(%):-%x}" +else + echo "Unsupported shell" + return 1 +fi + #if it was sourced as . setup.sh then you can't scrub off the end... assume that #we are in the correct directory. -if ! echo "${BASH_SOURCE}" | grep "/" --silent; then +if ! echo "${SCRIPT_PATH}" | grep "/" --silent; then SETUPDIR=$(readlink -f ${PWD}/..) else - SETUPDIR=$(readlink -f ${BASH_SOURCE%/*}/..) + SETUPDIR=$(readlink -f ${SCRIPT_PATH%/*}/..) fi export MaCh3Tutorial_ROOT=${SETUPDIR} export MACH3=${SETUPDIR} add_to_PATH ${MaCh3Tutorial_ROOT}/CIValidations -add_to_LD_LIBRARY_PATH ${MaCh3Tutorial_ROOT}/lib -if [ -d "${MaCh3Tutorial_ROOT}/lib64" ]; then - add_to_LD_LIBRARY_PATH ${MaCh3Tutorial_ROOT}/lib64 + +if [[ "$(uname)" == "Darwin" ]]; then # macOS + add_to_DYLD_LIBRARY_PATH ${MaCh3Tutorial_ROOT}/lib + if [ -d "${MaCh3Tutorial_ROOT}/lib64" ]; then + add_to_DYLD_LIBRARY_PATH ${MaCh3Tutorial_ROOT}/lib64 + fi +else + add_to_LD_LIBRARY_PATH ${MaCh3Tutorial_ROOT}/lib + if [ -d "${MaCh3Tutorial_ROOT}/lib64" ]; then + add_to_LD_LIBRARY_PATH ${MaCh3Tutorial_ROOT}/lib64 + fi fi unset SETUPDIR