Last active
February 5, 2018 05:01
-
-
Save chrischoy/91be70ad4799fa76d7638bba20bc4016 to your computer and use it in GitHub Desktop.
Python 3 virtual env setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ENVNAME=$1 | |
# Directory that contains the venvs | |
PYV_ROOT=${HOME} | |
ENV_ROOT="${PYV_ROOT}/.pyv/${ENVNAME}/bin" | |
# Check the number of arguments | |
if [ "$#" -eq 1 ] && [ -d "${ENV_ROOT}" ]; then | |
echo "Activating ${1}" | |
export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH | |
export OLD_PATH=$PATH | |
export OLD_PS1="$PS1" | |
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH | |
export PATH=${PYV_ROOT}/.pyv/${ENVNAME}/bin:/usr/local/cuda/bin:$PATH | |
export PS1="(${ENVNAME})$PS1" | |
else | |
echo "Please put the environment name as argument, you put ${1}" >&2 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH | |
export PATH=$OLD_PATH | |
export PS1=$OLD_PS1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
ENVNAME=$1 | |
# Directory that contains the venvs | |
PYV_ROOT=${HOME} | |
# Check the number of argument | |
if [ "$#" -eq 1 ]; then | |
ENV_ROOT=${PYV_ROOT}/.pyv/${ENVNAME} | |
PYTHON_ROOT=${PYV_ROOT}/.pyv/python3/ | |
mkdir -p ${ENV_ROOT} | |
# Python3 | |
wget -q -O- https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz | tar -xz -C "${PYV_ROOT}/.pyv/" | |
mv "${PYV_ROOT}/.pyv/Python-3.6.4" ${PYTHON_ROOT} | |
cd ${PYTHON_ROOT} | |
./configure --prefix=${PYTHON_ROOT} | |
make -j8 | |
make install | |
# Virtual environment setup | |
export OLD_PATH=$PATH | |
export PATH=${PYTHON_ROOT}/bin:$PATH | |
python3.6 -m venv ${ENV_ROOT} | |
cd ${PYV_ROOT} | |
source activate ${ENVNAME} | |
# Install custom libraries | |
pip3.6 install ipython | |
else | |
echo "Please put the server name and the environment name, you put ${1}" >&2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment