Fix the setuptools distutils overriding issue (#28393)

* Fix the distutil install issue

* Try to move setuptools install forward

* Try pin the distribution tools

* Enforce local distutil

* Fix script order of definition

* Add comment

* Try to fix the setuptool monkey patch

* Clean-up imports for commands.py

* Pin 59.6.0 instead of 59.7.0 (incomplete release)
pull/28368/head^2
Lidi Zheng 3 years ago committed by GitHub
parent ecd968391a
commit 83e7cb24fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      setup.py
  2. 11
      src/python/grpcio/commands.py
  3. 30
      tools/run_tests/helper_scripts/build_python.sh

@ -13,8 +13,8 @@
# limitations under the License.
"""A setup module for the GRPC Python package."""
# setuptools need to be imported before distutils. Otherwise it might lead to
# undesirable behaviors or errors.
# NOTE(https://github.com/grpc/grpc/issues/24028): allow setuptools to monkey
# patch distutils
import setuptools # isort:skip
# Monkey Patch the unix compiler to accept ASM

@ -13,26 +13,21 @@
# limitations under the License.
"""Provides distutils command classes for the GRPC Python setup process."""
from __future__ import print_function
# NOTE(https://github.com/grpc/grpc/issues/24028): allow setuptools to monkey
# patch distutils
import setuptools # isort:skip
import distutils
import glob
import os
import os.path
import platform
import re
import shutil
import subprocess
import sys
import sysconfig
import traceback
import setuptools
from setuptools.command import build_ext
from setuptools.command import build_py
from setuptools.command import easy_install
from setuptools.command import install
from setuptools.command import test
import support
PYTHON_STEM = os.path.dirname(os.path.abspath(__file__))

@ -150,10 +150,21 @@ else
VENV_PYTHON=$(script_realpath "$VENV/$VENV_RELATIVE_PYTHON")
fi
# See https://github.com/grpc/grpc/issues/14815 for more context. We cannot rely
# on pip to upgrade itself because if pip is too old, it may not have the required
# TLS version to run `pip install`.
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | $VENV_PYTHON
# On library/version/platforms combo that do not have a binary
# published, we may end up building a dependency from source. In that
# case, several of our build environment variables may disrupt the
# third-party build process. This function pipes through only the
# minimal environment necessary.
pip_install() {
/usr/bin/env -i PATH="$PATH" "$VENV_PYTHON" -m pip install "$@"
}
# Pin setuptools to < 60.0.0 to restore the distutil installation, see:
# https://github.com/pypa/setuptools/pull/2896
export SETUPTOOLS_USE_DISTUTILS=stdlib
pip_install --upgrade pip==21.3.1
pip_install --upgrade setuptools==59.6.0
# pip-installs the directory specified. Used because on MSYS the vanilla Windows
# Python gets confused when parsing paths.
@ -165,15 +176,6 @@ pip_install_dir() {
cd "$PWD"
}
# On library/version/platforms combo that do not have a binary
# published, we may end up building a dependency from source. In that
# case, several of our build environment variables may disrupt the
# third-party build process. This function pipes through only the
# minimal environment necessary.
pip_install() {
/usr/bin/env -i PATH="$PATH" "$VENV_PYTHON" -m pip install "$@"
}
case "$VENV" in
*py36_gevent*)
# TODO(https://github.com/grpc/grpc/issues/15411) unpin this
@ -185,8 +187,6 @@ case "$VENV" in
esac
pip_install --upgrade setuptools==44.1.1
pip_install --upgrade pip==19.3.1
pip_install --upgrade cython
pip_install --upgrade six protobuf

Loading…
Cancel
Save