Hi, why does the pex generated have different `#!`...
# general
c
Hi, why does the pex generated have different
#!
when I include the
complete_platforms
? Build with
complete_platforms
, produce pex with
#!/usr/bin/env <http://python3.9.PK|python3.9.PK>
Copy code
pex_binary(
    name="worker",
    complete_platforms=[
        "src/python:linux_py310",
    ],
    entry_point="main.py",
)
Build without it, produce pex with
#!/usr/bin/env <http://python3.10.PK|python3.10.PK>
My pants.toml hash
Copy code
[python]
interpreter_constraints = ["==3.10.*"]
And
src/python:linux_py310
is generated from
pex3 interpreter inspect --markers --tags
in
python:3.10-alpine
How did I get the python3.9 from?
And as a result, the pex won't run (as expected, given the
#!
)
Copy code
env: can't execute 'python3.9': No such file or directory
b
The details of how pants and pex interact to choose interpreters is a bit peculiar. One way to side step this is using https://www.pantsbuild.org/2.20/reference/targets/pex_binary#sh_boot to have shebang that doesn’t hard code a Python version. Like
pex_binary(…, sh_boot=True)
c
I am still using pants 2.18.1 and
sh_boot
is not available. Upgraded to 2.20.0 and the interpreter issue is gone without using
sh_boot
Still good to learn about
sh_boot
👍 1