mirror of https://github.com/pypa/pip
Stop erroring on installs of argparse and wsgiref.
This commit is contained in:
parent
df7bb2d18f
commit
7b2fbb069a
|
@ -1,5 +1,8 @@
|
|||
**8.1.0 (unreleased)**
|
||||
|
||||
* Installing argparse or wsgiref will no longer warn or error - pip will allow
|
||||
the installation even though it may be useless (since the installed thing
|
||||
will be shadowed by the standard library).
|
||||
|
||||
**8.0.0 (2016-01-19)**
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ import os
|
|||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import sysconfig
|
||||
import tempfile
|
||||
import traceback
|
||||
import zipfile
|
||||
|
||||
from distutils.util import change_root
|
||||
from distutils import sysconfig
|
||||
from email.parser import FeedParser
|
||||
|
||||
from pip._vendor import pkg_resources, six
|
||||
|
@ -20,7 +20,7 @@ from pip._vendor.six.moves import configparser
|
|||
|
||||
import pip.wheel
|
||||
|
||||
from pip.compat import native_str, WINDOWS
|
||||
from pip.compat import native_str, stdlib_pkgs, WINDOWS
|
||||
from pip.download import is_url, url_to_path, path_to_url, is_archive_file
|
||||
from pip.exceptions import (
|
||||
InstallationError, UninstallationError, UnsupportedWheel,
|
||||
|
@ -32,7 +32,7 @@ from pip.utils import (
|
|||
display_path, rmtree, ask_path_exists, backup_dir, is_installable_dir,
|
||||
dist_in_usersite, dist_in_site_packages, egg_link_path,
|
||||
call_subprocess, read_text_file, FakeFile, _make_build_dir, ensure_dir,
|
||||
get_installed_version, canonicalize_name
|
||||
get_installed_version, canonicalize_name, normalize_path, dist_is_local,
|
||||
)
|
||||
from pip.utils.hashes import Hashes
|
||||
from pip.utils.logging import indent_log
|
||||
|
@ -114,6 +114,9 @@ class InstallRequirement(object):
|
|||
self.install_succeeded = None
|
||||
# UninstallPathSet of uninstalled distribution (for possible rollback)
|
||||
self.uninstalled = None
|
||||
# Set True if a legitimate do-nothing-on-uninstall has happened - e.g.
|
||||
# system site packages, stdlib packages.
|
||||
self.nothing_to_uninstall = False
|
||||
self.use_user_site = False
|
||||
self.target_dir = None
|
||||
self.options = options if options else {}
|
||||
|
@ -606,6 +609,28 @@ class InstallRequirement(object):
|
|||
)
|
||||
dist = self.satisfied_by or self.conflicts_with
|
||||
|
||||
dist_path = normalize_path(dist.location)
|
||||
if not dist_is_local(dist):
|
||||
logger.info(
|
||||
"Not uninstalling %s at %s, outside environment %s",
|
||||
dist.key,
|
||||
dist_path,
|
||||
sys.prefix,
|
||||
)
|
||||
self.nothing_to_uninstall = True
|
||||
return
|
||||
|
||||
if dist_path in (
|
||||
sysconfig.get_path("stdlib"),
|
||||
sysconfig.get_path("platstdlib")):
|
||||
logger.info(
|
||||
"Not uninstalling %s at %s, as it is in the standard library.",
|
||||
dist.key,
|
||||
dist_path,
|
||||
)
|
||||
self.nothing_to_uninstall = True
|
||||
return
|
||||
|
||||
paths_to_remove = UninstallPathSet(dist)
|
||||
develop_egg_link = egg_link_path(dist)
|
||||
develop_egg_link_egg_info = '{0}.egg-info'.format(
|
||||
|
@ -735,9 +760,9 @@ class InstallRequirement(object):
|
|||
def commit_uninstall(self):
|
||||
if self.uninstalled:
|
||||
self.uninstalled.commit()
|
||||
else:
|
||||
elif not self.nothing_to_uninstall:
|
||||
logger.error(
|
||||
"Can't commit %s, nothing uninstalled.", self.project_name,
|
||||
"Can't commit %s, nothing uninstalled.", self.name,
|
||||
)
|
||||
|
||||
def archive(self, build_dir):
|
||||
|
|
|
@ -305,6 +305,28 @@ def test_editable_install_from_local_directory_with_no_setup_py(script, data):
|
|||
assert "is not installable. File 'setup.py' not found." in result.stderr
|
||||
|
||||
|
||||
@pytest.mark.skipif("sys.version_info < (2,7) or sys.version_info >= (3,4)")
|
||||
def test_install_argparse_shadowed(script, data):
|
||||
# When argparse is in the stdlib, we support installing it
|
||||
# even though thats pretty useless because older packages did need to
|
||||
# depend on it, and not having its metadata will cause pkg_resources
|
||||
# requirements checks to fail // trigger easy-install, both of which are
|
||||
# bad.
|
||||
# XXX: Note, this test hits the outside-environment check, not the
|
||||
# in-stdlib check, because our tests run in virtualenvs...
|
||||
result = script.pip('install', 'argparse>=1.4')
|
||||
assert "Not uninstalling argparse" in result.stdout
|
||||
|
||||
|
||||
@pytest.mark.skipif("sys.version_info < (3,4)")
|
||||
def test_upgrade_argparse_shadowed(script, data):
|
||||
# If argparse is installed - even if shadowed for imported - we support
|
||||
# upgrading it and properly remove the older versions files.
|
||||
script.pip('install', 'argparse==1.3')
|
||||
result = script.pip('install', 'argparse>=1.4')
|
||||
assert "Not uninstalling argparse" not in result.stdout
|
||||
|
||||
|
||||
def test_install_as_egg(script, data):
|
||||
"""
|
||||
Test installing as egg, instead of flat install.
|
||||
|
|
Loading…
Reference in New Issue