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

--interpreter-constraint causes the current platform to always be used #957

Closed
Eric-Arellano opened this issue Apr 16, 2020 · 2 comments
Closed
Labels

Comments

@Eric-Arellano
Copy link
Contributor

From a macOS machine, without constraints:

▶ pex --platform=linux-x86_64-cp-37-cp37m --output-file test.pex cryptography && unzip -l test.pex | grep 'macosx' | wc -l
       0

With constraints:

▶ pex --platform=linux-x86_64-cp-37-cp37m --interpreter-constraint 'CPython>=3.6' --output-file test.pex cryptography && unzip -l test.pex | grep 'macosx' | wc -l
     151

This is a problem for Pants, which always sets --interpreter-constraint, meaning it is never possible with Pants to create a binary without current as a platform.

@jsirois
Copy link
Member

jsirois commented Apr 16, 2020

Pants shouldn't do this. The only reasonable interpretation of interpreter constraints is a local PEX build.

@jsirois
Copy link
Member

jsirois commented Apr 16, 2020

Basically --platform implies remote / don't build. Everything else (except --no-build) implies pick a local interpreter.

Eric-Arellano added a commit to pantsbuild/pants that referenced this issue Apr 17, 2020
…specified (#9563)

### Problem

When specifying `platforms` on a `python_binary`, you'd expect the built wheel to only have those specified platforms. But, it currently will always include the `current` platform.

This is because we are unconditionally passing the flag `--interpreter-constraint` to Pex, which forces `current` to be used, per pex-tool/pex#957. As explained there, Pex is behaving correctly; the issue is with Pants.

### Solution

When `platforms` are set, ignore interpreter constraints. 

Platforms already embed interpreter constraints in them, e.g. `linux-x86_64-cp-37-cp37m` saying that it needs compatibility with CPython 3.7. So, `platforms` is an override over interpreter constraints.

This change only applies when using the target with `./pants run` and `./pants binary`. Other goals like `./pants test` will ignore the `platforms` value and use interpreter constraints like normal.

[ci skip-rust-tests]
[ci skip-jvm-tests]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants