VirtualBox

Changeset 92652 in vbox for trunk/src/VBox/Installer


Ignore:
Timestamp:
Nov 30, 2021 4:50:46 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148548
Message:

Installer/linux: Install VirtualBox API bindings for every suitable Python version in the list of "usual suspects". bugref:9840

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/linux/routines.sh

    r92601 r92652  
    390390
    391391
    392 maybe_run_python_bindings_installer() {
    393     VBOX_INSTALL_PATH="${1}"
    394 
    395     # Check for specific python2 versions only, because python3 is handled
    396     # by a generic library which should work with 3.3 and later.
    397     PYTHON=""
    398     for p in python python2 python2.6 python2.7 python3; do
    399         if [ "`$p -c 'import sys
    400 if sys.version_info >= (2, 6) and (sys.version_info < (3, 0) or sys.version_info >= (3, 3)):
    401     print(\"test\")' 2> /dev/null`" = "test" ]; then
    402             PYTHON=$p
    403         fi
    404     done
    405     if [ -z "$PYTHON" ]; then
    406         echo  1>&2 "Python (2.6, 2.7 or 3.3 and later) unavailable, skipping bindings installation."
     392# install_python_bindings(pythonbin pythondesc)
     393# failure: non fatal
     394install_python_bindings()
     395{
     396    pythonbin="$1"
     397    pythondesc="$2"
     398
     399    # The python binary might not be there, so just exit silently
     400    if test -z "$pythonbin"; then
     401        return 0
     402    fi
     403
     404    if test -z "$pythondesc"; then
     405        errorprint "missing argument to install_python_bindings"
    407406        return 1
    408407    fi
    409408
    410     echo  1>&2 "Python found: $PYTHON, installing bindings..."
     409    echo 1>&2 "Python found: $PYTHON, installing bindings..."
     410
    411411    # Pass install path via environment
    412412    export VBOX_INSTALL_PATH
     
    415415    cat $CONFIG_DIR/python-$CONFIG_FILES >> $CONFIG_DIR/$CONFIG_FILES
    416416    rm $CONFIG_DIR/python-$CONFIG_FILES
    417     # remove files created during build
     417
     418    # Remove files created by Python API setup.
    418419    rm -rf $VBOX_INSTALL_PATH/sdk/installer/build
     420}
     421
     422maybe_run_python_bindings_installer() {
     423    VBOX_INSTALL_PATH="${1}"
     424
     425    # Loop over all usual suspect Python executable names and try installing
     426    # the VirtualBox API bindings. Needs to prevent double installs which waste
     427    # quite a bit of time.
     428    PYTHONS=""
     429    for p in python2.6 python2.7 python2 python3.3 python3.4 python3.5 python3.6 python3.7 python3.8 python3.9 python3.10 python3 python; do
     430        if [ "`$p -c 'import sys
     431if sys.version_info >= (2, 6) and (sys.version_info < (3, 0) or sys.version_info >= (3, 3)):
     432    print(\"test\")' 2> /dev/null`" != "test" ]; then
     433            continue
     434        fi
     435        # Get python major/minor version, and skip if it was already covered.
     436        # Uses grep -F to avoid trouble with '.' matching any char.
     437        pyvers="`$p -c 'import sys
     438print("%s.%s" % (sys.version_info[0], sys.version_info[1]))' 2> /dev/null`"
     439        if echo "$PYTHONS" | grep -Fq ":$pyvers:"; then
     440            continue
     441        fi
     442        # Record which version will be installed. If it fails there is no point
     443        # trying with different executable/symlink reporting the same version.
     444        PYTHONS="$PYTHONS:$pyvers:"
     445        install_python_bindings "$p" "Python $pyvers"
     446    done
     447    if [ -z "$PYTHONS" ]; then
     448        echo 1>&2 "Python (2.6, 2.7 or 3.3 and later) unavailable, skipping bindings installation."
     449        return 1
     450    fi
    419451
    420452    return 0
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette