Skip to content

Make --require-virtualenv output more info #2401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 15 additions & 4 deletions pip/basecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import sys
import textwrap
import traceback
import optparse
import warnings
Expand Down Expand Up @@ -214,10 +215,20 @@ def main(self, args):
if options.require_venv:
# If a venv is required check if it can really be found
if not running_under_virtualenv():
logger.critical(
'Could not find an activated virtualenv (required).'
)
sys.exit(VIRTUALENV_NOT_FOUND)
if not getattr(options, 'use_user_site'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is odd to me. If I've set the option to require a virtualenv, it shouldn't allow a user install? that's redefining the option.

logger.critical(
textwrap.dedent("""\
******************************************************
Using pip outside a virtualenv and without --user
is not recommended!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think this is the place to log a message about best practices.

if they've set the option, and not in a virtualenv, then just log the facts like it is now.


Doing stuff with the system python's packages can break
your system.

Did you mean to use a virtualenv or use --user?
******************************************************""")
)
sys.exit(VIRTUALENV_NOT_FOUND)

# Check if we're using the latest version of pip available
if (not options.disable_pip_version_check and not
Expand Down