Skip to content
This repository

update tornado dependency to 2.1 #821

Merged
merged 2 commits into from over 2 years ago

2 participants

Min RK Fernando Perez
Min RK
Owner

The notebook server will no longer try to launch with 2.0.

Test imports and install doc updated to match.

The only reason I didn't push directly to master is that 2.0 will technically still work with some browser versions.

But I don't think there's any need to support 2.0.

Min RK update tornado dependency to 2.1
The notebook server will no longer try to launch with 2.0.

Test imports and install doc updated to match.
d3ee41f
Fernando Perez

My only thought here is that I wonder if it wouldn't be nicer to keep using test_for(), just to keep the code in iptest more regular, and simply teach test_for how to check something other than __version__.

I leave it as a suggestion for you, but I don't feel super strongly about it, so I'll leave the final choice up to you.

Owner

__version__ is so common, that I think special casing the exceptions makes sense. We might want to make some changes, since string comparison is risky, given that the next version of zmq is most likely to be 2.1.10, which will fail our test for 2.1.4.

Owner

I guess I'm not sure what you mean by your reply: do you want to do the special-casing inside test_for or in the iptest file itself? We certainly need to handle the other-than-__version__ cases somewhere, I was just thinking we might be better off putting all that inside test_for, that's all.

Owner

I was simultaneously saying we don't need to change it to support tornado, but we do still need to change it to support two-digit sub-versions. I'll make a quick tweak so that check_for uses importstring.import_item, and make the zmq versioncheck fix as well.

Owner

sounds good, thanks!

Fernando Perez
Owner

Other than the minor comment above, +1 from me. Merge away once you've decided what to do there.

Thanks!

Min RK allow more processing in test_for
* test_for uses import_item, instead of __import__
* test_for now allows a callback, for processing the result of import_item prior to comparison with min_zmq
* callback is only called when min_zmq is defined
* callback's default is to just return mod.__version__
* use this to check tornado version, and zmq as a version tuple
* fix pexpect check to use external.pexpect
e7616f6
Min RK
Owner

test_for updated with a callback for processing, so it can do more sophisticated things. the zmq check has been updated to use it, and the pexpect check was also wrong (checked for pexpect instead of external.pexpect).

Fernando Perez
Owner

great, thanks! Merging now.

Fernando Perez fperez merged commit 2ecf55e into from September 23, 2011
Fernando Perez fperez closed this September 23, 2011
Fernando Perez fperez referenced this pull request from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Sep 23, 2011
Min RK update tornado dependency to 2.1
The notebook server will no longer try to launch with 2.0.

Test imports and install doc updated to match.
d3ee41f
Min RK allow more processing in test_for
* test_for uses import_item, instead of __import__
* test_for now allows a callback, for processing the result of import_item prior to comparison with min_zmq
* callback is only called when min_zmq is defined
* callback's default is to just return mod.__version__
* use this to check tornado version, and zmq as a version tuple
* fix pexpect check to use external.pexpect
e7616f6
This page is out of date. Refresh to see the latest.
12  IPython/frontend/html/notebook/__init__.py
... ...
@@ -0,0 +1,12 @@
  1
+"""The IPython HTML Notebook"""
  2
+
  3
+# check for tornado 2.1.0
  4
+msg = "The IPython Notebook requires tornado >= 2.1.0"
  5
+try:
  6
+    import tornado
  7
+except ImportError:
  8
+    raise ImportError(msg)
  9
+else:
  10
+    if tornado.version_info < (2,1,0):
  11
+        raise ImportError(msg+", but you have %s"%tornado.version)
  12
+del msg
52  IPython/testing/iptest.py
@@ -45,6 +45,7 @@
45 45
 from nose.core import TestProgram
46 46
 
47 47
 # Our own imports
  48
+from IPython.utils.importstring import import_item
48 49
 from IPython.utils.path import get_ipython_module_path
49 50
 from IPython.utils.process import find_cmd, pycmd2argv
50 51
 from IPython.utils.sysinfo import sys_info
@@ -81,18 +82,38 @@
81 82
 #-----------------------------------------------------------------------------
82 83
 # Logic for skipping doctests
83 84
 #-----------------------------------------------------------------------------
  85
+def extract_version(mod):
  86
+    return mod.__version__
84 87
 
85  
-def test_for(mod, min_version=None):
86  
-    """Test to see if mod is importable."""
  88
+def test_for(item, min_version=None, callback=extract_version):
  89
+    """Test to see if item is importable, and optionally check against a minimum
  90
+    version.
  91
+    
  92
+    If min_version is given, the default behavior is to check against the
  93
+    `__version__` attribute of the item, but specifying `callback` allows you to
  94
+    extract the value you are interested in. e.g::
  95
+    
  96
+        In [1]: import sys
  97
+        
  98
+        In [2]: from IPython.testing.iptest import test_for
  99
+        
  100
+        In [3]: test_for('sys', (2,6), callback=lambda sys: sys.version_info)
  101
+        Out[3]: True
  102
+    
  103
+    """
87 104
     try:
88  
-        __import__(mod)
  105
+        check = import_item(item)
89 106
     except (ImportError, RuntimeError):
90  
-        # GTK reports Runtime error if it can't be initialized even if  it's
  107
+        # GTK reports Runtime error if it can't be initialized even if it's
91 108
         # importable.
92 109
         return False
93 110
     else:
94 111
         if min_version:
95  
-            return sys.modules[mod].__version__ >= min_version
  112
+            if callback:
  113
+                # extra processing step to get version to compare
  114
+                check = callback(check)
  115
+            
  116
+            return check >= min_version
96 117
         else:
97 118
             return True
98 119
 
@@ -102,16 +123,27 @@ def test_for(mod, min_version=None):
102 123
 
103 124
 have['curses'] = test_for('_curses')
104 125
 have['matplotlib'] = test_for('matplotlib')
105  
-have['pexpect'] = test_for('pexpect')
  126
+have['pexpect'] = test_for('IPython.external.pexpect')
106 127
 have['pymongo'] = test_for('pymongo')
107 128
 have['wx'] = test_for('wx')
108 129
 have['wx.aui'] = test_for('wx.aui')
  130
+have['qt'] = test_for('IPython.external.qt')
  131
+
  132
+have['tornado'] = test_for('tornado.version_info', (2,1,0), callback=None)
  133
+
109 134
 if os.name == 'nt':
110  
-    have['zmq'] = test_for('zmq', '2.1.7')
  135
+    min_zmq = (2,1,7)
111 136
 else:
112  
-    have['zmq'] = test_for('zmq', '2.1.4')
113  
-have['qt'] = test_for('IPython.external.qt')
114  
-have['tornado'] = test_for('tornado')
  137
+    min_zmq = (2,1,4)
  138
+
  139
+def version_tuple(mod):
  140
+    "turn '2.1.9' into (2,1,9), and '2.1dev' into (2,1,999)"
  141
+    # turn 'dev' into 999, because Python3 rejects str-int comparisons
  142
+    vs = mod.__version__.replace('dev', '.999')
  143
+    tup = tuple([int(v) for v in vs.split('.') ])
  144
+    return tup
  145
+
  146
+have['zmq'] = test_for('zmq', min_zmq, version_tuple)
115 147
 
116 148
 #-----------------------------------------------------------------------------
117 149
 # Functions and classes
10  docs/source/install/install.txt
@@ -336,6 +336,7 @@ pygments
336 336
 The syntax-highlighting in ``ipython qtconsole`` is done with the pygments_
337 337
 project, which is easy_install-able.
338 338
 
  339
+.. _installnotebook:
339 340
 
340 341
 Dependencies for the IPython HTML notebook
341 342
 ==========================================
@@ -352,14 +353,11 @@ the HTML notebook requires ZeroMQ and PyZMQ.
352 353
 Tornado
353 354
 -------
354 355
 
355  
-The IPython notebook uses the Tornado_ project for its HTTP server.  As of this
356  
-writing, we require a development version from github, as version 2.0 is *not
357  
-sufficient*.  You can either clone their git repository yourself and install it
358  
-manually, or install directly from github with::
  356
+The IPython notebook uses the Tornado_ project for its HTTP server.  Tornado 2.1
  357
+is required, in order to support current versions of browsers, due to an update
  358
+to the websocket protocol.
359 359
 
360  
-    easy_install https://github.com/facebook/tornado/tarball/master
361 360
 
362  
-    
363 361
 MathJax
364 362
 -------
365 363
 
4  docs/source/interactive/htmlnotebook.txt
@@ -4,6 +4,10 @@
4 4
 An HTML Notebook IPython
5 5
 =========================
6 6
 
  7
+.. seealso::
  8
+
  9
+    :ref:`Installation requirements <installnotebook>` for the Notebook.
  10
+
7 11
 The IPython Notebook consists of two related components:
8 12
 
9 13
 * An JSON based Notebook document format for recording and distributing
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.