From f024551395657baf6af90091d0ff0e699a7632ed Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Apr 2021 15:37:50 +0200 Subject: [PATCH] Use Python 3 for httpbin installation under Ubuntu Trusty Trying to use Python 2 under Trusty is hopeless, as pythonhosted.org has already started dropping support for non-SNI clients and will drop it completely soon, see https://status.python.org/incidents/hzmjhqsdjqgb and https://github.com/pypa/pypi-support/issues/978, and SNI is not available in the system Python 2 version (2.7.6, which is less than 2.7.9 in which it was added). Note that we still can't use Python 3 everywhere as long as we have macOS 11 builds as it's not available there. --- build/tools/httpbin.sh | 47 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/build/tools/httpbin.sh b/build/tools/httpbin.sh index b4b04e32f9..388d673e43 100644 --- a/build/tools/httpbin.sh +++ b/build/tools/httpbin.sh @@ -17,44 +17,45 @@ httpbin_launch() { case "$dist_codename" in trusty) - # Current decorator (>= 5) is incompatible with Python 2 which we - # still use in some builds, so explicitly use a version which - # is known to work. Just specifying "decorator==4.4.2" doesn't work - # neither for some reason ("no matching distribution found"), so - # use an explicit URL. - pip_decorator_arg='https://files.pythonhosted.org/packages/ed/1b/72a1821152d07cf1d8b6fce298aeb06a7eb90f4d6d41acec9861e7cc6df0/decorator-4.4.2-py2.py3-none-any.whl' + # Python 2.7.6 is too old to support SNI and can't be used. + PY3=3 - # We need to disable SSL certificate checking under Trusty because - # Python version there is too old to support SNI. - pip_options='--trusted-host files.pythonhosted.org' + # Current decorator (>= 5) is incompatible with Python 3.4 used + # here, so explicitly use a version which is known to work. + pip_decorator_arg='decorator==4.4.2' ;; macOS) + # We use Python 2 under macOS 10.11 which doesn't have Python 3, + # and decorator >= 5 is incompatible with it too. pip_decorator_arg='decorator==4.4.2' ;; *) # Elsewhere just use Python 3. PY3=3 - - # Ensure that we have at least some version of pip. - if ! python3 -m pip; then - sudo apt-get -q -o=Dpkg::Use-Pty=0 install python3-pip - fi - - # Running pip install fails with weird errors out of the box when - # using old pip version because it attempts to use python rather - # than python3, so upgrade it to fix this. - # - # However don't upgrade to a version which is too new because then - # it may not support Python version that we actually have. - python3 -m pip install --user --upgrade pip==20.0.1 ;; esac + if [ "$PY3" = 3 ]; then + # Ensure that we have at least some version of pip. + if ! python3 -m pip; then + sudo apt-get -q -o=Dpkg::Use-Pty=0 install python3-pip + fi + + # Running pip install fails with weird errors out of the box when + # using old pip version because it attempts to use python rather + # than python3, so upgrade it to fix this. + # + # However don't upgrade to a version which is too new because then + # it may not support Python version that we actually have (this one + # still works with 3.4, 20.0.1 is the last one to support 3.5). + python3 -m pip install --user --upgrade pip==19.1.1 + fi + echo "Installing using `python$PY3 -m pip --version`" - python$PY3 -m pip install $pip_decorator_arg httpbin --user $pip_options + python$PY3 -m pip install $pip_decorator_arg httpbin --user python$PY3 -m httpbin.core 2>&1 >httpbin.log & WX_TEST_WEBREQUEST_URL="http://localhost:5000"