From 4602c195797a2a554383797269fa9dc99bb87b3d Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Aug 2023 13:44:52 -0400 Subject: [PATCH] Fixes to build scripts so that they can work with Docker or just conda/mamba --- Dockerfile | 9 +++------ buildscripts/build_all.sh | 14 ++++++-------- buildscripts/build_dependencies.sh | 4 ++-- ...ke_environment.sh => make_build_environment.sh} | 13 +++++++++---- 4 files changed, 20 insertions(+), 20 deletions(-) rename buildscripts/{make_environment.sh => make_build_environment.sh} (85%) diff --git a/Dockerfile b/Dockerfile index 125417410..61b835958 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,13 +23,10 @@ COPY . ./ RUN ${SCRIPT_DIR}/fetch_dependencies.sh RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \ ${SCRIPT_DIR}/build_dependencies.sh Intel; \ - else \ - conda init bash && \ - conda update --name base conda -y && \ - ${SCRIPT_DIR}/make_environment.sh && \ + else \ + ${SCRIPT_DIR}/make_build_environment.sh && \ echo "conda activate swiftest-build-env" >> ~/.bashrc && \ - source ~/.bashrc && \ - ${SCRIPT_DIR}/build_dependencies.sh GNU; \ + /bin/bash -lic "${SCRIPT_DIR}/build_dependencies.sh GNU"; \ fi # ENV INSTALL_DIR="/usr/local" diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh index e64d22c14..fdcceb037 100755 --- a/buildscripts/build_all.sh +++ b/buildscripts/build_all.sh @@ -23,20 +23,18 @@ # Determine the platform and architecture -SCRIPT_DIR=$(dirname "$0") +SCRIPT_DIR=$(realpath $(dirname $0)) +ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) +BUILD_DIR=$(realpath ${ROOT_DIR}/build) read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) # Determine if we are in the correct directory (the script can either be run from the Swiftest project root directory or the # buildscripts directory) -if [ ! -f "./setup.py" ]; then - if [ -f "../setup.py" ]; then - cd .. - else - echo "Error: setup.py not found in . or .." +if [ ! -f "${ROOT_DIR}/setup.py" ]; then + echo "Error: setup.py not found" exit 1 - fi fi - +cd ${ROOT_DIR} VERSION=$( cat version.txt ) echo "Building Swiftest version ${VERSION} for ${OS}-${ARCH}" diff --git a/buildscripts/build_dependencies.sh b/buildscripts/build_dependencies.sh index 066b9f180..b06b1e8a8 100755 --- a/buildscripts/build_dependencies.sh +++ b/buildscripts/build_dependencies.sh @@ -10,8 +10,8 @@ # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License along with Swiftest. # If not, see: https://www.gnu.org/licenses. -SCRIPT_DIR=$(dirname "$0") -BUILD_DIR=${SCRIPT_DIR}/../build +SCRIPT_DIR=$(realpath $(dirname $0)) +BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) mkdir -p ${BUILD_DIR} cd $BUILD_DIR diff --git a/buildscripts/make_environment.sh b/buildscripts/make_build_environment.sh similarity index 85% rename from buildscripts/make_environment.sh rename to buildscripts/make_build_environment.sh index 152c0ca0f..fb42fc110 100755 --- a/buildscripts/make_environment.sh +++ b/buildscripts/make_build_environment.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # This script will create a miniforge3 conda environment in order to execute the build # Zlib, hdf5, netcdf-c, netcdf-fortran # @@ -31,9 +31,14 @@ else ${SHELL} Mambaforge-23.1.0-4-${OS}-${ARCH}.sh -b -p ${INSTALL_DIR} rm Mambaforge-23.1.0-4-${OS}-${ARCH}.sh - CONDABIN="${INSTALL_DIR}/condabin/mamba" - ${CONDABIN} init $MYSHELL - ${CONDABIN} update --name base mamba -y + CONDABIN="mamba" + if [ $MYSHELL != "bash" ]; then + $INSTALL_DIR/condabin/$CONDABIN init $MYSHELL + fi + $INSTALL_DIR/condabin/$CONDABIN init bash + source ~/.bashrc + export PATH=${INSTALL_DIR}/bin:$PATH fi cd $SCRIPT_DIR +${CONDABIN} update --name base ${CONDABIN} -y ${CONDABIN} env create --file swiftest-build-env.yml --name swiftest-build-env \ No newline at end of file