##// END OF EJS Templates
add `-a` to easy_install command in libedit warning...
MinRK -
Show More
@@ -1,107 +1,107 b''
1 1 # -*- coding: utf-8 -*-
2 2 """ Imports and provides the 'correct' version of readline for the platform.
3 3
4 4 Readline is used throughout IPython as::
5 5
6 6 import IPython.utils.rlineimpl as readline
7 7
8 8 In addition to normal readline stuff, this module provides have_readline
9 9 boolean and _outputfile variable used in IPython.utils.
10 10 """
11 11
12 12 import sys
13 13 import warnings
14 14
15 15 if sys.platform == 'darwin':
16 16 # dirty trick, to skip the system readline, because pip-installed readline
17 17 # will never be found on OSX, since lib-dynload always comes ahead of site-packages
18 18 from distutils import sysconfig
19 19 lib_dynload = sysconfig.get_config_var('DESTSHARED')
20 20 del sysconfig
21 21 try:
22 22 dynload_idx = sys.path.index(lib_dynload)
23 23 except ValueError:
24 24 dynload_idx = None
25 25 else:
26 26 sys.path.pop(dynload_idx)
27 27 try:
28 28 from readline import *
29 29 import readline as _rl
30 30 have_readline = True
31 31 except ImportError:
32 32 try:
33 33 from pyreadline import *
34 34 import pyreadline as _rl
35 35 have_readline = True
36 36 except ImportError:
37 37 have_readline = False
38 38
39 39 if sys.platform == 'darwin':
40 40 # dirty trick, part II:
41 41 if dynload_idx is not None:
42 42 # restore path
43 43 sys.path.insert(dynload_idx, lib_dynload)
44 44 if not have_readline:
45 45 # *only* have system readline, try import again
46 46 try:
47 47 from readline import *
48 48 import readline as _rl
49 49 have_readline = True
50 50 except ImportError:
51 51 have_readline = False
52 52 else:
53 53 # if we want to warn about EPD / Fink having bad readline
54 54 # we would do it here
55 55 pass
56 56 # cleanup dirty trick vars
57 57 del dynload_idx, lib_dynload
58 58
59 59 if (sys.platform == 'win32' or sys.platform == 'cli') and have_readline:
60 60 try:
61 61 _outputfile=_rl.GetOutputFile()
62 62 except AttributeError:
63 63 warnings.warn("Failed GetOutputFile")
64 64 have_readline = False
65 65
66 66 # Test to see if libedit is being used instead of GNU readline.
67 67 # Thanks to Boyd Waters for the original patch.
68 68 uses_libedit = False
69 69
70 70 if have_readline:
71 71 # Official Python docs state that 'libedit' is in the docstring for libedit readline:
72 72 uses_libedit = _rl.__doc__ and 'libedit' in _rl.__doc__
73 73 # Note that many non-System Pythons also do not use proper readline,
74 74 # but do not report libedit at all, nor are they linked dynamically against libedit.
75 75 # known culprits of this include: EPD, Fink
76 76 # There is not much we can do to detect this, until we find a specific failure
77 77 # case, rather than relying on the readline module to self-identify as broken.
78 78
79 79 if uses_libedit and sys.platform == 'darwin':
80 80 _rl.parse_and_bind("bind ^I rl_complete")
81 81 warnings.warn('\n'.join(['', "*"*78,
82 82 "libedit detected - readline will not be well behaved, including but not limited to:",
83 83 " * crashes on tab completion",
84 84 " * incorrect history navigation",
85 85 " * corrupting long-lines",
86 86 " * failure to wrap or indent lines properly",
87 87 "It is highly recommended that you install readline, which is easy_installable:",
88 " easy_install readline",
88 " easy_install -a readline",
89 89 "Note that `pip install readline` generally DOES NOT WORK, because",
90 90 "it installs to site-packages, which come *after* lib-dynload in sys.path,",
91 "where readline is located. It must be `easy_install readline`, or to a custom",
91 "where readline is located. It must be `easy_install -a readline`, or to a custom",
92 92 "location on your PYTHONPATH (even --user comes after lib-dyload).",
93 93 "*"*78]),
94 94 RuntimeWarning)
95 95
96 96 # the clear_history() function was only introduced in Python 2.4 and is
97 97 # actually optional in the readline API, so we must explicitly check for its
98 98 # existence. Some known platforms actually don't have it. This thread:
99 99 # http://mail.python.org/pipermail/python-dev/2003-August/037845.html
100 100 # has the original discussion.
101 101
102 102 if have_readline:
103 103 try:
104 104 _rl.clear_history
105 105 except AttributeError:
106 106 def clear_history(): pass
107 107 _rl.clear_history = clear_history
General Comments 0
You need to be logged in to leave comments. Login now