Skip to content

Commit

Permalink
Merge pull request pypa#724 from qwcode/unnamed
Browse files Browse the repository at this point in the history
upper case url reqs not aliased with name.lower() like other forms
  • Loading branch information
pnasrat committed Nov 15, 2012
2 parents 843ffb3 + d882827 commit 854574f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pip/req.py
Expand Up @@ -107,7 +107,7 @@ def from_line(cls, name, comes_from=None):
# Otherwise, assume the name is the req for the non URL/path/archive case.
if link and req is None:
url = link.url_without_fragment
req = link.egg_fragment
req = link.egg_fragment #when fragment is None, this will become an 'unnamed' requirement

# Handle relative file URLs
if link.scheme == 'file' and re.search(r'\.\./', url):
Expand Down Expand Up @@ -843,6 +843,7 @@ def add_requirement(self, install_req):
install_req.as_egg = self.as_egg
install_req.use_user_site = self.use_user_site
if not name:
#url or path requirement w/o an egg fragment
self.unnamed_requirements.append(install_req)
else:
if self.has_requirement(name):
Expand Down Expand Up @@ -1094,8 +1095,9 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
subreq = InstallRequirement(req, req_to_install)
reqs.append(subreq)
self.add_requirement(subreq)
if req_to_install.name not in self.requirements:
self.requirements[req_to_install.name] = req_to_install
if not self.has_requirement(req_to_install.name):
#'unnamed' requirements will get added here
self.add_requirement(req_to_install)
if self.is_download or req_to_install._temp_build_dir is not None:
self.reqs_to_cleanup.append(req_to_install)
else:
Expand Down
5 changes: 5 additions & 0 deletions tests/packages/README.txt
Expand Up @@ -62,6 +62,11 @@ simple-[123].0.tar.gz
---------------------
contains "simple" package; good for basic testing and version logic.

Upper-[12].0.tar.gz and requiresuppper-1.0.tar.gz
--------------------------------------------------
'requiresupper' requires 'upper'
used for testing case mismatch case for url requirements




Expand Down
Binary file added tests/packages/Upper-1.0.tar.gz
Binary file not shown.
Binary file added tests/packages/Upper-2.0.tar.gz
Binary file not shown.
Binary file added tests/packages/requiresupper-1.0.tar.gz
Binary file not shown.
23 changes: 23 additions & 0 deletions tests/test_requirements.py
Expand Up @@ -184,3 +184,26 @@ def test_install_local_editable_with_extras():
assert env.site_packages/'easy-install.pth' in res.files_updated
assert env.site_packages/'LocalExtras.egg-link' in res.files_created
assert env.site_packages/'simple' in res.files_created


def test_url_req_case_mismatch():
"""
tar ball url requirements (with no egg fragment), that happen to have upper case project names,
should be considered equal to later requirements that reference the project name using lower case.
tests/packages contains Upper-1.0.tar.gz and Upper-2.0.tar.gz
'requiresupper' has install_requires = ['upper']
"""
env = reset_env()
find_links = 'file://' + os.path.join(here, 'packages')
Upper = os.path.join(find_links, 'Upper-1.0.tar.gz')
result = run_pip('install', '--no-index', '-f', find_links, Upper, 'requiresupper')

#only Upper-1.0.tar.gz should get installed.
egg_folder = env.site_packages / 'Upper-1.0-py%s.egg-info' % pyversion
assert egg_folder in result.files_created, str(result)
egg_folder = env.site_packages / 'Upper-2.0-py%s.egg-info' % pyversion
assert egg_folder not in result.files_created, str(result)



0 comments on commit 854574f

Please sign in to comment.