stale-nightfall-29801
11/11/2021, 11:23 AM.pex
with the shebang #!/usr/bin/env python3.8
despite my pants.toml telling it to use python3.9
[python-setup]
interpreter_constraints = ["CPython==3.9.*"]
And the platforms being set to 3.9
pex_binary(
name="server",
platforms=["linux_x86_64-cp-39-cp39", "macosx_11.0_x86_64-cp-39-cp39"],
entry_point="some_project/server.py:main"
)
The same happens if I set the bex_binary's interpreter_constraints
directlyenough-analyst-54434
11/11/2021, 4:21 PMshebang
field on `pex_binary`: https://www.pantsbuild.org/docs/reference-pex_binarystale-nightfall-29801
11/11/2021, 4:51 PMenough-analyst-54434
11/12/2021, 1:50 AM#!/usr/bin/env pythonX.Y
where X.Y
is taken from the interpreter used to execute the Pex CLI in this case of a pure --platform
PEX. So Pants is running Pex with python 3.8 (probably because that's the Python Pants itself is running with - which need no match your code's interpreter constraints at all). For PEXes that use only `--platform`like yours, any interpreter will do when running the Pex CLI since --platform
is shorthand for "Build this PEX file for this - foreign - platform. I.E.: Only fetch pre-built wheels, never try to build sdists into wheels.". It might make sense for Pex to treat the pure --platform
case specially, and iff all platforms in the list share the same Python major / minor version, use that for the X.Y in the shebang.
Generally, though, multiplatform PEXes can span many major minors, say >=3.7,<3.10. In that general case Pex cannot pick a shebang that will always work. For example, #!/usr/bin/env python
, which would be one obvious choice, might pick Python 2.7 on one machine, and that would be incorrect. So mayube #!/usr/bin/env python3
? Same problem, might pick Python 3.6. Even weirder - on some distros, the python3
version of the - say - Python 3.7 binary, might not be installed at all. Although it's typical to have python
, pythonX
and pythonX.Y
its not done by all distributions.stale-nightfall-29801
11/12/2021, 9:42 AM