Skip to content

Commit

Permalink
fixes #435
Browse files Browse the repository at this point in the history
  • Loading branch information
edublancas committed Feb 11, 2022
1 parent a4c3ff1 commit 8c82210
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/ploomber/cli/install.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""
Implementation of:
$ plomber install
This command runs a bunch of pip/conda commands (depending on what's available)
and it does the *right thing*: creating a new environment if needed, and
locking dependencies.
"""

import json
import os
import shutil
Expand Down Expand Up @@ -100,7 +110,13 @@ def main_pip(use_lock, create_env=True):
if create_env:
venv_dir = f'venv-{name}'
cmdr.print('Creating venv...')
cmdr.run('python', '-m', 'venv', venv_dir, description='Creating venv')
# NOTE: explicitly call 'python3'. in some systems 'python' is
# Python 2, which doesn't have the venv module
cmdr.run('python3',
'-m',
'venv',
venv_dir,
description='Creating venv')

# add venv_dir to .gitignore if it doesn't exist
if Path('.gitignore').exists():
Expand Down Expand Up @@ -260,7 +276,7 @@ def _create_conda_env():

def _current_conda_env_name():
# NOTE: we can also use env variable: 'CONDA_DEFAULT_ENV'
return Path(shutil.which('python')).parents[1].name
return Path(shutil.which('python3')).parents[1].name


def _get_pip_folder_and_bin_name():
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ def test_install_lock_pip(tmp_directory, mock_cmdr_wrapped, create_setup_py,
venv, pip = _get_venv_and_pip()

expected = [
call('python', '-m', 'venv', venv, description='Creating venv'),
call('python3', '-m', 'venv', venv, description='Creating venv'),
call(pip,
'install',
'--editable',
Expand Down

0 comments on commit 8c82210

Please sign in to comment.