From 949c56885278ec68ca1ec994230e7033d04ff68c Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 5 Mar 2016 20:03:06 +0100 Subject: [PATCH] Pin requests>=2.4.1 and remove weird version check --- setup.py | 10 ++++++++-- vdirsyncer/utils/http.py | 25 ------------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/setup.py b/setup.py index 9711b02..54f2256 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,14 @@ requirements = [ 'click>=5.0', 'click-log>=0.1.3', 'click-threading>=0.1.2', - # https://github.com/kennethreitz/requests/issues/2930 - 'requests >=2.0.1, !=2.9.0', + # !=2.9.0: https://github.com/kennethreitz/requests/issues/2930 + # >=2.4.1: https://github.com/shazow/urllib3/pull/444 + # + # Without the above pull request, `verify=False` also disables fingerprint + # validation. This is *not* what we want, and it's not possible to replicate + # vdirsyncer's current behavior (verifying fingerprints without verifying + # against CAs) with older versions of urllib3. + 'requests >=2.4.1, !=2.9.0', 'lxml >=3.1' + ( # See https://github.com/untitaker/vdirsyncer/issues/298 # We pin some LXML version that is known to work with PyPy diff --git a/vdirsyncer/utils/http.py b/vdirsyncer/utils/http.py index 6b1fb2f..85f8c8f 100644 --- a/vdirsyncer/utils/http.py +++ b/vdirsyncer/utils/http.py @@ -8,28 +8,6 @@ from .. import exceptions, log logger = log.get(__name__) -def _verify_fingerprint_works(): - try: - from pkg_resources import parse_version as ver - - return ver(requests.__version__) >= ver('2.4.1') - except Exception: - return False - -# https://github.com/shazow/urllib3/pull/444 -# -# Without the above pull request, `verify=False` also disables fingerprint -# validation. This is *not* what we want, and it's not possible to replicate -# vdirsyncer's current behavior (verifying fingerprints without verifying -# against CAs) with older versions of urllib3. -# -# We check this here instead of setup.py, because: -# - Python's packaging stuff doesn't check installed versions. -# - The people who don't use `verify_fingerprint` wouldn't care. -VERIFY_FINGERPRINT_WORKS = _verify_fingerprint_works() -del _verify_fingerprint_works - - def _install_fingerprint_adapter(session, fingerprint): prefix = 'https://' try: @@ -65,9 +43,6 @@ def request(method, url, session=None, latin1_fallback=True, session = requests.Session() if verify_fingerprint is not None: - if not VERIFY_FINGERPRINT_WORKS: - raise RuntimeError('`verify_fingerprint` can only be used with ' - 'requests versions >= 2.4.1') _install_fingerprint_adapter(session, verify_fingerprint) func = session.request