Haven’t worked in our python/pants repo in a while...
# general
b
Haven’t worked in our python/pants repo in a while and (probably after upgrading to BigSur), I get this system popup every time I run pants. I tried reinstalling the python version pants is using (with pyenv), but that did not help. We’re on the latest stable pants version.
h
Huh
I've never seen that one before
What happens if you run that Python outside of Pants?
h
Hm, are you able to find which Python it is by using
which -a python
and trying to run
--version
on each entry? Also you could try adding
set -x
to the top of the
./pants
script - I imagine the failure might be happening when that Bash script tries to determine the interpreter to use to run Pants
b
All works as expected (i.e. no system popup) when running python3 directly
@hundreds-father-404 here’s the output from that:
Copy code
❯ which -a python
/Users/valera/.pyenv/shims/python
/Users/valera/.pyenv/shims/python
/usr/bin/python
❯ /Users/valera/.pyenv/shims/python --version
Python 3.8.11
❯ /Users/valera/.pyenv/shims/python --version
Python 3.8.11
❯ /usr/bin/python --version
Python 2.7.16
p
I’ve been running this periodically:
sudo softwareupdate --ignore "macOS Big Sur"
and today I added a new one
sudo softwareupdate --ignore "macOS Monterey"
That doesn’t help you, but /shrug
b
Here’s the output with `set -x`:
Copy code
❯ ./pants typecheck src/python/mdevxp/http_client/http_client.py
+ PYTHON_BIN_NAME=unspecified
+ PANTS_TOML=pants.toml
+ PANTS_BIN_NAME=./pants
+ PANTS_SETUP_CACHE=/Users/valera/.cache/pants/setup
+ [[ /Users/valera/.cache/pants/setup != /* ]]
++ uname -s
++ uname -m
+ PANTS_BOOTSTRAP=/Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64
+ PEX_VERSION=2.1.42
+ PEX_URL=<https://github.com/pantsbuild/pex/releases/download/v2.1.42/pex>
+ PEX_EXPECTED_SHA256=69d6b1b1009b00dd14a3a9f19b72cff818a713ca44b3186c9b12074b2a31e51f
+ VIRTUALENV_VERSION=20.4.7
++ cat
+ VIRTUALENV_REQUIREMENTS='virtualenv==20.4.7 --hash sha256:2b0126166ea7c9c3661f5b8e06773d28f83322de7a3ff7d06f0aed18c9de6a76
filelock==3.0.12 --hash sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836
six==1.16.0 --hash sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
distlib==0.3.2 --hash sha256:23e223426b28491b1ced97dc3bbe183027419dfc7982b4fa2f05d5f3ff10711c
appdirs==1.4.4 --hash sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128
importlib-resources==5.1.4; python_version < "3.7" --hash sha256:e962bff7440364183203d179d7ae9ad90cb1f2b74dcb84300e88ecc42dca3351
importlib-metadata==4.5.0; python_version < "3.8" --hash sha256:833b26fb89d5de469b24a390e9df088d4e52e4ba33b01dc5e0e4f41b81a16c00
zipp==3.4.1; python_version < "3.10" --hash sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea5a63edc3e03098
typing-extensions==3.10.0.0; python_version < "3.8" --hash sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84'
+ COLOR_RED='\x1b[31m'
+ COLOR_GREEN='\x1b[32m'
+ COLOR_RESET='\x1b[0m'
+ ulimit -n 10000
+++ dirname ./pants
++ cd .
++ pwd -P
+ cd /Users/valera/test-infra
++ determine_pants_version
++ '[' -n '' ']'
+++ get_pants_config_value pants_version
+++ local config_key=pants_version
+++ local 'optional_space=[[:space:]]*'
+++ local 'prefix=^pants_version[[:space:]]*=[[:space:]]*'
+++ local raw_value
++++ sed -ne '/^pants_version[[:space:]]*=[[:space:]]*/ s#^pants_version[[:space:]]*=[[:space:]]*##p' pants.toml
+++ raw_value='"2.7.0"'
+++ echo '"2.7.0"'
+++ tr -d '"'\'''
+++ return 0
++ pants_version=2.7.0
++ [[ -z 2.7.0 ]]
+++ echo 2.7.0
+++ cut -d . -f1
++ pants_major_version=2
+++ echo 2.7.0
+++ cut -d . -f2
++ pants_minor_version=7
++ [[ 2 -eq 1 ]]
++ echo 2.7.0
+ pants_version=2.7.0
++ determine_python_exe 2.7.0
++ local pants_version=2.7.0
++ set_supported_python_versions 2.7.0
++ local pants_version=2.7.0
++ local pants_major_version
++ local pants_minor_version
+++ echo 2.7.0
+++ cut -d . -f1
++ pants_major_version=2
+++ echo 2.7.0
+++ cut -d . -f2
++ pants_minor_version=7
++ [[ 2 -eq 1 ]]
++ [[ 2 -eq 2 ]]
++ [[ 7 -eq 0 ]]
++ [[ 2 -eq 2 ]]
++ [[ 7 -eq 1 ]]
++ [[ 2 -eq 2 ]]
++ [[ 7 -lt 5 ]]
++ supported_python_versions_decimal=('3.9' '3.8' '3.7')
++ supported_python_versions_int=('39' '38' '37')
++ supported_message='3.7, 3.8, or 3.9'
++ local 'requirement_str=For `pants_version = "2.7.0"`, Pants requires Python 3.7, 3.8, or 3.9 to run.'
++ local python_bin_name
++ [[ unspecified != \u\n\s\p\e\c\i\f\i\e\d ]]
+++ determine_default_python_exe
+++ for version in '"${supported_python_versions_decimal[@]}"'
+++ local interpreter_path
++++ command -v python3.9
+++ interpreter_path=/Users/valera/.pyenv/shims/python3.9
+++ [[ -z /Users/valera/.pyenv/shims/python3.9 ]]
++++ /Users/valera/.pyenv/shims/python3.9 --version
+++ [[ pyenv: python3.9: command not found

The `python3.9' command exists in these Python versions:
  3.9.0

Note: See 'pyenv help global' for tips on allowing both
      python2 and python3 to be found. == \p\y\e\n\v\:\ \p\y\t\h\o\n\3\.\9* ]]
+++ continue
+++ for version in '"${supported_python_versions_decimal[@]}"'
+++ local interpreter_path
++++ command -v python3.8
+++ interpreter_path=/Users/valera/.pyenv/shims/python3.8
+++ [[ -z /Users/valera/.pyenv/shims/python3.8 ]]
++++ /Users/valera/.pyenv/shims/python3.8 --version
+++ [[ '' == \p\y\e\n\v\:\ \p\y\t\h\o\n\3\.\8* ]]
+++ echo /Users/valera/.pyenv/shims/python3.8
+++ return 0
++ python_bin_name=/Users/valera/.pyenv/shims/python3.8
++ [[ -z /Users/valera/.pyenv/shims/python3.8 ]]
++ local python_exe
+++ get_exe_path_or_die /Users/valera/.pyenv/shims/python3.8
+++ local exe=/Users/valera/.pyenv/shims/python3.8
+++ command -v /Users/valera/.pyenv/shims/python3.8
++ python_exe=/Users/valera/.pyenv/shims/python3.8
++ local major_minor_version
+++ get_python_major_minor_version /Users/valera/.pyenv/shims/python3.8
+++ local python_exe=/Users/valera/.pyenv/shims/python3.8
+++ /Users/valera/.pyenv/shims/python3.8
++ major_minor_version=38
++ for valid_version in '"${supported_python_versions_int[@]}"'
++ [[ 38 == \3\9 ]]
++ for valid_version in '"${supported_python_versions_int[@]}"'
++ [[ 38 == \3\8 ]]
++ echo /Users/valera/.pyenv/shims/python3.8
++ return 0
+ python=/Users/valera/.pyenv/shims/python3.8
++ bootstrap_pants 2.7.0 /Users/valera/.pyenv/shims/python3.8 ''
++ local pants_version=2.7.0
++ local python=/Users/valera/.pyenv/shims/python3.8
++ local pants_sha=
++ local pants_requirement=pantsbuild.pants==2.7.0
++ local maybe_find_links
++ [[ -z '' ]]
++ maybe_find_links=
++ local python_major_minor_version
+++ get_python_major_minor_version /Users/valera/.pyenv/shims/python3.8
+++ local python_exe=/Users/valera/.pyenv/shims/python3.8
+++ /Users/valera/.pyenv/shims/python3.8
++ python_major_minor_version=38
++ local target_folder_name=2.7.0_py38
++ local bootstrapped=/Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38
++ [[ ! -d /Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38 ]]
++ echo /Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38
+ pants_dir=/Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38
+ pants_python=/Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38/bin/python
+ pants_binary=/Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38/bin/pants
+ pants_extra_args=
+ [[ -n '' ]]
+ exec /Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38/bin/python /Users/valera/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py38/bin/pants --pants-bin-name=./pants --pants-version=2.7.0 typecheck src/python/mdevxp/http_client/http_client.py
13:50:16.87 [INFO] Completed: Resolving 3rdparty/python/constraints.txt
13:50:17.92 [INFO] Completed: Extracting types-requests==2.25.11 from repository.pex
13:50:18.01 [INFO] Completed: Extracting requests==2.26.0 from repository.pex
13:50:18.78 [INFO] Completed: Composing 2 requirements to build requirements.pex from repository.pex
13:50:18.80 [INFO] Completed: typecheck - MyPy succeeded.
Success: no issues found in 1 source file



✓ MyPy succeeded.
The command succeeds, btw. It’s just the popup is really annoying.
h
Oh interesting, didn't realize it still succeeds. So does the popup happen when doing
python --version
? In particular, I suspect
/usr/bin/python
could be the culprit? MacOS deprecated Python 2
b
There is no popup when running either
python --version
or
/usr/bin/python
.
Any idea on how pants could be triggering
python2
?
h
Maybe in interpreter discovery?
Does this happen even if you just run a no-op
./pants
?
👍 1
b
Nope. Neither
./pants
nor
./pants help
trigger it.
h
But
./pants test
,
./pants lint
, etc do? If so, that implies that this is not coming from the Python to run Pants itself. But rather the Python interpreters pants is using to run your own code
h
So I'm guessing this is interpreter discovery
it sees python2, tries to execute it to check what version it declares, and ...