Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt venv_install.sh to install SMASH 1.0 with python-venv #173

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions venv-dev.sh

This file was deleted.

125 changes: 125 additions & 0 deletions venv_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/bin/bash
#bash script to install SMASH in a virtual environnement using Python venv.
#The installation has been tested for ubuntu 22.04 only
#When running this script, you will be prompted for your administrator password to install the required dependencies.

venv_path=~/python_venv
env_name=smash_1.0


#Parse input arguments
i=1
until [ $# = 0 ]
do
case $1 in
--venv_path)
shift
venv_path=$1
echo "venv_path="$venv_path
shift
;;
--env_name)
shift
env_name=$1
echo "env_name="$env_name
shift
;;
--help | -h)
echo "Installation of the SMASH python package"
echo ""
echo "Options :"
echo "-h, --help Display the help"
echo "--venv_path {venv_path} Specify the folder where the python environnement will be created. Default value is $venv_path"
echo "--env_name {env_name} Specify the name of the python environment that will be created. Default is $env_name"
exit 0
;;
*)
echo "Unknown options ..."
echo "Use --help to see available options."
exit 0
;;
esac
done


if [ ! -d ${venv_path} ] ; then
echo "Creating the folder to store the python environnement in ${venv_path}"
mkdir ${venv_path}
fi

#install debian dependencies
#Warning to the user
if [ $(cat /etc/*release | grep ^NAME | grep -o Ubuntu) == "Ubuntu" ]; then

DEB_PACKAGE_NAME="gfortran build-essential gdal-bin libgdal-dev libshp-dev python3-gdal python3-venv python3-dev"
echo "==============================================="
echo "Make sure you first installed the following package (ubuntu): $DEB_PACKAGE_NAME"
echo "==============================================="

else

PACKAGE_NAME="gfortran build-essential gdal-bin libgdal-dev libshp-dev python3-gdal python3-venv python3-dev"
echo "==============================================="
echo "Builging smash require some packages. Make sure you install them first. Install the corresponding package depending your distribution. On Debian/Ubuntu these package are: $PACKAGE_NAME"
echo "==============================================="

fi


echo ""
read -p "Press enter to continue, ctrl+c to abort ..."


if [ ! -d "${venv_path}/.venv-${env_name}" ] ; then

echo ''
echo 'Creating a virtual python environment for Smash...'
echo ''

#creating a python environment and activate it
python3 -m venv "${venv_path}/.venv-${env_name}"
ln "${venv_path}/.venv-${env_name}/bin/activate" "${venv_path}/${env_name}"
source ${venv_path}/${env_name}

#install python dependencies
pip install --upgrade pip
pip install 'numpy>=1.13,<=1.23'
pip install f90wrap
pip install wheel
pip install rasterio pandas h5py tqdm scipy pyyaml terminaltables matplotlib

echo ''
echo 'Building Smash...'
echo ''

make

echo ''
echo 'Installing extra-package for building the documentation...'
echo ''
#install extra-package for building the documentation:
pip install sphinx numpydoc pydata-sphinx-theme ipython sphinxcontrib-bibtex sphinx-design sphinx-autosummary-accessors pytest pytest-cov black ruff fprettify

else
echo ''
echo "The python environnemnt ${venv_path}/${env_name} already exist..."
echo ''
fi
echo '************************************************'

echo ''

echo '************************************************'
echo 'To activate the python environment for Smash, run:'
echo "> source ${venv_path}/${env_name}"
echo 'To deactivate the python environnement, juste type:'
echo '>deactivate'
echo ''
echo 'To use the smash package run the following commands:'
echo "> source ${venv_path}/${env_name}"
echo '>Then launch python:'
echo '(smash)> python'
echo 'Import the SMASH package in your python shell:'
echo '>>> import smash'
echo '************************************************'