jenkins-bot has submitted this change and it was merged.
Change subject: Fix httplib2 dependency check ......................................................................
Fix httplib2 dependency check
- Move dependency check from threadedhttp.py to http.py and revise it removing the dependency on setuptools for running pywikibot (it is still required to use setup.py) - Add httplib2 version checks, and display the httplib2 __file__ to assist the user identify why they have the wrong version.
Bug: 66618 Change-Id: I66c9a42f80710dec78b6e2b25ccb7b4b949c5740 --- M README-conversion.txt M pwb.py M pywikibot/comms/http.py M pywikibot/comms/threadedhttp.py 4 files changed, 26 insertions(+), 14 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/README-conversion.txt b/README-conversion.txt index e229ab0..24d62f4 100644 --- a/README-conversion.txt +++ b/README-conversion.txt @@ -48,10 +48,9 @@ so that these dependencies will be loaded automatically when the package is installed, and users won't need to worry about this...]
-To run pywikibot, you will need the httplib2, simplejson, and setuptools +To run pywikibot, you will need the httplib2 and simplejson: packages-- * httplib2 : http://code.google.com/p/httplib2/ -* setuptools : http://pypi.python.org/pypi/setuptools/ * simplejson : http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.7.1/docs/index.html
or, if you already have setuptools installed, just execute diff --git a/pwb.py b/pwb.py index 2fba1d3..a375826 100644 --- a/pwb.py +++ b/pwb.py @@ -108,7 +108,17 @@ import httplib2 except ImportError as e: print("ImportError: %s" % e) - print("Did you clone without --recursive? Try running 'git submodule update --init'.") + print("Python module httplib2 >= 0.6.0 is required.") + print("Did you clone without --recursive?" + "Try running 'git submodule update --init'.") + sys.exit(1) + +from distutils.version import StrictVersion +if StrictVersion(httplib2.__version__) < StrictVersion("0.6.0"): + print("Python module httplib2 (%s) needs to be 0.6.0 or greater." % + httplib2.__file__) + print("Did you clone without --recursive?" + "Try running 'git submodule update --init'.") sys.exit(1)
if "PYWIKIBOT2_DIR" not in os.environ: diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index affc571..14a55ac 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -27,6 +27,19 @@ import atexit import time
+# Verify that a working httplib2 is present. +try: + import httplib2 +except ImportError: + print("Error: Python module httplib2 >= 0.6.0 is required.") + sys.exit(1) + +from distutils.version import StrictVersion +if StrictVersion(httplib2.__version__) < StrictVersion("0.6.0"): + print("Error: Python module httplib2 (%s) is not 0.6.0 or greater." % + httplib2.__file__) + sys.exit(1) + if sys.version_info[0] == 2: from httplib2 import SSLHandshakeError import Queue diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py index 5dd0840..0f04f5e 100644 --- a/pywikibot/comms/threadedhttp.py +++ b/pywikibot/comms/threadedhttp.py @@ -42,17 +42,7 @@ _logger = "comm.threadedhttp"
-# easy_install safeguarded dependencies -try: - import httplib2 -except ImportError: - try: - import pkg_resources - pkg_resources.require("httplib2") - except ImportError: - pywikibot.error( - u"Error: You need the python module httplib2 to use this module") - sys.exit(1) +import httplib2
class ConnectionPool(object):
pywikibot-commits@lists.wikimedia.org