https://pantsbuild.org/ logo
#general
Title
# general
i

icy-hair-30586

05/02/2022, 7:07 AM
A question on the interpreter chosen for the PEX shebang: I have a pex defined as
Copy code
pex_binary(
    name="app_binary",
    execution_mode="venv",
    dependencies=[
        ":app",
        "3rdparty/python:uvicorn",  # This isn't imported anywhere, so dependency inference doesn't find it.
    ],
    entry_point="main.py",
    platforms=["linux_x86_64-cp-3.8.13-cp38m"],
    interpreter_constraints=["==3.8.13"]
)
but when I build the image and try to run it, the error is
Copy code
/app_binary.pex 
/usr/bin/env: 'python3.10': No such file or directory
my expectation was that the shebang would pick an interpreter that matches the constraints. Besides setting shebang explicitly, how can I ensure a proper interpreter gets picked?
e

enough-analyst-54434

05/02/2022, 3:52 PM
Your expectation is the right one and this is a current wart with PEX that Pants can't do much about (the most relevant issue over in PEX being https://github.com/pantsbuild/pex/issues/1020). In short, you should remove
interpreter_constraints=["==3.8.13"]
since Pants actually ignores it in this case and instead set the
shebang
, possibly to
shebang="/usr/bin/env python3.8"
.
👍 1
6 Views