Skip to content

Commit

Permalink
get-pipsi.py will now use the virtualenv installed in the python inte…
Browse files Browse the repository at this point in the history
…rpreter

Instead of searching for the virtualenv command, use the virtualenv that
is installed in the python interpreter that is running
``python get-pipsi.py``. This will also fallback to using the ``venv``
package on python3. It's assumed if someone installed ``virtualenv``
then that overrides the default ``venv`` from the stdlib.
  • Loading branch information
mmerickel committed Feb 9, 2017
1 parent 5f5feb8 commit be4abc4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions get-pipsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
PIP = '/Scripts/pip.exe'
PIPSI = '/Scripts/pipsi.exe'

try:
import virtualenv
venv_pkg = 'virtualenv'
del virtualenv
except ImportError:
try:
import venv
venv_pkg = 'venv'
del venv
except ImportError:
venv_pkg = None

DEFAULT_PIPSI_HOME = os.path.expanduser('~/.local/venvs')
DEFAULT_PIPSI_BIN_DIR = os.path.expanduser('~/.local/bin')

Expand Down Expand Up @@ -67,7 +79,7 @@ def _cleanup():
except (OSError, IOError):
pass

if call(['virtualenv', venv]) != 0:
if call([sys.executable, '-m', venv_pkg, venv]) != 0:
_cleanup()
fail('Could not create virtualenv for pipsi :(')

Expand All @@ -84,10 +96,9 @@ def main():
else:
echo('Installing pipsi')

if not command_exists('virtualenv'):
if venv_pkg is None:
fail('You need to have virtualenv installed to bootstrap pipsi.')


bin_dir = os.environ.get('PIPSI_BIN_DIR', DEFAULT_PIPSI_BIN_DIR)
venv = os.path.join(os.environ.get('PIPSI_HOME', DEFAULT_PIPSI_HOME),
'pipsi')
Expand Down

0 comments on commit be4abc4

Please sign in to comment.