]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: locate path to the python3 binary
authorMichael Fritch <mfritch@suse.com>
Thu, 18 Nov 2021 21:54:56 +0000 (14:54 -0700)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 13 Sep 2022 16:17:20 +0000 (12:17 -0400)
fixes incorrect shebang in the compiled zipfile (`#!python3`)

Signed-off-by: Michael Fritch <mfritch@suse.com>
src/cephadm/build.sh

index 3aff16d354aee4ef614fae5b09427a7fa75d39a3..94e8a3247c99bd98ecb604986b5c2804aef0baee 100755 (executable)
@@ -9,6 +9,8 @@ clean_up() {
 }
 trap clean_up EXIT
 
+PYTHON=$(which python3)
+
 # Create build directory and install required dependencies
 target_fpath="$(pwd)/cephadm"
 if [ -n "$1" ]; then
@@ -16,13 +18,13 @@ if [ -n "$1" ]; then
 fi
 builddir=$(mktemp -d)
 if [ -e "requirements.txt" ]; then
-    python3 -m pip install -r requirements.txt --target ${builddir}
+    $PYTHON -m pip install -r requirements.txt --target ${builddir}
 fi
 
 # Make sure all newly created source files are copied here as well!
 cp cephadm.py ${builddir}/__main__.py
 
-version=$(python3 --version)
+version=$($PYTHON --version)
 if [[ "$version" =~ ^Python[[:space:]]([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$ ]]; then
     major=${BASH_REMATCH[1]}
     minor=${BASH_REMATCH[2]}
@@ -33,7 +35,7 @@ if [[ "$version" =~ ^Python[[:space:]]([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:
         compress="--compress"
     fi
 
-    python3 -mzipapp -p python3 ${builddir} ${compress} --output $target_fpath
+    $PYTHON -mzipapp -p $PYTHON ${builddir} ${compress} --output $target_fpath
     echo written to ${target_fpath}
 else
     echo "Couldn't parse Python version"