Skip to content

Commit 4bd4542

Browse files
author
Patrick Lawson
committed
Clean up merge issues, fix py version reference, and add tests.
1 parent 1540ac1 commit 4bd4542

16 files changed

+191
-7
lines changed

docs/reference/pip_download.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ Examples
5454

5555
::
5656

57-
$ pip download --platform macosx-10.10-x86_64 --interpreter-version py27 SomePackage
57+
$ pip download --platform macosx-10.10-x86_64 --interpreter-version 27 SomePackage
5858

5959

pip/index.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ def _candidate_sort_key(self, candidate):
264264
with the same version, would have to be considered equal
265265
"""
266266
support_num = len(self.valid_tags)
267-
if candidate.location == INSTALLED_VERSION:
268-
pri = 1
269-
elif candidate.location.is_wheel:
267+
if candidate.location.is_wheel:
270268
# can raise InvalidWheelFilename
271269
wheel = Wheel(candidate.location.filename)
272270
if not wheel.supported(self.valid_tags):
Binary file not shown.
Binary file not shown.

simplewheel-2.0-py2.py3-none-any.whl

1.71 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

tests/functional/test_download.py

Lines changed: 189 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ def test_download_specify_platform(script, data):
167167
Test using "pip download --platform" to download a .whl archive
168168
supported for a specific platform
169169
"""
170+
# Confirm that universal wheels are returned even for specific
171+
# platforms.
170172
result = script.pip(
171173
'download', '--no-index', '--find-links', data.find_links,
172174
'--dest', '.', '--platform', 'linux_x86_64', 'simplewheel'
@@ -186,15 +188,49 @@ def test_download_specify_platform(script, data):
186188
in result.files_created
187189
)
188190

191+
# Now confirm that platform specific wheels will also be fetched.
192+
result = script.pip(
193+
'download', '--no-index', '--find-links', data.find_links,
194+
'--dest', '.', '--platform', 'macosx_10_10_x86_64', 'simpleplatdist==1.0'
195+
)
196+
assert (
197+
Path('scratch') / 'simpleplatdist-1.0-cp27-none-macosx_10_9_x86_64.whl'
198+
in result.files_created
199+
)
200+
201+
# OSX platform wheels are not forward-compatible.
202+
result = script.pip(
203+
'download', '--no-index', '--find-links', data.find_links,
204+
'--dest', '.', '--platform', 'macosx_10_8_x86_64', 'simpleplatdist==1.0',
205+
expect_error=True,
206+
)
207+
208+
# No linux wheel provided for this version.
209+
result = script.pip(
210+
'download', '--no-index', '--find-links', data.find_links,
211+
'--dest', '.', '--platform', 'linux_x86_64', 'simpleplatdist==1.0',
212+
expect_error=True,
213+
)
214+
215+
result = script.pip(
216+
'download', '--no-index', '--find-links', data.find_links,
217+
'--dest', '.', '--platform', 'linux_x86_64', 'simpleplatdist==2.0'
218+
)
219+
assert (
220+
Path('scratch') / 'simpleplatdist-2.0-py2.py3-none-any.whl'
221+
in result.files_created
222+
)
223+
224+
189225
@pytest.mark.network
190226
def test_download_specify_interpreter_version(script, data):
191227
"""
192228
Test using "pip download --interpreter-version" to download a .whl archive
193-
supported for a specific platform
229+
supported for a specific interpreter
194230
"""
195231
result = script.pip(
196232
'download', '--no-index', '--find-links', data.find_links,
197-
'--dest', '.', '--interpreter-version', 'py2', 'simplewheel'
233+
'--dest', '.', '--interpreter-version', '2', 'simplewheel'
198234
)
199235
assert (
200236
Path('scratch') / 'simplewheel-2.0-py2.py3-none-any.whl'
@@ -203,10 +239,160 @@ def test_download_specify_interpreter_version(script, data):
203239

204240
result = script.pip(
205241
'download', '--no-index', '--find-links', data.find_links,
206-
'--dest', '.', '--interpreter-version', 'py3',
242+
'--dest', '.', '--interpreter-version', '3',
207243
'requires_source'
208244
)
209245
assert (
210246
Path('scratch') / 'requires_source-1.0-py2.py3-none-any.whl'
211247
in result.files_created
212248
)
249+
250+
# No py3 provided for version 1.
251+
result = script.pip(
252+
'download', '--no-index', '--find-links', data.find_links,
253+
'--dest', '.', '--interpreter-version', '3', 'simpleinterpdist==1.0',
254+
expect_error=True,
255+
)
256+
257+
258+
# Because of the existing compatibility semantics, a "cp27" wheel IS considered
259+
# compatible with the pep425 tags for a plain interpreter version of "27".
260+
# (Is this correct? cp27 seems more specific than "27", i.e. "py27")
261+
result = script.pip(
262+
'download', '--no-index', '--find-links', data.find_links,
263+
'--dest', '.', '--interpreter-version', '27', 'simpleinterpdist==1.0'
264+
)
265+
assert (
266+
Path('scratch') / 'simpleinterpdist-1.0-cp27-none-any.whl'
267+
in result.files_created
268+
)
269+
270+
# Because of the existing compatibility semantics, a "cp27" wheel is not considered
271+
# compatible with the pep425 tags for a plain interpreter version of "2".
272+
# (Is this correct? Given the above behavior, it seems like "xp27" should satisfy "py2"
273+
# if "xp27" would satisfy "py27")
274+
result = script.pip(
275+
'download', '--no-index', '--find-links', data.find_links,
276+
'--dest', '.', '--interpreter-version', '2', 'simpleinterpdist==1.0',
277+
expect_error=True,
278+
)
279+
280+
result = script.pip(
281+
'download', '--no-index', '--find-links', data.find_links,
282+
'--dest', '.', '--interpreter-version', '2', 'simpleinterpdist'
283+
)
284+
assert (
285+
Path('scratch') / 'simpleinterpdist-2.0-py2.py3-none-any.whl'
286+
in result.files_created
287+
)
288+
289+
result = script.pip(
290+
'download', '--no-index', '--find-links', data.find_links,
291+
'--dest', './scratch2', '--interpreter-version', '3', 'simpleinterpdist',
292+
)
293+
assert (
294+
Path('scratch') / 'scratch2' / 'simpleinterpdist-2.0-py2.py3-none-any.whl'
295+
in result.files_created
296+
)
297+
298+
299+
@pytest.mark.network
300+
def test_download_specify_interpreter_version_and_platform(script, data):
301+
"""
302+
Test using "pip download --interpreter-version X --platform Y" to download
303+
a .whl archive supported for a specific interpreter and version combination.
304+
"""
305+
result = script.pip(
306+
'download', '--no-index', '--find-links', data.find_links,
307+
'--dest', '.',
308+
'--interpreter-version', '2',
309+
'--platform', 'linux_x86_64',
310+
'simpleinterpplatdist==1'
311+
)
312+
assert (
313+
Path('scratch') / 'simpleinterpplatdist-1.0-py2.py3-none-any.whl'
314+
in result.files_created
315+
)
316+
script.pip(
317+
'download', '--no-index', '--find-links', data.find_links,
318+
'--dest', '.',
319+
'--interpreter-version', '3',
320+
'--platform', 'linux_x86_64',
321+
'simpleinterpplatdist==1'
322+
)
323+
script.pip(
324+
'download', '--no-index', '--find-links', data.find_links,
325+
'--dest', '.',
326+
'--interpreter-version', '3',
327+
'--platform', 'macosx_10_9_x86_64.whl',
328+
'simpleinterpplatdist'
329+
)
330+
331+
result = script.pip(
332+
'download', '--no-index', '--find-links', data.find_links,
333+
'--dest', '.',
334+
'--interpreter-version', '27',
335+
'--platform', 'linux_x86_64',
336+
'simpleinterpplatdist==2'
337+
)
338+
assert (
339+
Path('scratch') / 'simpleinterpplatdist-2.0-cp27-none-linux_x86_64.whl'
340+
in result.files_created
341+
)
342+
343+
result = script.pip(
344+
'download', '--no-index', '--find-links', data.find_links,
345+
'--dest', '.',
346+
'--interpreter-version', '27',
347+
'--platform', 'macosx_10_10_x86_64',
348+
'simpleinterpplatdist==2'
349+
)
350+
assert (
351+
Path('scratch') / 'simpleinterpplatdist-2.0-cp27-none-macosx_10_9_x86_64.whl'
352+
in result.files_created
353+
)
354+
355+
result = script.pip(
356+
'download', '--no-index', '--find-links', data.find_links,
357+
'--dest', '.',
358+
'--interpreter-version', '2',
359+
'--platform', 'linux_x86_64',
360+
'simpleinterpplatdist==2'
361+
)
362+
assert (
363+
Path('scratch') / 'simpleinterpplatdist-2.0-py2.py3-none-linux_x86_64.whl'
364+
in result.files_created
365+
)
366+
367+
result = script.pip(
368+
'download', '--no-index', '--find-links', data.find_links,
369+
'--dest', '.',
370+
'--interpreter-version', '3',
371+
'--platform', 'macosx_10_10_x86_64',
372+
'simpleinterpplatdist==2'
373+
)
374+
assert (
375+
Path('scratch') / 'simpleinterpplatdist-2.0-py2.py3-none-macosx_10_9_x86_64.whl'
376+
in result.files_created
377+
)
378+
379+
result = script.pip(
380+
'download', '--no-index', '--find-links', data.find_links,
381+
'--dest', '.',
382+
'--interpreter-version', '3',
383+
'--platform', 'fake_platform',
384+
'simpleinterpplatdist==2',
385+
expect_error=True,
386+
)
387+
388+
result = script.pip(
389+
'download', '--no-index', '--find-links', data.find_links,
390+
'--dest', '.',
391+
'--interpreter-version', '3',
392+
'--platform', 'fake_platform',
393+
'simpleinterpdist==2'
394+
)
395+
assert (
396+
Path('scratch') / 'simpleinterpdist-2.0-py2.py3-none-any.whl'
397+
in result.files_created
398+
)

0 commit comments

Comments
 (0)