pip download with `--platform` specified fails to resolve dependencies with `sys_platform==` conditional
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
- [X] I agree to follow the PSF Code of Conduct.
Using cpython for reference.
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.
This is covered by #11664 so can probably be closed. Would be great to get a resolution to #11664.
Closing as a duplicate, indeed! Thanks.