Open
Description
Similar to #2725, if a pex is built with --sh-boot --venv
, executed at least once with the default configuration (to seed the venv in the PEX_ROOT cache), then certain env vars to control the details of the execution are ignored:
- explicitly selecting a python interpreter with
PEX_PYTHON
- constraining the interpreter search with
PEX_PYTHON_PATH
- inserting additional requirements/code into the venv via
PEX_PATH
This behaviour differs to non---sh-boot
where the vars are not ignored. Here's the results of running the reproducer below on my machine:
execution | result with --no-sh-boot |
result with --sh-boot |
---|---|---|
seeding venv interpreter | 3.10 | 3.10 |
PEX_PYTHON interpreter |
3.9 | 3.10 ❌ |
PEX_PYTHON_PATH interpreter |
3.9 | 3.10 ❌ |
PEX_PATH can import cowsay ? |
✅ | ❌ |
Reproducer that tests overriding the PEX_PYTHON*
vars to choose Python 3.9 for PEX execution, and also PEX_PATH
for inserting and importing a cowsay
requirement:
export PEX_ROOT=$(mktemp -d)
pex --version # 2.33.7
pex cowsay -o cowsay.pex
for boot_arg in --no-sh-boot --sh-boot; do
echo "# Bootstrap: ${boot_arg}"
pex "$boot_arg" --venv -o base.pex
echo "## Seed venv: what default version?"
./base.pex -c "import sys; print(sys.version)"
echo "## Run with Python 3.9 via PEX_PYTHON"
PEX_PYTHON=$(which python3.9) ./base.pex -c "import sys; print(sys.version)"
echo "## Run with Python 3.9 via PEX_PYTHON_PATH"
path_dir=$(mktemp -d)
ln -s "$(which python3.9)" "$path_dir"
PEX_EMIT_WARNINGS=false PEX_PYTHON_PATH=$path_dir ./base.pex -c "import sys; print(sys.version)"
echo "## Run with additional requirements via PEX_PATH"
PEX_PATH=cowsay.pex ./base.pex -c "import cowsay; print(cowsay.__version__)"
echo
echo
done