remove DistributionNotFound when no version is found

- and rely on if not applicable_versions test instead
- fixes #2502
- rephrase the DistributionNotFound error message to fix other tests
This commit is contained in:
Xavier Fernandez 2015-03-13 09:52:50 +01:00
parent e5b447b14f
commit 9dd1852c16
3 changed files with 33 additions and 29 deletions

View File

@ -421,31 +421,8 @@ class PackageFinder(object):
Returns an InstallationCandidate or None
May raise DistributionNotFound or BestVersionAlreadyInstalled"""
all_versions = self._find_all_versions(req)
if not all_versions:
logger.critical(
'Could not find any downloads that satisfy the requirement %s',
req,
)
if self.need_warn_external:
logger.warning(
"Some externally hosted files were ignored as access to "
"them may be unreliable (use --allow-external %s to "
"allow).",
req.name,
)
if self.need_warn_unverified:
logger.warning(
"Some insecure and unverifiable files were ignored"
" (use --allow-unverified %s to allow).",
req.name,
)
raise DistributionNotFound(
'No distributions at all found for %s' % req
)
# Filter out anything which doesn't match our specifier
_versions = set(
req.specifier.filter(
[x.version for x in all_versions],
@ -507,7 +484,9 @@ class PackageFinder(object):
if self.need_warn_external:
logger.warning(
"Some externally hosted files were ignored as access to "
"them may be unreliable (use --allow-external to allow)."
"them may be unreliable (use --allow-external %s to "
"allow).",
req.name,
)
if self.need_warn_unverified:
@ -518,7 +497,7 @@ class PackageFinder(object):
)
raise DistributionNotFound(
'No distributions matching the version for %s' % req
'No matching distribution found for %s' % req
)
if applicable_versions[0].location is INSTALLED_VERSION:

View File

@ -739,3 +739,28 @@ def test_no_compiles_pyc(script, data):
)
assert not any(exists)
def test_install_upgrade_editable_depending_on_other_editable(script):
script.scratch_path.join("pkga").mkdir()
pkga_path = script.scratch_path / 'pkga'
pkga_path.join("setup.py").write(textwrap.dedent("""
from setuptools import setup
setup(name='pkga',
version='0.1')
"""))
script.pip('install', '--editable', pkga_path)
result = script.pip('list')
assert "pkga" in result.stdout
script.scratch_path.join("pkgb").mkdir()
pkgb_path = script.scratch_path / 'pkgb'
pkgb_path.join("setup.py").write(textwrap.dedent("""
from setuptools import setup
setup(name='pkgb',
version='0.1',
install_requires=['pkga'])
"""))
script.pip('install', '--upgrade', '--editable', pkgb_path)
result = script.pip('list')
assert "pkgb" in result.stdout

View File

@ -13,7 +13,7 @@ def test_options_from_env_vars(script):
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
assert "Ignoring indexes:" in result.stdout, str(result)
assert (
"DistributionNotFound: No distributions at all found for INITools"
"DistributionNotFound: No matching distribution found for INITools"
in result.stdout
)
@ -68,7 +68,7 @@ def _test_env_vars_override_config_file(script, virtualenv, config_file):
"""))
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
assert (
"DistributionNotFound: No distributions at all found for INITools"
"DistributionNotFound: No matching distribution found for INITools"
in result.stdout
)
script.environ['PIP_NO_INDEX'] = '0'
@ -184,6 +184,6 @@ def test_options_from_venv_config(script, virtualenv):
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
assert "Ignoring indexes:" in result.stdout, str(result)
assert (
"DistributionNotFound: No distributions at all found for INITools"
"DistributionNotFound: No matching distribution found for INITools"
in result.stdout
)