Use python.org MacPython builds for Travis
MODIFY
.travis.yml
.travis.yml
@@ -4,6 +4,7 @@ script:
before_install:
- env
- openssl version
+ - python -c "import ssl; print(ssl.OPENSSL_VERSION)"
after_success:
- ./_travis/upload_coverage.sh
cache:
@@ -58,9 +59,6 @@ matrix:
- language: generic
os: osx
env: TOXENV=py37
- - language: generic
- os: osx
- env: TOXENV=py38
allow_failures:
- python: pypy-5.4
sudo: false

MODIFY
_travis/install.sh
_travis/install.sh
@@ -4,50 +4,23 @@ set -e
set -x
if [[ "$(uname -s)" == 'Darwin' ]]; then
- sw_vers
- brew update || brew update
- brew outdated openssl || brew upgrade openssl
- brew install openssl@1.1
-
- # install pyenv
- git clone --depth 1 https://github.com/yyuu/pyenv.git ~/.pyenv
- PYENV_ROOT="$HOME/.pyenv"
- PATH="$PYENV_ROOT/bin:$PATH"
- eval "$(pyenv init -)"
-
case "${TOXENV}" in
- py27)
- pyenv install 2.7.14
- pyenv global 2.7.14
- ;;
- py34)
- pyenv install 3.4.7
- pyenv global 3.4.7
- ;;
- py35)
- pyenv install 3.5.4
- pyenv global 3.5.4
- ;;
- py36)
- pyenv install 3.6.3
- pyenv global 3.6.3
- ;;
- py37)
- pyenv install 3.7-dev
- pyenv global 3.7-dev
- ;;
- py38)
- pyenv install 3.8-dev
- pyenv global 3.8-dev
- ;;
- pypy*)
- pyenv install "pypy-5.4.1"
- pyenv global "pypy-5.4.1"
- ;;
+ py27) MACPYTHON=2.7.15 ;;
+ py34) MACPYTHON=3.4.4 ;;
+ py35) MACPYTHON=3.5.4 ;;
+ py36) MACPYTHON=3.6.7 ;;
+ py37) MACPYTHON=3.7.1 ;;
esac
- pyenv rehash
- pip install -U setuptools
- pip install --user virtualenv
+
+ MINOR=$(echo $MACPYTHON | cut -d. -f1,2)
+
+ curl -Lo macpython.pkg https://www.python.org/ftp/python/${MACPYTHON}/python-${MACPYTHON}-macosx10.6.pkg
+ sudo installer -pkg macpython.pkg -target /
+ ls /Library/Frameworks/Python.framework/Versions/$MINOR/bin/
+ PYTHON_EXE=/Library/Frameworks/Python.framework/Versions/$MINOR/bin/python$MINOR
+ # The pip in older MacPython releases doesn't support a new enough TLS
+ curl https://bootstrap.pypa.io/get-pip.py | sudo $PYTHON_EXE
+ $PYTHON_EXE -m pip install virtualenv
else
pip install virtualenv
fi

MODIFY
_travis/run.sh
_travis/run.sh
set -e
set -x
-if [[ "$(uname -s)" == "Darwin" ]]; then
- # initialize our pyenv
- PYENV_ROOT="$HOME/.pyenv"
- PATH="$PYENV_ROOT/bin:$PATH"
- eval "$(pyenv init -)"
-
- # Use the good OpenSSL for PyOpenSSL. This also links it statically into
- # cryptography, which more accurately reflects the way the wheel is used.
- export CRYPTOGRAPHY_OSX_NO_LINK_FLAGS="1"
- export LDFLAGS="$(brew --prefix openssl@1.1)/lib/libcrypto.a $(brew --prefix openssl@1.1)/lib/libssl.a"
- export CFLAGS="-I$(brew --prefix openssl@1.1)/include"
+if [[ "$(uname -s)" == "Darwin" && "$TOXENV" == "py27" ]]; then
+ export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin":$PATH
fi
tox

MODIFY
test/__init__.py
test/__init__.py
@@ -4,6 +4,7 @@ import errno
import functools
import logging
import socket
+import ssl
import os
import pytest
@@ -85,6 +86,18 @@ def notSecureTransport(test):
return wrapper
+def notOpenSSL098(test):
+ """Skips this test for Python 3.4 and 3.5 macOS python.org distributions"""
+
+ @functools.wraps(test)
+ def wrapper(*args, **kwargs):
+ is_stdlib_ssl = not ssl_.IS_SECURETRANSPORT and not ssl_.IS_PYOPENSSL
+ if is_stdlib_ssl and ssl.OPENSSL_VERSION == "OpenSSL 0.9.8zh 14 Jan 2016":
+ pytest.xfail("{name} fails with OpenSSL 0.9.8zh".format(name=test.__name__))
+ return test(*args, **kwargs)
+ return wrapper
+
+
_requires_network_has_route = None

MODIFY
test/with_dummyserver/test_https.py
test/with_dummyserver/test_https.py
@@ -22,6 +22,7 @@ from dummyserver.server import (DEFAULT_CA, DEFAULT_CA_BAD, DEFAULT_CERTS,
from test import (
onlyPy279OrNewer,
notSecureTransport,
+ notOpenSSL098,
requires_network,
fails_on_travis_gce,
TARPIT_HOST,
@@ -197,6 +198,7 @@ class TestHTTPS(HTTPSDummyServerTestCase):
@onlyPy279OrNewer
@notSecureTransport # SecureTransport does not support cert directories
+ @notOpenSSL098 # OpenSSL 0.9.8 does not support cert directories
def test_ca_dir_verified(self):
https_pool = HTTPSConnectionPool(self.host, self.port,
cert_reqs='CERT_REQUIRED',

MODIFY
tox.ini
tox.ini
@@ -9,6 +9,7 @@ commands=
pip --version
python --version
python -c "import struct; print(struct.calcsize('P') * 8)"
+ python -m OpenSSL.debug
# Inspired from https://github.com/pyca/cryptography
# We use parallel mode and then combine here so that coverage.py will take
# the paths like .tox/pyXY/lib/pythonX.Y/site-packages/urllib3/__init__.py

Use python.org MacPython builds for Travis (#1485)