Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#31216 closed enhancement (fixed)

build python against libedit instead of readline

Reported by: jmroot (Joshua Root) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version:
Keywords: haspatch Cc: jyrkiwahlstedt, MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), erickt@…, cdeil (Christoph Deil), spork-macports@…
Port: python25 python26 python27 python31 python32

Description

GNU readline is licensed under GPL-3+, whereas libedit is BSD. Using libedit will therefore make the binary distribution situation easier. This is actually the default configuration on OS X for upstream anyway, as Apple's libreadline is a link to libedit.

Should just be a matter of patching the configure script to change -lreadline to -ledit and readline/readline.h to editline/readline.h.

Attachments (1)

python-libedit.diff (38.5 KB) - added by jmroot (Joshua Root) 9 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 9 years ago by ned-deily (Ned Deily)

Note that there was feature code added to Python to support using libedit instead of readline. That feature code was added to python26, python27, and python32 but not other versions; see http://bugs.python.org/issue6877

comment:2 Changed 9 years ago by jmroot (Joshua Root)

Cc: roel@… removed
Port: python24 removed

Turns out the incompatibility is fixed in the version of libedit we now install, which means it actually crashes unless we revert the upstream python patch.

Also, readline is in a separate port for python24, so this is not a big deal for that version.

Changed 9 years ago by jmroot (Joshua Root)

Attachment: python-libedit.diff added

comment:3 Changed 9 years ago by jmroot (Joshua Root)

Keywords: haspatch added

comment:4 Changed 9 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: newclosed

comment:5 Changed 9 years ago by ned-deily (Ned Deily)

Note that linking with libedit instead of GNU readline introduces potential user incompatibilities. As noted in the docs for the Python readline module , the configuration file commands for libedit are different than readline. For example, if you have a PYTHONSTARTUP file set up to enable tab completion in the Python interactive interpreter, the directives have to be changed or be conditional based on which library is used or directives have to be added to .editrc (the libedit defaults file). Here's an example:

    import rlcompleter
    if 'libedit' in readline.__doc__:
        readline.parse_and_bind("bind ^I rl_complete")
    else:  # GNU readline format
        readline.parse_and_bind("tab: complete")

Also, py27-ipython and py32-ipython (at least) complain when running with a python linked with libedit:

/macports/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/utils/rlineimpl.py:96:
RuntimeWarning: Leopard libedit detected - readline will not be well behaved including some crashes on tab completion, and
incorrect history navigation. It is highly recommended that you install readline, which is easy_installable with: 'easy_install readline'
  RuntimeWarning)

comment:6 Changed 9 years ago by cdeil (Christoph Deil)

I have the same problem with ipython. Actually the ipython prompt is broken:

$ /opt/local/bin/ipython-2.6 
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/IPython/utils/rlineimpl.py:96: RuntimeWarning: Leopard libedit detected - readline will not be well behaved including some crashes on tab completion, and incorrect history navigation. It is highly recommended that you install readline, which is easy_installable with: 'easy_install readline'
  RuntimeWarning)
Python 2.6.7 (r267:88850, Nov  8 2011, 12:13:06) 
Type "copyright", "credits" or "license" for more information.

IPython 0.11 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
34In[1;3[0;34][0^D

Same warning and broken prompt whether I use ipython from MacPorts of the git master.

Any workaround / fix from this from the Macports or Ipython side? Should I file a new ticket?

comment:7 Changed 9 years ago by cdeil (Christoph Deil)

Cc: Deil.Christoph@… added

Cc Me!

comment:8 Changed 9 years ago by spork-macports@…

Cc: spork-macports@… added

Cc Me!

comment:9 Changed 9 years ago by jmroot (Joshua Root)

See #31938 regarding ipython. Basically you can just install the appropriate py*-readline port.

Note: See TracTickets for help on using tickets.