Package: rl
OverviewTheGNU Readline Libraryis the canonical implementation of command line
editing, tab completion, and history for console-based applications.
It is developed as part of Bash and available on virtually any platform.While Python ships with readline bindings in its standard library, they
only implement a subset of readline’s features, just enough to perform
identifier completion at the Python interpreter prompt.Therlpackage aims to provide full implementations of GNU Readline’sCustom CompleterandHistoryinterfaces.
It also contains high-level APIs to better organize the namespace and
shield applications from low-level verbosity.Package Contentsrl exports these components:completerInterface to the readline completer. Used to configure the completion
aspects of readline.completionInterface to the active readline completion. Used to interact
with readline when a completion is in progress.historyInterface to the readline history. Used to read and write history files
and to manipulate history entries.readlineThe readline bindings module. Contains everything known from the standard
library plus extensions specific to the rl package.  Thecompleter,completion, andhistoryinterfaces make use of this module, and you
should rarely need to interact with it directly.generatorA decorator turning any callable into acompletion entry functionthat
can be handed to readline.print_excA decorator printing exceptions to stderr. Useful when writing Python
completions and hooks, as exceptions occurring there are usually
swallowed by the in-between C code.DocumentationFor further details please refer to theAPI Documentation.Developmentrl development is hosted onGitHubwhere it also has anissue tracker.Installationrl requires Python 2.7 or higher. The installer builds GNU Readline 8.2
and a Python extension module.On Mac OS X make sure you have Xcode Tools installed. Open a Terminal
window and type:gcc --versionYou either see some output (good) or an installer window pops up. Click
the “Install” button to install the command line developer tools.
A more detailed tutorial is available from theMac Install Guide.On Linux and BSD systems you probably already have a C compiler, but you may
need to verify the development environment is complete.
For example, Ubuntu lacks the Python headers by default and Fedora is
missing some compiler configuration. Lastly, readline needs a termcap library
to link to.Ubuntu/Debian:sudo apt install build-essential
sudo apt install python3-dev
sudo apt install libncurses-devRedhat/Fedora:sudo dnf install gcc
sudo dnf install redhat-rpm-config
sudo dnf install ncurses-develThen type:pip install rlRelatedkmd.Kmdis an rl-enabled version ofcmd.Cmd.Changelog3.1 - 2022-10-31Include GNU Readline 8.2.
[stefan]Improve documentation and example code. Promote usinggeneratoras a
decorator.
[stefan]Document howdirectory_completion_hookinteracts with new hooks added
in version 3.0.
[stefan]Implement Python 3.6readline.set_auto_historyand the correspondinghistory.auto.
[stefan]Fall back to ncurses if termcap auto-detection fails. This at least produces
a linker error instead of silently borking the extension.
[stefan]Replace deprecatedpython setup.py testin tox.ini.
[stefan]Remove deprecatedtest_suitefrom setup.py.
[stefan]Remove setuptools frominstall_requires.
[stefan]Add a pyproject.toml file.
[stefan]Include tests in sdist but not in wheel.
[stefan]3.0 - 2019-03-20rl is now GPLv3 because it statically links to GNU Readline.
[stefan]Include GNU Readline 8.0.
[stefan]Support Python 3.6 os.PathLike objects for filenames.
[stefan]Handle new GIL checks in Python 3.6. SeePYTHONMALLOC.
[stefan]Addhistory.max_fileandhistory.append_file.
[stefan]Adddirectory_rewrite_hook,filename_rewrite_hook, andfilename_stat_hook.
[stefan]Catch up with bug fixes applied to the standard library readline module.
[stefan]Stop using 2to3.
[stefan]RemoveresetAPIs from the documentation. They override~/.inputrcand should only be used in tests.
[stefan]2.4 - 2012-10-05Update to Python 3.3 Unicode C-API.
[stefan]2.3 - 2012-07-18Implement history iterators in C instead of relying on
intermediate lists.
[stefan]Raise a more informative error when history slicing is attempted.
[stefan]2.2 - 2012-05-10Restore support for gcc < 4.2.
[stefan]Switch to a happier looking Sphinx theme.
[stefan]2.1 - 2012-04-27Force a static build if the RL_BUILD_STATIC_READLINE environment
variable is set.
[stefan]Include readline 6.2 patches in static builds.
[stefan]Suppress compiler warnings on more platforms.
[stefan]2.0.1 - 2011-10-06Fix a C compiler issue under Python 3 on Linux.
[stefan]2.0 - 2011-10-06Drop support for cmd.Cmd. You now must derive your command
interpreters fromkmd.Kmdto use rl features.
[stefan]Accept None as argument to file operations under Python 3.
[stefan]Switch to pretty Sphinx-based docs.
[stefan]1.16 - 2011-07-28Tilde-expand filenames inread_history_fileandwrite_history_file.
[stefan]1.15.2 - 2011-07-03Silence a second C compiler warning in functionget_y_or_n.
[stefan]1.15.1 - 2011-07-03Silence a C compiler warning in functionget_y_or_n.
[stefan]1.15 - 2011-06-04Fix memory leaks inpy_remove_history,py_replace_history, andpy_clear_historywhich can occur when history entries are edited.
See Pythonissue 12186.
[stefan]Add a defaultdisplay_matches_hookthat behaves exactly like readline
behaves in Bash.
[stefan]Addresetfunctions to completer, completion, and history.
[stefan]1.14 - 2011-05-05Add xfree.c to sources when building GNU Readline 6.2.
[stefan]Allow history indexes of type long.
[stefan]1.13 - 2011-03-11Use a custom build_ext command to find the best termcap library.
[stefan]Update static builds to GNU Readline 6.2.
[stefan]1.12 - 2010-08-04Fix memory leaks inpy_remove_historyandpy_replace_history.
See Pythonissue 9450.
[stefan]1.11 - 2010-05-21Update README, API documentation, and examples.
[stefan]MacPython detection caught other framework builds as well.
[stefan]1.10 - 2010-05-05Rework the history interface: Implement iteration and remove redundant APIs.
[stefan]History stifling could cause duplicate history entries.
[stefan]Make surebegidxandendidxcompletion variables are reset to 0.
[stefan]1.9 - 2010-04-02Remove unused defines; we don’t support libedit or readline < 5.0.
[stefan]Improve performance ofget_current_history_length.
[stefan]1.8 - 2010-03-14Makeget_history_itemzero-based and removeget_history_base.
[stefan]1.7 - 2010-03-09Support installation into MacPython for Mac OS X.
[stefan]1.6 - 2010-03-07The history size can now be limited (“stifled”) by settinghistory.max_entries. This supersedeshistory.lengthwhich has been
removed.
[stefan]Close a memory leak inget_current_history_length. Also see Pythonissue 8065.
[stefan]1.5.4 - 2010-03-01Avoid segfaults during codec lookup by callingPyGILState_Ensurein all
the right places. Fixes rlissue/5. Removes the workaround introduced in
1.5.2.
[stefan]1.5.3 - 2010-02-26Re-release with link to the correct issue.
[stefan]1.5.2 - 2010-02-26Work around segfaults under Python 3 on Linux, which are caused by bad or
missing codecs. This restricts Linux to UTF-8 and Latin-1 locales only.
Also see rlissue/5.
[stefan]1.5.1 - 2010-02-25Switch readline download location to ftp.gnu.org for speed.
[stefan]1.5 - 2010-02-25In Python 3, convert to and from Unicode using filesystem encoding
and “surrogateescape” error handler. SeePEP 383for the low-down.
[stefan]1.4.1 - 2010-02-13Fix GPL trove classifier.
[stefan]1.4 - 2010-02-13rl can now be installed into the system Python on Mac OS X, the only
dependency being Xcode Tools.
[stefan]Change license to PSF or GPL.
[stefan]1.3 - 2010-01-03Fix header detection under Fink on Mac OS X.
[stefan]Addreadline_versionAPI.
[stefan]1.2 - 2009-11-24Improve API documentation and examples.
[stefan]1.1 - 2009-11-16Remove all occurrences of old-style function typedefs to silence
compiler warnings.
[stefan]Make thedisplay_matches_hookwork in Python 2.5. Fixes rlissue/1.
[stefan]No longer auto-refresh the prompt at the end ofdisplay_match_list.
Applications should callredisplay(force=True)to restore the prompt.
[stefan]1.0 - 2009-11-08No changes since 1.0a8.1.0a8 - 2009-11-07Close a memory leak inword_break_hook. Three cheers for Xcode’sleakstool.
[stefan]1.0a7 - 2009-11-05Rename_readlinemodule toreadlinesince it’s not private.
[stefan]Removedumpandread_keyAPIs from public interfaces.
[stefan]1.0a6 - 2009-10-30Unclutter thecompleterinterface by removing settings that can
just as well be made withparse_and_bind.
[stefan]Fix a memory leak inusername_completion_functionandfilename_completion_function.
[stefan]Add a custom epydoc stylesheet to make its reST rendering more pleasant.
[stefan]1.0a5 - 2009-10-29Make allcompletionproperties writable. While not useful in
production, this allows us to write better tests.
[stefan]Improve API documentation and add a call graph for the completion
process. This goes a long way in explaining how readline completion
works.
[stefan]1.0a4 - 2009-10-27Implement thegeneratorfactory using an iterator instead of a list.
[stefan]Removefind_completion_wordso people don’t get ideas.
[stefan]Don’t list distribute as dependency, setuptools will do the
right thing.
[stefan]1.0a3 - 2009-10-22Add__slots__to interface objects to make them immutable.
[stefan]Support Python 2.5, 2.6, and 3.1 (thanks to distribute).
[stefan]Approach something like test coverage.
[stefan]1.0a2 - 2009-10-08Make thegeneratorfactory work for all types of callables.
[stefan]Improve examples.
[stefan]1.0a1 - 2009-10-04Initial release.