try to use the same python as hg automatically

Mon, 07 Mar 2022 23:11:41 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 07 Mar 2022 23:11:41 -0600
changeset 985
349ea9f736b9
parent 984
9c7c452cc87f
child 986
b06e863e3175

try to use the same python as hg automatically

bin/setup-hg-evolve file | annotate | diff | comparison | revisions
bin/setup-hg-git file | annotate | diff | comparison | revisions
--- a/bin/setup-hg-evolve
+++ b/bin/setup-hg-evolve
@@ -1,12 +1,16 @@
 #!/bin/bash
 set -eu -o pipefail
 
-if ! (command -v pip3 && pip3 -V) &>/dev/null; then
+hg --version >/dev/null
+
+shebang="$(head -n 1 $(which hg) | sed 's/^#!//')"
+
+if ! ($shebang -m pip -V) &>/dev/null; then
   curl -fsSL --compressed https://bootstrap.pypa.io/get-pip.py |
-    python3 - --user
+    $shebang - --user
 fi
 
-pip3 install --user --upgrade hg-evolve
+$shebang -m pip install --user --upgrade hg-evolve
 
 if ! grep -qsw evolve ~/.hgext/hgrc; then
   printf '[extensions]\nevolve =\n' >> ~/.hgext/hgrc
--- a/bin/setup-hg-git
+++ b/bin/setup-hg-git
@@ -1,12 +1,16 @@
 #!/bin/bash
 set -eu -o pipefail
 
-if ! (command -v pip3 && pip3 -V) &>/dev/null; then
+hg --version >/dev/null
+
+shebang="$(head -n 1 $(which hg) | sed 's/^#!//')"
+
+if ! ($shebang -m pip -V) &>/dev/null; then
   curl -fsSL --compressed https://bootstrap.pypa.io/get-pip.py |
-    python3 - --user
+    $shebang - --user
 fi
 
-pip3 install --user --upgrade hg-git
+$shebang -m pip install --user --upgrade hg-git
 
 if ! grep -qsw hggit ~/.hgext/hgrc; then
   printf '[extensions]\nhggit =\n' >> ~/.hgext/hgrc

mercurial