Skip to content

Instantly share code, notes, and snippets.

@webee
Last active December 23, 2015 04:39
Show Gist options
  • Select an option

  • Save webee/6582040 to your computer and use it in GitHub Desktop.

Select an option

Save webee/6582040 to your computer and use it in GitHub Desktop.
if [ "${0:0:1}" != "-" ]; then
export PY_PROFILE=$(readlink -f $0)
fi
export PY_ROOT=/home/q/python
export PY_HOME=$PY_ROOT/default
export PY_ENV=$PY_ROOT/env
export PY_SRC=$PY_ROOT/src
export PY_XSRC=$PY_ROOT/xsrc
export PY_DEFAULT_ENV=main
function pyenv() {
local env=$1
if [ "$env" = "" ];then
env=$PY_DEFAULT_ENV
fi
source $PY_ENV/$env/bin/activate 2>/dev/null
if (($?)); then
pyenv $PY_DEFAULT_ENV
fi
}
PY_PROFILE_URL=https://gist.github.com/webee/6582040/raw/python.sh
PY_PROFILE=/etc/profile.d/python.sh
function pyprofile() {
if [ "$1" = "-u" ]; then
sudo curl $PY_PROFILE_URL >$PY_PROFILE
source $PY_PROFILE
elif [ "$1" = "-p" ]; then
curl $PY_PROFILE_URL
else
cat $PY_PROFILE
fi
}
#repo: http://e.pypi.python.org/
#easy_install --index-url http://pypi.v2ex.com/simple scipy
alias easyinstall="sudo easy_install"
alias pipinstall="sudo pip install -i http://pypi.v2ex.com/simple"
#setup python virtual environments.
function setup_pyenv() {
local env=$1
cd ${PY_ROOT}
mkdir -p env
cd env
$PY_HOME/bin/virtualenv $env
}
#other
alias sudo="sudo "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment