Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding validation when Python interpreter constraints conflict with platforms #9560

Open
Eric-Arellano opened this issue Apr 16, 2020 · 0 comments
Labels
backend: Python Python backend-related issues enhancement

Comments

@Eric-Arellano
Copy link
Contributor

Soon, we will fix platforms in V2 to override whatever the --interpreter-constraint flag would have been that we normally pass to Pex. As explained in pex-tool/pex#957, it does not make sense to specify both flags.

But, this means that it is possible, for example, for the transitive closure of a python_binary to have Python 2.7 interpreter constraints, but a platform of linux-x86_64-cp-37-cp37m. We would end up building a Pex compatible with Py37, even though the code would normally use Py27. Arguably, it would be better to warn/error with a nice error message here.

Implementation wise, we could leverage pkg_resources:

from pkg_resources import Requirement
>>> r = Requirement.parse("CPython>=3.4,!=3.6.4,!=3.7.0")
>>> "3.6" in r
True
>>> "3.6.4" in r
False
>>> "3.7.0" in r
False
>>> "3.7" in r
False
>>> "3.7.1" in r
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Python Python backend-related issues enhancement
Projects
None yet
Development

No branches or pull requests

3 participants