pw_env_setup: Use python, python3, or python2

Change-Id: Id6714e02729ac8b95c9db3f4a545f3bd8273e68b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/40982
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/bootstrap.sh b/bootstrap.sh
index 8eefca0..5f75d90 100644
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -15,7 +15,7 @@
 # This script must be tested on bash, zsh, and dash.
 
 _bootstrap_abspath () {
-  python -c "import os.path; print(os.path.abspath('$@'))"
+  $(which python || which python3 || which python2) -c "import os.path; print(os.path.abspath('$@'))"
 }
 
 # Users are not expected to set PW_CHECKOUT_ROOT, it's only used because it
diff --git a/pw_env_setup/util.sh b/pw_env_setup/util.sh
index 348730c..1379611 100644
--- a/pw_env_setup/util.sh
+++ b/pw_env_setup/util.sh
@@ -12,10 +12,6 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-_pw_abspath () {
-  python -c "import os.path; print(os.path.abspath('$@'))"
-}
-
 # Just in case PATH isn't already exported.
 export PATH
 
@@ -202,6 +198,10 @@
     _PW_PYTHON="$PW_BOOTSTRAP_PYTHON"
   elif which python &> /dev/null; then
     _PW_PYTHON=python
+  elif which python3 &> /dev/null; then
+    _PW_PYTHON=python3
+  elif which python2 &> /dev/null; then
+    _PW_PYTHON=python2
   else
     pw_bold_red "Error: No system Python present\n"
     pw_red "  Pigweed's bootstrap process requires a local system Python."
@@ -265,7 +265,6 @@
   unset _NEW_PW_ROOT
   unset _PW_ENV_SETUP_STATUS
 
-  unset _pw_abspath
   unset pw_none
   unset pw_red
   unset pw_bold_red