Skip to content
This repository
Browse code

Merge pull request #724 from qwcode/unnamed

upper case url reqs not aliased with name.lower() like other forms
  • Loading branch information...
commit 854574f65c4ef92da8dd78b9831a9604dcc9957a 2 parents 843ffb3 + d882827
Paul Nasrat pnasrat authored
8 pip/req.py
@@ -107,7 +107,7 @@ def from_line(cls, name, comes_from=None):
107 107 # Otherwise, assume the name is the req for the non URL/path/archive case.
108 108 if link and req is None:
109 109 url = link.url_without_fragment
110   - req = link.egg_fragment
  110 + req = link.egg_fragment #when fragment is None, this will become an 'unnamed' requirement
111 111
112 112 # Handle relative file URLs
113 113 if link.scheme == 'file' and re.search(r'\.\./', url):
@@ -843,6 +843,7 @@ def add_requirement(self, install_req):
843 843 install_req.as_egg = self.as_egg
844 844 install_req.use_user_site = self.use_user_site
845 845 if not name:
  846 + #url or path requirement w/o an egg fragment
846 847 self.unnamed_requirements.append(install_req)
847 848 else:
848 849 if self.has_requirement(name):
@@ -1094,8 +1095,9 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
1094 1095 subreq = InstallRequirement(req, req_to_install)
1095 1096 reqs.append(subreq)
1096 1097 self.add_requirement(subreq)
1097   - if req_to_install.name not in self.requirements:
1098   - self.requirements[req_to_install.name] = req_to_install
  1098 + if not self.has_requirement(req_to_install.name):
  1099 + #'unnamed' requirements will get added here
  1100 + self.add_requirement(req_to_install)
1099 1101 if self.is_download or req_to_install._temp_build_dir is not None:
1100 1102 self.reqs_to_cleanup.append(req_to_install)
1101 1103 else:
5 tests/packages/README.txt
@@ -62,6 +62,11 @@ simple-[123].0.tar.gz
62 62 ---------------------
63 63 contains "simple" package; good for basic testing and version logic.
64 64
  65 +Upper-[12].0.tar.gz and requiresuppper-1.0.tar.gz
  66 +--------------------------------------------------
  67 +'requiresupper' requires 'upper'
  68 +used for testing case mismatch case for url requirements
  69 +
65 70
66 71
67 72
BIN  tests/packages/Upper-1.0.tar.gz
Binary file not shown
BIN  tests/packages/Upper-2.0.tar.gz
Binary file not shown
BIN  tests/packages/requiresupper-1.0.tar.gz
Binary file not shown
23 tests/test_requirements.py
@@ -184,3 +184,26 @@ def test_install_local_editable_with_extras():
184 184 assert env.site_packages/'easy-install.pth' in res.files_updated
185 185 assert env.site_packages/'LocalExtras.egg-link' in res.files_created
186 186 assert env.site_packages/'simple' in res.files_created
  187 +
  188 +
  189 +def test_url_req_case_mismatch():
  190 + """
  191 + tar ball url requirements (with no egg fragment), that happen to have upper case project names,
  192 + should be considered equal to later requirements that reference the project name using lower case.
  193 +
  194 + tests/packages contains Upper-1.0.tar.gz and Upper-2.0.tar.gz
  195 + 'requiresupper' has install_requires = ['upper']
  196 + """
  197 + env = reset_env()
  198 + find_links = 'file://' + os.path.join(here, 'packages')
  199 + Upper = os.path.join(find_links, 'Upper-1.0.tar.gz')
  200 + result = run_pip('install', '--no-index', '-f', find_links, Upper, 'requiresupper')
  201 +
  202 + #only Upper-1.0.tar.gz should get installed.
  203 + egg_folder = env.site_packages / 'Upper-1.0-py%s.egg-info' % pyversion
  204 + assert egg_folder in result.files_created, str(result)
  205 + egg_folder = env.site_packages / 'Upper-2.0-py%s.egg-info' % pyversion
  206 + assert egg_folder not in result.files_created, str(result)
  207 +
  208 +
  209 +

0 comments on commit 854574f

Please sign in to comment.
Something went wrong with that request. Please try again.