Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
add dirty trick for readline import on OSX #937
also made the libedit warning extremely loud, so people don't miss it.
We still get reports of people never having noticed the warning, and getting confused when readline is broken on OSX.
The libedit test is also simplified to just check
The reason for the dirty trick
pip installs to site-packages by default, but site-packages dirs always come after lib-dynload (and extras, etc.), which is where the system readline is installed.
That means that a non-setuptools install (pip or setup.py install) cannot override any package that ships with OSX, including:
without installing to a non-standard path (not even user site-packages via
Note that this path issue not unique to OSX - lib-dynload, and patform packages always come before site-packages, including
The method for the dirty trick
This doesn't solve everything
It has also come to my attention that EPD and Fink Pythons both ship with broken readline (logical for EPD, given readline's license). However, neither of these report as being anything other than GNU readline, so we can't detect that they are broken.
It's possible that we could print a warning if we detect that we are in EPD and we get to step 3 without readline, but if EPD's readline ever does work, then that message would be misleading, and we would have no real way to know that the issue has been fixed.
The answer remains, in all cases (except for possibly Python.org Python and macports, only because they are untested), that the first command OSX Python users should ever do is
Other than the minor edits above, I have nothing against the approach. We should probably ping Enthought to ask them to make their readline identifiable in some manner though, I'm sure they could just add a flag to their module to allow us to recognize it.
I haven't run the code myself, but given your OSX expertise and how much you've dealt with this issue, I'm OK if you want to merge once the above tiny things are fixed. Though if you want a second pair of OSX-specific eyes, that's OK too.
I do worry about mucking with the path, but I was helping someone out today, explaining why pip doesn't work, and they asked if I could just instruct Python to ignore the system one, allowing the site-packages to be searched for readline, and I realized it actually is possible. I tested it, and it certainly does work - pip-installed readline will be found by IPython, at least with System Python and EPD on my machine.
I honestly don't know why EPD and/or fink readline are broken - we should ask Ilan, or someone. Just this week, I have had people with EPD at py4science and Fink (in #915) report weird readline behavior (not the same), and both found that their respective weirdnesses were resolved by