Skip to content

Commit

Permalink
remove DistributionNotFound when no version is found
Browse files Browse the repository at this point in the history
- and rely on if not applicable_versions test instead
- fixes #2502
- rephrase the DistributionNotFound error message to fix other tests
  • Loading branch information
xavfernandez committed Mar 15, 2015
1 parent e5b447b commit 9dd1852
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
31 changes: 5 additions & 26 deletions pip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,31 +421,8 @@ def find_requirement(self, req, upgrade):
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],
Expand Down Expand Up @@ -507,7 +484,9 @@ def find_requirement(self, req, upgrade):
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:
Expand All @@ -518,7 +497,7 @@ def find_requirement(self, req, upgrade):
)

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:
Expand Down
25 changes: 25 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions tests/functional/test_install_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
)

0 comments on commit 9dd1852

Please sign in to comment.