Skip to content

Commit

Permalink
Hint "pipenv run" after creating the virtualenv
Browse files Browse the repository at this point in the history
Also some refactoring to remove dead code and misleading function name.
  • Loading branch information
uranusjr committed Jun 6, 2018
1 parent f91f53b commit 013a621
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,20 +1200,6 @@ def activate_virtualenv(source=True):
return '{0}/bin/activate'.format(venv_location)


def do_activate_virtualenv(bare=False):
"""Executes the activate virtualenv functionality."""
# Check for environment marker, and skip if it's set.
if 'PIPENV_ACTIVE' not in os.environ:
if not bare:
click.echo(
'To activate this project\'s virtualenv, run the following:\n $ {0}'.format(
crayons.red('pipenv shell')
)
)
else:
click.echo(activate_virtualenv())


def do_purge(bare=False, downloads=False, allow_global=False, verbose=False):
"""Executes the purge functionality."""
if downloads:
Expand Down Expand Up @@ -1374,9 +1360,17 @@ def do_init(
requirements_dir=requirements_dir.name,
)
requirements_dir.cleanup()
# Activate virtualenv instructions.
if not allow_global and not deploy:
do_activate_virtualenv()

# Hint the user what to do to activate the virtualenv.
if not allow_global and not deploy and 'PIPENV_ACTIVE' not in os.environ:
click.echo(
"To activate this project's virtualenv, run {0}.\n"
"Alternativaly, run a command "
"inside the virtualenv with {1}.".format(
crayons.red('pipenv shell'),
crayons.red('pipenv run'),
)
)


def pip_install(
Expand Down Expand Up @@ -1508,7 +1502,7 @@ def pip_install(


def pip_download(package_name):
cache_dir = Path(PIPENV_CACHE_DIR)
cache_dir = Path(PIPENV_CACHE_DIR)
pip_config = {
'PIP_CACHE_DIR': fs_str(cache_dir.as_posix()),
'PIP_WHEEL_DIR': fs_str(cache_dir.joinpath('wheels').as_posix()),
Expand Down

0 comments on commit 013a621

Please sign in to comment.