pip: Various package-index filtering flags do not affect the environment markers
This is a common pattern that I’m seeing in pip’s issue tracker; so filing an issue to (a) trigger a discussion of how to improve documentation / output / errors to better deal with the mismatch in user expectations vs behaviour here and (b) consolidate those issues.
Basically, the fundamental problem here is that pip has various options that affect the wheels that pip will consider when triaging things (--platform <platform>, --python-version <python_version>, --implementation <implementation>, --abi <abi>) but those do not affect the marker evaluation environment for dependencies.
This results in a subtle failure mode: pip install [options] package will use a wheel for package that has a (hypothetical) Python version 9.22 but when evaluating environment markers (https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers), that would still use the environment for the current Python interpreter.
It is not possible to compute the environment markers based on the values passed in by the user via the CLI.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 17 (13 by maintainers)
Commits related to this issue
- Fixing artifacts download - back to matrix due to https://github.com/pypa/pip/issues/11664 — committed to djpugh/azure_devops_artifacts_helpers by djpugh 4 years ago
- Fixing artifacts download - back to matrix due to https://github.com/pypa/pip/issues/11664 — committed to djpugh/azure_devops_artifacts_helpers by djpugh 4 years ago
- Fixing artifacts download - back to matrix due to https://github.com/pypa/pip/issues/11664 — committed to djpugh/azure_devops_artifacts_helpers by djpugh 4 years ago
- Do not create PyPI mirrors for macos and Linux on Windows Currently there is an issue with pip that prevents installing the notebook package's dependencies (and possibly others) for non-Windows OSs o... — committed to ethanwhite/offlinedatasci by ethanwhite 3 years ago
FWIW, re: https://github.com/pypa/pip/issues/11664#issuecomment-3002029823, Pex 2.41.0 now has 1st class support for this via
pex3 downloadwhere you can use--platformor--complete-platformto download distributions needed by foreign systems.I’m copying @uranusjr’s UX proposal from https://github.com/pypa/pip/issues/9981#issuecomment-843046920 here:
pip install --marker="os_name='nt'" --marker="platform_release='...'"I assume that whenever one
--markeris provided, none of the other markers usually provided by the platform will be made available to the resolver. I suppose it would also make sense to rely only on explicit markers whenever any of--platform,--implementationor--python-versionis used. Installation or build would fail if any specifier uses a marker that is not explicitly provided by the user.Oh, that wasn’t clear. 😅
We’re in complete agreement here. 😃
@hackowitz-af I’ve started https://github.com/pex-tool/pex/discussions/2789 for this discussion re: possible Pex use.
@hackowitz-af If you’re not using Windows, you might be able to use Pex for this. It uses Pip under the covers, but patches it to implement this feature as noted in https://github.com/pypa/pip/issues/10050.
@hackowitz-af Yes, this is a known limitation of pip, and a non-trivial feature to implement, as pip is a volunteer project this feature is waiting on someone to propose and then implement a design that maintainers are generally happy with, until that happens this feature request will stay open.
However on your second issue:
I think you have a misunderstanding here
--only-binary=:all:means that no sdists should be considered, so this is working as intended. If there is some feature you think is missing or some bug with this please open a new issue.I think the right move here is doing what pex has done, and taking a complete environment specification including environment markers; and not inferring anything from the interpreter when that’s done. It’ll be a slightly disruptive change, like any other change, but we’ll be in a better spot in terms of this.
Thoughts on this?