Skip to content

Commit

Permalink
Merge pull request #4490 from pradyunsg/windows-upgrade-message
Browse files Browse the repository at this point in the history
Display message on Windows when modifying pip
  • Loading branch information
dstufft authored May 19, 2017
2 parents f16de42 + 053fa2f commit 60ebb03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/4490.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display a message to run the right command for modifying pip on Windows
17 changes: 17 additions & 0 deletions pip/basecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,23 @@ def populate_requirement_set(requirement_set, args, options, finder,
'You must give at least one requirement to %(name)s '
'(see "pip help %(name)s")' % opts)

# On Windows, any operation modifying pip should be run as:
# python -m pip ...
# See https://github.com/pypa/pip/issues/1299 for more discussion
should_show_use_python_msg = (
sys.platform == 'win32' and
requirement_set.has_requirement('pip') and
"pip" in os.path.basename(sys.argv[0])
)
if should_show_use_python_msg:
new_command = [
sys.executable, "-m", "pip"
] + sys.argv[1:]
raise CommandError(
'To modify pip, please run the following command:\n{}'
.format(" ".join(new_command))
)

def _build_package_finder(self, options, session,
platform=None, python_versions=None,
abi=None, implementation=None):
Expand Down

0 comments on commit 60ebb03

Please sign in to comment.