##// END OF EJS Templates
remove no-longer-necessary dirty hack for readline on OS X...
MinRK -
Show More
@@ -12,51 +12,24 b' boolean and _outputfile variable used in IPython.utils.'
12 import sys
12 import sys
13 import warnings
13 import warnings
14
14
15 if sys.platform == 'darwin':
15 _rlmod_names = ['gnureadline', 'readline']
16 # dirty trick, to skip the system readline, because pip-installed readline
16 if sys.platform == 'win32' or sys.platform == 'cli':
17 # will never be found on OSX, since lib-dynload always comes ahead of site-packages
17 _rlmod_names.append('pyreadline')
18 from distutils import sysconfig
18
19 lib_dynload = sysconfig.get_config_var('DESTSHARED')
19 have_readline = False
20 del sysconfig
20 for _rlmod_name in _rlmod_names:
21 try:
21 try:
22 dynload_idx = sys.path.index(lib_dynload)
22 # import readline as _rl
23 except ValueError:
23 _rl = __import__(_rlmod_name)
24 dynload_idx = None
24 # from readline import *
25 globals().update({k:v for k,v in _rl.__dict__.items() if not k.startswith('_')})
26 except ImportError:
27 pass
25 else:
28 else:
26 sys.path.pop(dynload_idx)
27 try:
28 from readline import *
29 import readline as _rl
30 have_readline = True
31 except ImportError:
32 try:
33 from pyreadline import *
34 import pyreadline as _rl
35 have_readline = True
29 have_readline = True
36 except ImportError:
30 break
37 have_readline = False
38
39 if sys.platform == 'darwin':
40 # dirty trick, part II:
41 if dynload_idx is not None:
42 # restore path
43 sys.path.insert(dynload_idx, lib_dynload)
44 if not have_readline:
45 # *only* have system readline, try import again
46 try:
47 from readline import *
48 import readline as _rl
49 have_readline = True
50 except ImportError:
51 have_readline = False
52 else:
53 # if we want to warn about EPD / Fink having bad readline
54 # we would do it here
55 pass
56 # cleanup dirty trick vars
57 del dynload_idx, lib_dynload
58
31
59 if (sys.platform == 'win32' or sys.platform == 'cli') and have_readline:
32 if _rlmod_name == 'pyreadline':
60 try:
33 try:
61 _outputfile=_rl.GetOutputFile()
34 _outputfile=_rl.GetOutputFile()
62 except AttributeError:
35 except AttributeError:
@@ -84,12 +57,8 b" if uses_libedit and sys.platform == 'darwin':"
84 " * incorrect history navigation",
57 " * incorrect history navigation",
85 " * corrupting long-lines",
58 " * corrupting long-lines",
86 " * failure to wrap or indent lines properly",
59 " * failure to wrap or indent lines properly",
87 "It is highly recommended that you install readline, which is easy_installable:",
60 "It is highly recommended that you install gnureadline, which is installable with:",
88 " easy_install -a readline",
61 " pip install gnureadline",
89 "Note that `pip install readline` generally DOES NOT WORK, because",
90 "it installs to site-packages, which come *after* lib-dynload in sys.path,",
91 "where readline is located. It must be `easy_install -a readline`, or to a custom",
92 "location on your PYTHONPATH (even --user comes after lib-dyload).",
93 "*"*78]),
62 "*"*78]),
94 RuntimeWarning)
63 RuntimeWarning)
95
64
General Comments 0
You need to be logged in to leave comments. Login now