Browse code

Remove crusty old python 3 package version logic

If we are running with python3, just assume that any
package that is not blacklisted is available for py3
and just attempt to install it and let pip sort it out
whether it gets installed from a local or remote package.

Change-Id: Ic05d183e489320f6dfc721575d47e7e4d661f87c
Closes-Bug: #1820892

Matt Riedemann authored on 2019/04/02 01:19:45
Showing 1 changed files
... ...
@@ -81,34 +81,6 @@ function pip_install_gr_extras {
81 81
     pip_install $clean_name[$extras]
82 82
 }
83 83
 
84
-# Determine the python versions supported by a package
85
-function get_python_versions_for_package {
86
-    local name=$1
87
-    cd $name && python setup.py --classifiers \
88
-        | grep 'Language' | cut -f5 -d: | grep '\.' | tr '\n' ' '
89
-}
90
-
91
-# Check for python3 classifier in local directory
92
-function check_python3_support_for_package_local {
93
-    local name=$1
94
-    cd $name
95
-    set +e
96
-    classifier=$(python setup.py --classifiers \
97
-        | grep 'Programming Language :: Python :: 3')
98
-    set -e
99
-    echo $classifier
100
-}
101
-
102
-# Check for python3 classifier on pypi
103
-function check_python3_support_for_package_remote {
104
-    local name=$1
105
-    set +e
106
-    classifier=$(curl -s -L "https://pypi.python.org/pypi/$name/json" \
107
-        | grep '"Programming Language :: Python :: 3"')
108
-    set -e
109
-    echo $classifier
110
-}
111
-
112 84
 # python3_enabled_for() assumes the service(s) specified as arguments are
113 85
 # enabled for python 3 unless explicitly disabled. See python3_disabled_for().
114 86
 #
... ...
@@ -259,52 +231,20 @@ function pip_install {
259 259
             cmd_pip=$(get_pip_command $PYTHON2_VERSION)
260 260
             local sudo_pip="sudo -H"
261 261
             if python3_enabled; then
262
-                # Look at the package classifiers to find the python
263
-                # versions supported, and if we find the version of
264
-                # python3 we've been told to use, use that instead of the
265
-                # default pip
266
-                local python_versions
267
-
268 262
                 # Special case some services that have experimental
269 263
                 # support for python3 in progress, but don't claim support
270 264
                 # in their classifier
271 265
                 echo "Check python version for : $package_dir"
272 266
                 if python3_disabled_for ${package_dir##*/}; then
273 267
                     echo "Explicitly using $PYTHON2_VERSION version to install $package_dir based on DISABLED_PYTHON3_PACKAGES"
274
-                elif python3_enabled_for ${package_dir##*/}; then
268
+                else
269
+                    # For everything that is not explicitly blacklisted with
270
+                    # DISABLED_PYTHON3_PACKAGES, assume it supports python3
271
+                    # and we will let pip sort out the install, regardless of
272
+                    # the package being local or remote.
275 273
                     echo "Using $PYTHON3_VERSION version to install $package_dir based on default behavior"
276 274
                     sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
277 275
                     cmd_pip=$(get_pip_command $PYTHON3_VERSION)
278
-                elif [[ -d "$package_dir" ]]; then
279
-                    python_versions=$(get_python_versions_for_package $package_dir)
280
-                    if [[ $python_versions =~ $PYTHON3_VERSION ]]; then
281
-                        echo "Automatically using $PYTHON3_VERSION version to install $package_dir based on classifiers"
282
-                        sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
283
-                        cmd_pip=$(get_pip_command $PYTHON3_VERSION)
284
-                    else
285
-                        # The package may not have yet advertised python3.5
286
-                        # support so check for just python3 classifier and log
287
-                        # a warning.
288
-                        python3_classifier=$(check_python3_support_for_package_local $package_dir)
289
-                        if [[ ! -z "$python3_classifier" ]]; then
290
-                            echo "Automatically using $PYTHON3_VERSION version to install $package_dir based on local package settings"
291
-                            sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
292
-                            cmd_pip=$(get_pip_command $PYTHON3_VERSION)
293
-                        else
294
-                            echo "WARNING: Did not find python 3 classifier for local package $package_dir"
295
-                        fi
296
-                    fi
297
-                else
298
-                    # Check pypi as we don't have the package on disk
299
-                    package=$(echo $package_dir | grep -o '^[.a-zA-Z0-9_-]*')
300
-                    python3_classifier=$(check_python3_support_for_package_remote $package)
301
-                    if [[ ! -z "$python3_classifier" ]]; then
302
-                        echo "Automatically using $PYTHON3_VERSION version to install $package based on remote package settings"
303
-                        sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
304
-                        cmd_pip=$(get_pip_command $PYTHON3_VERSION)
305
-                    else
306
-                        echo "WARNING: Did not find python 3 classifier for remote package $package_dir"
307
-                    fi
308 276
                 fi
309 277
             fi
310 278
         fi