pip icon indicating copy to clipboard operation
pip copied to clipboard

pip download with `--platform` specified fails to resolve dependencies with `sys_platform==` conditional

Open tim-stephenson opened this issue 2 years ago • 3 comments

Description

When calling pip download --only-binary ":all:" with a platform specifier (--platform), it does not properly follow sys_platform specifiers defined in the dependencies. The example I am trying to download jupyter_core with dependencies specified in the pyproject.toml as follows:

dependencies = [
  "platformdirs>=2.5",
  "traitlets>=5.3",
  "pywin32>=300 ; sys_platform == 'win32' and platform_python_implementation != 'PyPy'"
]

In this situation pip uses my own platform instead of the one specified with the --platform specifier

Expected behavior

Should download required whl files for jupyter_core

pip version

23.3.2

Python version

3.10

OS

Windows 10

How to Reproduce

pip download "jupyter-core==5.7.1" --only-binary ":all:" --python-version 310 --platform manylinux_2_17_x86_64 --platform manylinux_2_12_x86_64 --platform manylinux_2_5_x86_64

Output

ERROR: Could not find a version that satisfies the requirement pywin32>=300; sys_platform == "win32" and platform_python_implementation != "PyPy" (from jupyter-core) (from versions: none)
ERROR: No matching distribution found for pywin32>=300; sys_platform == "win32" and platform_python_implementation != "PyPy"

Code of Conduct

tim-stephenson avatar Jan 09 '24 15:01 tim-stephenson

Using cpython for reference.

tim-stephenson avatar Jan 09 '24 15:01 tim-stephenson

I ran into this same issue with our package for helping teach Python in internet-limited locations. We create partial PyPI mirrors on local teaching servers using pypi-mirror, but when running on Windows we can't create the mirrors for non-Windows platforms.

https://github.com/carpentriesoffline/offlinedatasci/issues/95

I'm willing to consider making a PR if someone with some experience thinks its relatively doable for a first time contributor and can point me in the right direction. Alternatively if anyone has thoughts on a work around I'd appreciate it.

ethanwhite avatar Apr 22 '24 11:04 ethanwhite

This is covered by #11664 so can probably be closed. Would be great to get a resolution to #11664.

ethanwhite avatar Apr 27 '24 16:04 ethanwhite

Closing as a duplicate, indeed! Thanks.

ichard26 avatar Jun 23 '24 01:06 ichard26