Skip to content

Commit

Permalink
Merge pull request #184 from mabarnes/machine-setup-macos
Browse files Browse the repository at this point in the history
Make machine setup scripts work on MacOS
  • Loading branch information
johnomotani authored Apr 8, 2024
2 parents 1ae96de + 93caa51 commit 573c966
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion machines/generic-batch-template/compile_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fi
if [[ $BUILDHDF5 == "y" ]]; then
HDF5=hdf5-1.14.3
# Download and extract the source
wget -O ${HDF5}.tar.bz2 https://www.hdfgroup.org/package/hdf5-1-14-3-tar-bz2/?wpdmdl=18469
wget -O ${HDF5}.tar.bz2 https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.3/src/hdf5-1.14.3.tar.bz2
tar xjf ${HDF5}.tar.bz2

cd $HDF5
Expand Down
2 changes: 1 addition & 1 deletion machines/generic-pc/compile_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fi
if [[ $BUILDHDF5 == "y" ]]; then
HDF5=hdf5-1.14.3
# Download and extract the source
wget -O ${HDF5}.tar.bz2 https://www.hdfgroup.org/package/hdf5-1-14-3-tar-bz2/?wpdmdl=18469
wget -O ${HDF5}.tar.bz2 https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.3/src/hdf5-1.14.3.tar.bz2
tar xjf ${HDF5}.tar.bz2

cd $HDF5
Expand Down
30 changes: 21 additions & 9 deletions machines/machine_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ if [ $REQUEST_INPUT -eq 0 ]; then
fi
fi
# Ensure we have the resolved path for $JULIA, to avoid potentially creating a
# self-referencing symlink at bin/julia
JULIA=$(realpath $JULIA)
# self-referencing symlink at bin/julia.
# Use Python's `os.path` module instead of GNU coreutils `realpath` as
# `realpath` may not be available on all systems (e.g. some MacOS versions),
# but we already assume Python is available.
JULIA=$(/usr/bin/env python3 -c "import os; juliapath = os.path.realpath('$JULIA'); not os.path.isfile(juliapath) and exit(1); print(juliapath)")

# Make sure $JULIA is actually an executable. If not, prompt the user to try
# again.
Expand All @@ -191,9 +194,13 @@ while [[ -z "$JULIA" || ! $(command -v $JULIA) ]]; do
read -e -p "> " JULIA
done
# Convert $JULIA (which might be a relative path) to an absolute path.
# '-s' to skip resolving symlinks (if we did resolve symlinks, it might make
# the path look different than expected).
JULIA=$(realpath -s $JULIA)
# Use Python's `os.path` module instead of GNU coreutils `realpath` as
# `realpath` may not be available on all systems (e.g. some MacOS versions),
# but we already assume Python is available.
# Use `os.path.abspath` rather than `os.path.realpath` to skip resolving
# symlinks (if we did resolve symlinks, it might make the path look different
# than expected).
JULIA=$(/usr/bin/env python3 -c "import os; juliapath = os.path.abspath('$JULIA'); not os.path.isfile(juliapath) and exit(1); print(juliapath)")
echo
echo "Using Julia at $JULIA"
echo
Expand Down Expand Up @@ -224,11 +231,16 @@ if [ ! -z "$input" ]; then
JULIA_DIRECTORY=$input
fi
# Convert input (which might be a relative path) to an absolute path.
# '-m' to avoid erroring if the directory does not exist already.
# '-s' to skip resolving symlinks (if we did resolve symlinks, it might make
# the path look different than expected).
# Note that here we do not require the directory to exist already - if it does
# not exist then Julia will create it.
# Use Python's `os.path` module instead of GNU coreutils `realpath` as
# `realpath` may not be available on all systems (e.g. some MacOS versions),
# but we already assume Python is available.
# Use `os.path.abspath` rather than `os.path.realpath` to skip resolving
# symlinks (if we did resolve symlinks, it might make the path look different
# than expected).
if [ ! -z "$JULIA_DIRECTORY" ]; then
JULIA_DIRECTORY=$(realpath -m -s $JULIA_DIRECTORY)
JULIA_DIRECTORY=$(/usr/bin/env python3 -c "import os; print(os.path.abspath('$JULIA_DIRECTORY'))")
fi
echo
echo "Using julia_directory=$JULIA_DIRECTORY"
Expand Down
2 changes: 1 addition & 1 deletion machines/marconi/compile_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fi
if [ $BUILDHDF5 -eq 0 ]; then
HDF5=hdf5-1.14.3
# Download and extract the source
wget -O ${HDF5}.tar.bz2 https://www.hdfgroup.org/package/hdf5-1-14-3-tar-bz2/?wpdmdl=18469
wget -O ${HDF5}.tar.bz2 https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.3/src/hdf5-1.14.3.tar.bz2
tar xjf ${HDF5}.tar.bz2

cd $HDF5
Expand Down

0 comments on commit 573c966

Please sign in to comment.