VirtualBox

Changeset 103028 in vbox for trunk/src/VBox/Installer/darwin


Ignore:
Timestamp:
Jan 24, 2024 3:53:59 PM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161263
Message:

Main/Python: Big revamp to modernize our vboxapi Python package to now use a so-called src-layout, which also can be used with pip directly. Also added compatibility w/ Python 3.12 where distutils are not shipped anymore. We also now do have automatic linting for our code, which hopefully should improve quality in this area. Moved some Python-related files into an own sub folder so that it's more clear to which these belong to. The "sdk/installer" directories also have an own "python" sub directory where the stuff resides now. The Windows installer also uses "sdk/installer" instead of "sdk/install", to match the other platforms. bugref:10579

Location:
trunk/src/VBox/Installer/darwin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/darwin/Makefile.kmk

    r101552 r103028  
    721721                        $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/sdk \
    722722                        $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/sdk/installer \
    723                         $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/sdk/installer/vboxapi \
     723                        $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/sdk/installer/python/vboxapi \
    724724                        $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/sdk/bindings/ \
    725725                        $(VBOX_PATH_VBOX_APP_TMP)/Contents/MacOS/sdk/bindings/xpcom \
  • trunk/src/VBox/Installer/darwin/VirtualBox/postflight

    r98103 r103028  
    3434# Install the Python bindings
    3535#
     36## @todo r=andy Merge this code with linux/routines.sh!
     37#
    3638VBOX_INSTALL_PATH=/Applications/VirtualBox.app/Contents/MacOS
    37 PYTHON="python python2.3 python2.5 python2.6 python2.7"
    38 if [ -e "${VBOX_INSTALL_PATH}/sdk/installer/vboxapisetup.py" ]; then
    39     for p in $PYTHON; do
     39PYTHON_INSTALLER_PATH="$VBOX_INSTALL_PATH/sdk/installer/python"
     40PYTHON_BINARIES="\
     41    python2.7  \
     42    python2    \
     43    python3.3  \
     44    python3.4  \
     45    python3.5  \
     46    python3.6  \
     47    python3.7  \
     48    python3.8  \
     49    python3.9  \
     50    python3.10 \
     51    python3.11 \
     52    python3.12 \
     53    python3    \
     54    python"
     55
     56if [ -e "$PYTHON_INSTALLER_PATH/vboxapisetup.py" ]; then
     57    for PYTHON_BIN in $PYTHON_BINARIES; do
    4058        # Install the python bindings if python is in the path
    41         if [ "`\${p} -c 'print "test"' 2> /dev/null`" = "test" ]; then
    42                 echo  1>&2 "Python found: ${p}, installing bindings..."
    43                 # Pass install path via environment
    44                 export VBOX_INSTALL_PATH
    45                 /bin/sh -c "cd $VBOX_INSTALL_PATH/sdk/installer && ${p} vboxapisetup.py install"
    46                 /bin/sh -c "cd $VBOX_INSTALL_PATH/sdk/installer && ${p} vboxapisetup.py clean --all"
     59        if [ "`\${PYTHON_BIN} -c 'print "test"' 2> /dev/null`" = "test" ]; then
     60            echo  1>&2 "Python found: ${PYTHON_BIN}, installing bindings..."
     61            # Pass install path via environment
     62            export VBOX_INSTALL_PATH
     63            # Check if python has working distutils
     64            "$PYTHON_BIN" -c "from distutils.core import setup" > /dev/null 2>&1
     65            if test "$?" -ne 0; then
     66                echo 1>&2 "Python $PYTHON_VER does not have package 'distutils', checking for 'setuptools'..."
     67                # Since Python 3.12 there are no distutils anymore. See PEP632.
     68                "$PYTHON_BIN" -c "from setuptools import setup" > /dev/null 2>&1
     69                if test "$?" -ne 0; then
     70                    echo 1>&2 "Python $PYTHON_VER also does not have package 'setuptools'. Skipping installation."
     71                    return 0
     72                fi
     73                # When we reach here, we have to use 'pip' in order to install our bindings (Python >= 3.12).
     74                if test -x "`which pip 2>/dev/null`"; then
     75                    PYTHON_PIP_BIN=$(which pip)
     76                else
     77                    echo 1>&2 "Python package manager 'pip' not found. Skipping installation."
     78                fi
     79            fi
     80
     81            if [ -n "$PYTHON_PIP_BIN" ]; then
     82                # Note: We use '-v' to show verbose output of our setup.py script on error.
     83                $SHELL -c "cd ${PYTHON_INSTALLER_PATH} && ${PYTHON_PIP_BIN} -v install ./vboxapi"
     84            else
     85                $SHELL -c "cd ${PYTHON_INSTALLER_PATH} && ${PYTHON_BIN} vboxapisetup.py install"
     86                $SHELL -c "cd ${PYTHON_INSTALLER_PATH} && ${PYTHON_BIN} vboxapisetup.py clean --all"
     87            fi
    4788        fi
    4889    done
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