Browse Source

Override pip and virtualenv installation for macOS. (#7704)

This commit cleans up our environment setup for macOS builds.

-  Always use `python -m {pip | virtualenv}` form of commands.
-  Only upgrade in-place, and never use `--ignore-installed`.
-  Use latest tox on macos, and test 3.6 on macos presubmit.

These changes ensure that multibuilder won't break the system-installed Python on the Kokoro macOS builder, and thus won't resolve the ancient system version. For Tox, make sure we test with Python 3.6 (the version of Python in current macOS).
David L. Jones 5 years ago
parent
commit
0f9ae07fe0
3 changed files with 22 additions and 3 deletions
  1. 1 1
      kokoro/macos/prepare_build_macos_rc
  2. 19 0
      kokoro/release/python/macos/config.sh
  3. 2 2
      tests.sh

+ 1 - 1
kokoro/macos/prepare_build_macos_rc

@@ -66,7 +66,7 @@ fi
 # Install Tox
 # Install Tox
 
 
 if [[ "${KOKORO_INSTALL_TOX:-}" == "yes" ]] ; then
 if [[ "${KOKORO_INSTALL_TOX:-}" == "yes" ]] ; then
-  sudo pip install tox==2.4.1
+  sudo python3 -m pip install --upgrade pip tox
 fi
 fi
 
 
 ##
 ##

+ 19 - 0
kokoro/release/python/macos/config.sh

@@ -1,6 +1,25 @@
 # Define custom utilities
 # Define custom utilities
 # Test for OSX with [ -n "$IS_OSX" ]
 # Test for OSX with [ -n "$IS_OSX" ]
 
 
+function remove_travis_ve_pip {
+    # Removing the system virtualenv or pip can be very problematic for
+    # macOS on Kokoro, so just leave them be.
+    :;
+}
+
+function install_pip {
+    check_python
+    PIP_CMD="sudo $PYTHON_EXE -m pip${pip_args:+ $pip_args}"
+    $PIP_CMD install --upgrade pip
+}
+
+function install_virtualenv {
+    check_python
+    check_pip
+    $PIP_CMD install --upgrade virtualenv
+    VIRTUALENV_CMD="$PYTHON_EXE -m virtualenv"
+}
+
 function pre_build {
 function pre_build {
     # Any stuff that you need to do before you start building the wheels
     # Any stuff that you need to do before you start building the wheels
     # Runs in the root directory of this repository.
     # Runs in the root directory of this repository.

+ 2 - 2
tests.sh

@@ -314,7 +314,7 @@ build_python() {
   if [ $(uname -s) == "Linux" ]; then
   if [ $(uname -s) == "Linux" ]; then
     envlist=py\{27,33,34,35,36\}-python
     envlist=py\{27,33,34,35,36\}-python
   else
   else
-    envlist=py27-python
+    envlist=py\{27,36\}-python
   fi
   fi
   tox -e $envlist
   tox -e $envlist
   cd ..
   cd ..
@@ -364,7 +364,7 @@ build_python_cpp() {
   if [ $(uname -s) == "Linux" ]; then
   if [ $(uname -s) == "Linux" ]; then
     envlist=py\{27,33,34,35,36\}-cpp
     envlist=py\{27,33,34,35,36\}-cpp
   else
   else
-    envlist=py27-cpp
+    envlist=py\{27,36\}-cpp
   fi
   fi
   tox -e $envlist
   tox -e $envlist
   cd ..
   cd ..