Skip to content

Commit

Permalink
updated install
Browse files Browse the repository at this point in the history
  • Loading branch information
RAHenriksen committed Dec 18, 2024
1 parent 10aef67 commit 3af8778
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 41 deletions.
91 changes: 51 additions & 40 deletions custom_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
# cd serum_readfilter
# pip install .

#ENV_NAME=$1
ENV_NAME=$1
echo "Environment $ENV_NAME and $1"


GIT_REPO=https://github.com/ssi-dk/serum_readfilter
REPO_FOLDER=serum_readfilter
REPO_FOLDER="serum_readfilter"
SUBMODULE_PATH="bifrost_sp_cdiff/cdiff_fbi" # Path to the submodule

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Expand All @@ -19,51 +21,61 @@ function exit_function() {
exit 1
}

CONDA_BASE=$(conda info --base)
source $CONDA_BASE/etc/profile.d/conda.sh

# if ! (conda env list | grep "$ENV_NAME")
# then
#CONDA_BASE=$(conda info --base)
#source $CONDA_BASE/etc/profile.d/conda.sh
#conda env list | grep "$ENV_NAME"

#if ! (conda env list | grep "$ENV_NAME")
#then
# echo "Conda environment specified is not found"
# exit_function
# else
#else
# conda activate $ENV_NAME
# fi
#fi
#echo "packages before activating the environment"
#which python
#which pip

#echo "before activate environmment"
#conda info
#echo "activate conda environment $ENV_NAME"
#conda activate $ENV_NAME
#ls /home/projects/fvst_ssi_dtu/apps/sofi_bifrost_dev/conda/envs/
#ls /home/projects/fvst_ssi_dtu/apps/sofi_bifrost_dev/conda/envs/bifrost_dev_sp_cdiff_v0.0.1/
echo "Activating conda environment $ENV_NAME"

# Ensure conda is properly sourced
CONDA_BASE=$(conda info --base)
source $CONDA_BASE/etc/profile.d/conda.sh

if test -d "$SCRIPT_DIR/$REPO_FOLDER"
then
echo "$SCRIPT_DIR/$REPO_FOLDER already exists, if you want to overwrite, please remove the old repository folder"
echo "You can use:"
echo "rm -rf $SCRIPT_DIR/$REPO_FOLDER"
# Check if the environment exists
if ! conda env list | grep -q "$ENV_NAME"; then
echo "Conda environment $ENV_NAME does not exist. Please ensure it is created."
exit 1
fi

CONDA_ENV_PATH=$(conda env list|awk '{print $2}' | grep -v '^$'|grep "$ENV_NAME")

conda activate $ENV_NAME

git clone $GIT_REPO
cd $REPO_FOLDER
echo "#################Installing package using pip"
PIP_PATH="$CONDA_ENV_PATH/bin/pip"
echo "installed pip path $INSTALLED_PIP_PATH"
$PIP_PATH install .
# Check where serum_readfilter is installed
INSTALLED_PATH=$(which serum_readfilter)

if [[ "$INSTALLED_PATH" == "~/.local/bin/serum_readfilter" ]]; then
echo "Warning: serum_readfilter is installed in ~/.local/bin, which may cause conflicts."
exit_function
else
git --version
GIT_IS_AVAILABLE=$?
if [ $GIT_IS_AVAILABLE -eq 0 ]
then
echo "#################Cloning repository from $GIT_REPO"
if ! git clone $GIT_REPO
then
echo >&2 "git clone command failed"
exit_function
else
cd $REPO_FOLDER
echo "#################Installing package using pip"
if ! pip install .
then
echo >&2 "pip install command failed"
exit_function
else
echo "Package successfully installed"
fi
fi
else
echo "git is not installed"
echo "You can try installing git and rerunning the script"
exit_function
fi
fi

echo "serum_readfilter is installed at: $INSTALLED_PATH"
conda deactivate

cd $SCRIPT_DIR

# Initialize and update submodules
Expand All @@ -75,7 +87,6 @@ fi

cd $SUBMODULE_PATH || { echo "Failed to enter submodule cdiff_fbi repository directory"; exit_function; }


# Fetch the latest tags
echo "################# Fetching the latest tags for the submodule..."
if ! git fetch origin --tags; then
Expand Down
3 changes: 2 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ fi
#check if custom_install.sh file exists and run it
if test -f "$CUSTOM_INSTALL_PATH";
then
echo -e "\nRunning custom_install.sh"
echo -e "\nRunning custom_install.sh -> bash -i $CUSTOM_INSTALL_PATH $ENV_NAME"
bash -i $CUSTOM_INSTALL_PATH $ENV_NAME #-i required for interactive mode to active env
#bash $CUSTOM_INSTALL_PATH $ENV_NAME
fi

0 comments on commit 3af8778

Please sign in to comment.