Skip to content
Browse files

Fix ./pants2 overriding desired $PY interpreter (#7338)

### Problem
Very similar to #7334 that `./pants2` was overriding interpreter constraints, it's become a problem that it also overrides `$PY`, which is to bootstrap Pants.

This led to an issue where we meant to bootstrap Pants with Python 2.7.15 but instead bootstrapped with 2.7.13. Specifically, see, where we had set $PY to point to pyenv's `python2.7`, but it is using the system Python.

### Solution
Allow the env var to be pre-set, else default to using `python2.7`.

#### Also simplify ``
Because we override $PY and $PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS already, there is no advantage to using ./pants2 vs ./pants beyond additional complexity. So, we always use `./pants`.

### Result
`./pants2` will default to using unconstrained Python 2.7. `PY=/usr/bin/python2.7` will run with Python 2 and that specific interpreter.

Both commands will provide default interpreter constraints for spawned subprocesses.
  • Loading branch information...
Eric-Arellano committed Mar 8, 2019
1 parent 59d92ea commit 646699b361f915355ed4d20920717dabef1200b1
Showing with 2 additions and 4 deletions.
  1. +1 −3 build-support/bin/
  2. +1 −1 pants2
@@ -111,10 +111,8 @@ export PANTS_DEV=1
# and `./pants2`, so those scripts cannot set the relevant environment variables.
if [[ "${python_two:-false}" == "false" ]]; then
export PY="${PY:-python${py_major_minor}}"

@@ -133,7 +131,7 @@ if [[ "${run_bootstrap:-false}" == "true" ]]; then
if [[ "${run_bootstrap_clean:-false}" == "true" ]]; then
./build-support/python/ || die "Failed to clean before bootstrapping pants."
${bootstrap_pants_script} binary \
./pants binary \
src/python/pants/bin:pants_local_binary && \
mv dist/pants_local_binary.pex pants.pex && \
./pants.pex -V
2 pants2
@@ -4,7 +4,7 @@

# This bootstrap script invokes Pants using a Python 2 interpreter.

export PY="python2.7"
export PY="${PY:-python2.7}"

# Allow spawned subprocesses, such as unit tests, to execute with either Python 2 and Python 3.
# So long as the target does not have a compatibility constraint that requires only Python 3, the

0 comments on commit 646699b

Please sign in to comment.
You can’t perform that action at this time.