https://pantsbuild.org/ logo
#development
Title
# development
b

bitter-ability-32190

03/06/2023, 5:25 PM
Looking at
src/python/pants/backend/python/util_rules/pex.py
, and specifically the usages of
PexCliProcess
and the Python it is run with. ๐Ÿงต
build_pex
is the only usage of a user Python running the Pex CLI process. Is this really necessary? Would it change the behavior of building a PEX to unconditionally use (some) Python which isn't the Python we run user code with?
e

enough-analyst-54434

03/06/2023, 5:30 PM
Pex will use the Python it is run with to build PEX files if the Python it is run with meets ICs. If the PEX build requires any native sdist builds, the Python better be able to handle that.
That is the only restriction.
b

bitter-ability-32190

03/06/2023, 5:31 PM
Bummer. Any way to disable that behavior and treat the running Python as some foreign thing? As if Pex was written in FORTRAN and
sys.executable
is the FORTRAN interpreter? (obviously a thought experiment)
e

enough-analyst-54434

03/06/2023, 5:31 PM
Yes, there is. Do you want me to feed you that or do you want to read more 1st?
b

bitter-ability-32190

03/06/2023, 5:32 PM
I assume its somewhere in https://pex.readthedocs.io/en or
--help
?
e

enough-analyst-54434

03/06/2023, 5:33 PM
You could figure it out just from Pants code if you paged the util rules code in. But ...
I find this frustrating. This is what
PEX_PYTHON_PATH
/
--python-path
is for.
b

bitter-ability-32190

03/06/2023, 5:35 PM
Ah yeah I would'nt have pieced that together ๐Ÿ˜•
e

enough-analyst-54434

03/06/2023, 5:36 PM
You definitely should have been able to.
b

bitter-ability-32190

03/06/2023, 5:37 PM
I don't see the behavior of using the running Python when building a pex anywhere in
--help
looking specifically at the
PEX target environment options:
section, so I don't feel too bad ๐Ÿ™‚
e

enough-analyst-54434

03/06/2023, 5:37 PM
Like I said, it's right in the Pants source code.
You were incurious about existing util rules grokking.
b

bitter-ability-32190

03/06/2023, 5:38 PM
Unless its
The Python interpreter to use (default: current interpreter)
, in which case yay I found it, but not how to change it in the absense of an absolute path
I also find the existing pex rule code extremely hard to grok. Likely a result of the complexity of the ecosystem
e

enough-analyst-54434

03/06/2023, 5:40 PM
Agreed! But I'm frustrated that you outsource the grokking. It's complicated but nowhere near impossible and when you grok a thing, you really know it. It's a good bit of pain to go through.
b

bitter-ability-32190

03/06/2023, 5:51 PM
Looks like
--python-path
is unconditionally passed (because the controlling variable is never
False
) so I'll pin this with a comment and switch the pex invocation to use some mystical Python
3 Views