Skip to content
Open
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
8 changes: 8 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Originally by and Copyright (C) 2012 Rachid Belaid
--------------------------------------------------

... with contributions and inspiration from the community, including:

Paul A. Prince <paul@littlebluetech.com> (2014)

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='virtualenvwrapper.gem',
version='0.1',
version='0.2',
description='Plugin for virtualenvwrapper to automatically '
'encapsulate inside the virtual environment'
'any gems installed when the venv is activated',
Expand Down
70 changes: 59 additions & 11 deletions virtualenvwrapper/gem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,72 @@

log = logging.getLogger(__name__)


def post_activate_source(args):
return """
#patch to wrap gems inside the virtual env
export _OLD_GEM_HOME="$GEM_HOME"
export _OLD_GEM_PATH="$GEM_PATH"
export GEM_HOME="$VIRTUAL_ENV/lib/gems"
export GEM_PATH=""
PATH="$GEM_HOME/bin:$PATH"
export PATH
if [ -e "${VIRTUAL_ENV}/.gem" ]; then

"""
if [ -n "${GEM_HOME+x}" ]; then
export _OLD_GEM_HOME="$GEM_HOME"
fi
export GEM_HOME=$VIRTUAL_ENV

if [ -n "${GEM_PATH+x}" ]; then
export _OLD_GEM_PATH="$GEM_PATH"
fi
export GEM_PATH=""

if [ -n "${BUNDLE_HOME+x}" ]; then
export _OLD_BUNDLE_HOME="$BUNDLE_HOME"
fi
export BUNDLE_HOME="$GEM_HOME"

if [ -n "${BUNDLE_BIN+x}" ]; then
export _OLD_BUNDLE_BIN="$BUNDLE_BIN"
fi
export BUNDLE_BIN="${GEM_HOME}/bin"

fi

"""


def pre_deactivate_source(args):
return """
#restore the value before entering the venv
export GEM_HOME="$_OLD_GEM_HOME"
export GEM_PATH="$GEM_PATH"
if [ -e "${VIRTUAL_ENV}/.gem" ]; then

if [ -n "${_OLD_GEM_HOME+x}" ]; then
GEM_HOME="$_OLD_GEM_HOME"
export GEM_HOME
unset _OLD_GEM_HOME
else
unset GEM_HOME
fi

if [ -n "${_OLD_GEM_PATH+x}" ]; then
GEM_PATH="$_OLD_GEM_PATH"
export GEM_PATH
unset _OLD_GEM_PATH
else
unset GEM_PATH
fi

if [ -n "${_OLD_BUNDLE_HOME+x}" ]; then
BUNDLE_HOME="$_OLD_BUNDLE_HOME"
export BUNDLE_HOME
unset _OLD_BUNDLE_HOME
else
unset BUNDLE_HOME
fi

if [ -n "${_OLD_BUNDLE_BIN+x}" ]; then
BUNDLE_BIN="$_OLD_BUNDLE_BIN"
export BUNDLE_BIN
unset _OLD_BUNDLE_BIN
else
unset BUNDLE_BIN
fi

fi

"""