aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mohr <mohrr@google.com>2021-04-14 16:18:23 -0700
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-04-14 23:47:16 +0000
commitd392611acc5d5c15ee25fcd3c6a3bde0cb6f0e00 (patch)
tree19f1994e08a8250dbab5ecda79610599c74cedf5
parent3f12bff9ed167a54f7f2427c2abc93ae27c8f8d9 (diff)
downloadpigweed-d392611acc5d5c15ee25fcd3c6a3bde0cb6f0e00.tar.gz
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>
-rw-r--r--bootstrap.sh2
-rw-r--r--pw_env_setup/util.sh9
2 files changed, 5 insertions, 6 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index 8eefca079..5f75d901d 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 348730c50..1379611cf 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_bootstrap() {
_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 @@ pw_cleanup() {
unset _NEW_PW_ROOT
unset _PW_ENV_SETUP_STATUS
- unset _pw_abspath
unset pw_none
unset pw_red
unset pw_bold_red