The standard Python readline extension statically linked against the GNU readline library.
Project description
Stand-alone GNU readline module
Do I need this package?
Do the following quick check:
python -c "import readline; print(readline.__doc__)"
If the output is:
Importing this module enables command line editing using GNU readline.
then you already have GNU Readline and you probably don’t need this package (unless you know what you are doing!). However, if the output is:
Importing this module enables command line editing using libedit readline.
then you’ve come to the right place.
Still interested?
Some Posix platforms such as macOS do not ship with GNU Readline installed. Readline is licensed under the GPL, which makes it hard to distribute with proprietary software. A popular alternative is NetBSD’s Editline (libedit) library which has a less restrictive BSD license. If you install Python on macOS via a popular open-source package manager such as Homebrew or MacPorts, you’ll get a readline extension module that calls libedit internally (even though it’s confusingly still called “readline”!).
While a lot of effort has gone into making GNU Readline and Editline interchangeable within Python, they are not fully equivalent. If you want proper Readline support, this module provides it by bundling the standard Python readline module with the GNU Readline source code, which is compiled and statically linked to it. The end result is a package which is simple to install and only requires the system-dependent ncurses library.
The module is called gnureadline so as not to clash with the existing readline module in the standard library. It supports two general needs:
Code that explicitly imports readline
A typical use case is to override readline in your code like this:
try:
import gnureadline as readline
except ImportError:
import readline
Tab completion in the standard interactive Python shell
The above trick does not fix tab completion in the Python shell because by the time the shell prints its first output to the screen, it’s too late… One solution is to put this workaround in one of the customization modules imported by the site module early on during the startup process.
This is conveniently done for you by installing gnureadline and running:
<python> -m override_readline
where <python> is the specific Python interpreter you want to fix (for example python3). The script first tries to add the workaround to usercustomize and then falls back to sitecustomize if the user site is not enabled (for example in virtualenvs). If you want to go straight to sitecustomize, add the standard -s option:
<python> -s -m override_readline
The script explains in detail what it is doing and also refuses to install the workaround twice. Another benefit of override_readline is that the interactive Python interpreter gains a helpful reminder on startup, like:
Python 3.12.2 (main, Apr 17 2024, 20:25:57) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. Using GNU readline instead of the default readline (see sitecustomize.py) >>>
You don’t have to run the override_readline script if gnureadline was installed as a dependency of another package. It’s only there to help you fix tab completion in the standard Python shell.
While usercustomize and sitecustomize are associated with a specific Python version, you can also fix tab completion for all Python versions by adding the workaround to the PYTHONSTARTUP file (e.g. ~/.pythonrc). This requires some extra setup as seen in this example pythonrc, which also shows a way to maintain separate history files for libreadline and libedit. The PYTHONSTARTUP file only affects the interactive shell, while user / site customization affects general scripts using readline as well. The Python Tutorial has a section describing these customization options.
Please take note that IPython does not depend on gnureadline for tab completion anymore. Since version 5.0 it uses prompt_toolkit instead.
Versions
The module can be used with both Python 2.x and 3.x, and has been tested with Python versions 2.6, 2.7, and 3.2 to 3.13. The first three numbers of the module version reflect the version of the underlying GNU Readline library (major, minor and patch level), while any additional fourth number distinguishes different module updates based on the same Readline library.
The latest development version is available from the GitHub repository.
If you are using Windows, which also ships without GNU Readline, you might want to consider using the pyreadline3 module instead, which is a readline replacement written in pure Python that interacts with the Windows clipboard.
History
8.2.13 (2024-10-18)
#70, #76: Supports Python 3.13 (including free-threaded version)
#74, #75: Fix readline override to work with python-build-standalone dist
Uses Python 3.13.0 readline.c (commit 417dd3a, 2024-05-06)
Updated to build against readline 8.2 (patch-level 13)
8.2.10 (2024-06-10)
#61, #62, #65, #69: Supports Python 3.11 and 3.12, but not yet 3.13
New readline override mechanism via site customization
Overhaul documentation and tests to reflect this
Upgrade GitHub Actions to use macos-13 and macos-14 native builds
Uses Python 3.12.1 readline.c (commit 7225a01, 2023-11-28), also OK for 3.11
Uses Python 3.10.9 readline.c (commit 5074c35, 2022-10-27), also OK for 3.9
Updated to build against readline 8.2 (patch-level 10)
8.1.2 (2022-06-14)
#57, #58: Now supports arm64 architecture (Apple M1, Raspberry Pi)
Moved CI from Travis + multibuild to GitHub Actions + cibuildwheel
Uses Python 3.11.0a7 readline.c (commit aac29af, 2021-10-13), OK for 3.10, 3.9
Uses Python 3.8.8 readline.c (commit f9d7c12, 2021-02-16), also OK for 3.7
Uses Python 2.7.18 readline.c (commit f32bcf8, 2019-11-07)
Updated to build against readline 8.1 (patch-level 2)
8.0.0 (2019-07-10)
Uses Python 3.7.4 readline.c (commit ef10f88, 2019-03-20), also OK for 3.8
Uses Python 3.6.8 readline.c (commit 25555e0, 2018-12-08), also OK for 3.5
Uses Python 3.4.4 readline.c (commit 7462b64, 2015-11-02)
Uses Python 2.7.16 readline.c (commit 89b5ea2, 2018-12-19)
Updated to build against readline 8.0
6.3.8 (2017-10-20)
#42, #44: Address compiler issues (avoid Cygwin, fix multi-arch on gcc)
#40: Make GPLv3 license explicit
#39: Look for bash shell in more places
Uses Python 2.x readline.c from hg 2.7 branch (95814:192f9efe4a38)
Uses Python 3.x readline.c from hg 3.4 / 3.5 branch (95813:ec6ed10d611e)
Updated to build against readline 6.3 (patch-level 8)
6.3.3 (2014-04-08)
Major rework of OS X build process (detect arches, no custom flags)
#20, #22, #28: Various issues addressed by new streamlined build
#28: Use $CC or cc to compile libreadline instead of default gcc
#35: Workaround for clang from Xcode 5.1 and Mac OS X 10.9.2
Uses Python 3.4 readline.c from hg 3.4 branch (89086:3110fb3095a2)
Updated to build against readline 6.3 (patch-level 3)
6.2.5 (2014-02-19)
Renamed module to gnureadline to improve installation with pip
#23, #25-27, #29-33: Tweaks and package reworked to gnureadline
Uses Python 2.x readline.c from hg 2.7 branch (89084:6b10943a5916)
Uses Python 3.x readline.c from hg 3.3 branch (89085:6adac0d9b933)
Updated to build against readline 6.2 (patch-level 5)
6.2.4.1 (2012-10-22)
#21: Fixed building on Python.org 3.3 / Mac OS 10.8
6.2.4 (2012-10-17)
#15: Improved detection of compilers before Xcode 4.3
Uses Python 3.x readline.c from v3.3.0 tag (changeset 73997)
Updated to build against readline 6.2 (patch-level 4)
6.2.2 (2012-02-24)
#14: Fixed compilation with Xcode 4.3 on Mac OS 10.7
Updated to build against readline 6.2 (patch-level 2)
6.2.1 (2011-08-31)
#10: Fixed ‘_emacs_meta_keymap’ missing symbol on Mac OS 10.7
#7: Fixed SDK version check to work with Mac OS 10.7 and later
Uses Python 2.x readline.c from release27-maint branch (r87358)
Uses Python 3.x readline.c from release32-maint branch (r88446)
6.2.0 (2011-06-02)
#5: Removed ‘-arch ppc’ on Mac OS 10.6, as Snow Leopard supports Intel only
Updated to build against readline 6.2 (patch-level 1)
6.1.0 (2010-09-20)
Changed version number to reflect readline version instead of Python version
#4: Updated to build against readline 6.1 (patch-level 2)
#2: Python 3 support
Uses Python 2.x readline.c from release27-maint branch (r83672)
Uses Python 3.x readline.c from r32a2 tag (r84541)
Source code moved to GitHub
Additional maintainer: Sridhar Ratnakumar
2.6.4 (2009-11-26)
Added -fPIC to compiler flags to fix linking error on 64-bit Ubuntu
Enabled all readline functionality specified in pyconfig.h macros
Uses readline.c from Python svn trunk (r75725), which followed 2.6.4 release
Patched readline.c to replace Py_XDECREF calls with the safer Py_CLEAR
Fixed compilation error on Mac OS 10.4 with XCode older than version 2.4
2.6.1 (2009-11-18)
Updated package to work with Mac OS 10.6 (Snow Leopard), which ships with Python 2.6.1
Uses readline.c from Python 2.6.1 release
Backported “spurious trailing space” bugfix from Python svn trunk (see e.g. https://bugs.launchpad.net/python/+bug/470824 for details on bug)
Updated to build against readline 6.0 (patch-level 4)
Now builds successfully on Linux (removed Mac-specific flags in this case), and still supports Mac OS 10.4 and 10.5
2.5.1 (2008-05-28)
Updated package to work with Mac OS 10.5 (Leopard), which ships with Python 2.5.1
Uses readline.c from Python 2.5.1 release
Updated to build against readline 5.2 (patch-level 12)
New maintainer: Ludwig Schwardt
2.4.2 (2005-12-26)
Original package by Bob Ippolito, supporting Python 2.3 / 2.4 on Mac OS 10.3 (Panther) and 10.4 (Tiger)
Builds against readline 5.1
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for gnureadline-8.2.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f59275168cae1b02ca1ec7586a9804bb04ce427df92f8582a80d16e96c846b78 |
|
MD5 | 17a7cd7e202b29fb607f869a0793ff52 |
|
BLAKE2b-256 | ee2c29cc2b99b9c7f49041edefe3c051c566e60080631dd4241cae269a2f067b |
Hashes for gnureadline-8.2.13-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7d6e3f5d9fd0cf8a84fb382d4e3ad2914331be4d929f17d50da01f1571c4b03 |
|
MD5 | 052ed7e7aa2019d712885d68cd220f8b |
|
BLAKE2b-256 | 168e9f716757f875dfea0c9f5a323e103eec8a546e650a37c7f133a9b86c2c8f |
Hashes for gnureadline-8.2.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c550d08c4d2882a83293a724b14a262ee5078fd4fa7acdc78aa59cab26ae343 |
|
MD5 | 685d001f6427818b7788d7a3f4b05323 |
|
BLAKE2b-256 | 3a418821db40f2b0dd9cc935d6838bc63776fb5bfb1df092f8d4698ec29ada6a |
Hashes for gnureadline-8.2.13-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d3e33d2e0dd694d623a2ca1fae6990b52f1d25955504b7293a9350fb9912940 |
|
MD5 | bb8eda80010a3e3c27501813a8d5c9dc |
|
BLAKE2b-256 | a1b04a3c55a05b4c1c240fd6dc204ff597432008c4649ce500688a2441d27cf4 |
Hashes for gnureadline-8.2.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cc77fc9c8a8fcf10e0a554e49ee763219683386b8f906b7e6ef07c9e40e8420 |
|
MD5 | 74a44f02aeb1d3890307f42d7c893a23 |
|
BLAKE2b-256 | 08d31face508173298b6d4d9f96ad4e408bcbdea704c583646e41d0aa6826385 |
Hashes for gnureadline-8.2.13-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b69e6608cc94e110018b721a11718d480a6330e0b62cbab65a22880e84011205 |
|
MD5 | ae2bb5068eddac91319a421b3d88a1f2 |
|
BLAKE2b-256 | 9264ae5598fd1dbf7de863cd7066798fe882f2e9b5dcdb49f8ad859e736c2212 |
Hashes for gnureadline-8.2.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85e362d2d0e85e45f0affae7bbfaf998b00167c55a78d31ee0f214de9ff429d2 |
|
MD5 | e66e01dd830ff5b34e4ac8467000ebb9 |
|
BLAKE2b-256 | 97ee322e5340c8cdfa40e71bd0485a82404ad4cf9aed2260cca090f3c1a3a032 |
Hashes for gnureadline-8.2.13-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c152a82613fa012ab4331bb9a0ffddb415e37561d376b910bf9e7d535607faf |
|
MD5 | a7ee9109085005b568b183474712c277 |
|
BLAKE2b-256 | 68bddf8fd060e43efd3dbdd3b210bf558ce3ef854843cd093f910f4115ebe2e9 |
Hashes for gnureadline-8.2.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10fcaf561bc4ed6ab7075ab3ead188a18faaf4e6e92d916f81a09c0a670ce906 |
|
MD5 | faaa428a92f9c70d2d50b6b76a8d5bde |
|
BLAKE2b-256 | bd12af62b7578f741f6af3120a44eb930aaa2f215c56f171068a0c8b7839245d |
Hashes for gnureadline-8.2.13-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 576dac060887adc6067ee9d23fb2f0031fb2b3e560e07a6c9e666e05f0473af7 |
|
MD5 | 6336b54e81093221a462ccf60326425d |
|
BLAKE2b-256 | 1988c7465657d2c4c3e30794f15568e322d65389cc00d825627cc3d0f9b92d9a |
Hashes for gnureadline-8.2.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | daa405028b9fe92bfbb93624e13e0674a242a1c5434b70ef61a04294502fdb65 |
|
MD5 | 7b4f313887da6a5d2b02e67ea35405c0 |
|
BLAKE2b-256 | f79b464929f1e81ba4ea4fafb033c38eefedc533b503d777e91ffa12751ad34e |
Hashes for gnureadline-8.2.13-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 561a60b12f74ea7234036cc4fe558f3b46023be0dac5ed73541ece58cba2f88a |
|
MD5 | 8eea221f5f5a3b9dbf1a0fee2e6fe13f |
|
BLAKE2b-256 | ffada6c59fcdbc8173bc538dad042696b732d39bc8de95adb07664b124c07942 |
Hashes for gnureadline-8.2.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94b143ea5d22b0c1ca4a591265afe135272c69b7757e968e34fbb47a7858d1ce |
|
MD5 | df1caec0896281afe39c2856d5f2638c |
|
BLAKE2b-256 | d33283b7f20d1847755cb44a1f9e338b85a517277a62490e4dadff7edf1a8d1e |
Hashes for gnureadline-8.2.13-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6472e3a780087eecd67c03e5455aecb209de51bcae74583222976f6b816f6192 |
|
MD5 | cb5dab5ef079f483299c8ea6b0bdcc20 |
|
BLAKE2b-256 | 4d5bcdefea07b18f98737b7908c7de75ba55106a6b4a8c182e5e5b0b53c195e5 |
Hashes for gnureadline-8.2.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c28e33bfc56d4204693f213abeab927f65c505ce91f668a039720bc7c46b0353 |
|
MD5 | 2e3da671b782ed0ae811d2e153c467c3 |
|
BLAKE2b-256 | 48060297bdde1e4a842ec786b9b7c9fca53116bac8fe2aed9769000f652fd1e3 |
Hashes for gnureadline-8.2.13-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ca03501ce0939d7ecf9d075860d6f6ceb2f49f30331b4e96e4678ce03687bab |
|
MD5 | 75b4c2e3f425eb0bc29a21f54465c629 |
|
BLAKE2b-256 | f44f81ff367156444f67d16cc8d9023b4a0a3f4bd29acaf8f8e510c7872b6927 |
Hashes for gnureadline-8.2.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f57a3aa97c3379b2513c8bfbac0de2dfb41f695623c0b2ad337babb646b51a7 |
|
MD5 | f0a5aba66df258e017520064c3d2b24a |
|
BLAKE2b-256 | 765e4189ed7dcc1b09fb138703d688ab342366f7c223c669ed1aff5c7595ebc9 |
Hashes for gnureadline-8.2.13-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 811d85a70ac97cddeb1755282915e8a93c279dcf89513426f28617b8feff5aec |
|
MD5 | 9df57887836e548bb1c6207420e398dd |
|
BLAKE2b-256 | 41f66b42a70e630f3308bb58eee0b1ba6f6e112df1bbc65269252f5a6ae15e5d |
Hashes for gnureadline-8.2.13-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7b8d3f2a2c9b7e6feaf1f20bdb6ebb8210e207b8c5360ffe407a47efeeb3fb8 |
|
MD5 | 8caefe18635d0e2aaf16a578bf10e30a |
|
BLAKE2b-256 | 877d9834bc32cf6531c2ec21998d0b0631ddc5f69c31bf2358f9489e27e06dec |
Hashes for gnureadline-8.2.13-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcfa601d95c00aa670ec5e4bf791caf6ba0bcf266de940fb54d44c278bd302fe |
|
MD5 | 10e2286604140487e5759ab1cb192a6a |
|
BLAKE2b-256 | 03f1be0297498c20df97525ddd1bb48bc3a3237321f323e9c24fe45ff576decb |
Hashes for gnureadline-8.2.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50c40bfffffa82d4fcb0fde4940d4ff128ba2f876c1da09bae9d6d9ff770095e |
|
MD5 | 31cbb8f7cdfe07d386accea0c5eb28b0 |
|
BLAKE2b-256 | bf1e6a135c0c6cb79cf2afa925e49ef5d51c24be10d9bfb1f5f5a01345108b97 |
Hashes for gnureadline-8.2.13-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30cc1b6cb11d94554815cb91eb1dfa6a11887185aae50f253adaa393e91c6a86 |
|
MD5 | 0fd3a152c2187c5eddfc5cbbdad9d7f4 |
|
BLAKE2b-256 | 911242a79fe1d48fd9e3ae0b10f68fe56201f199bd7d20ac6a7a639272128ee5 |
Hashes for gnureadline-8.2.13-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07231f8191adb7f204010a86a91df9df9a80944981a16576a471f59304ad6a16 |
|
MD5 | 0dea93902f1c98ec6bf0234552e0c474 |
|
BLAKE2b-256 | 9dc571a0194f6c55b923d672f9347b2ef5dd35ba4746f489586eea8d6422c754 |
Hashes for gnureadline-8.2.13-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 265bcf6ef7082e130160fb34b9664284affb216a22c5bffcd518b35d02bcc4e9 |
|
MD5 | 9979670ce446b0142811ae811fde639d |
|
BLAKE2b-256 | 3fab2404fd8fbad742b81e60522eb1fc71b50547cb63f3b4e8d22d746e55ac3b |
Hashes for gnureadline-8.2.13-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d708e8f655d3b556a138f13e9fcb2d8a10a6901e3125c04cad5ef7c883191fe8 |
|
MD5 | cefa804dbe66f92bd3a6dc72149c690c |
|
BLAKE2b-256 | c3a30efb1df454aebbd96dc17a534445c30ce590fe9c6bd0ee26f08fadafd826 |
Hashes for gnureadline-8.2.13-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f5fc90af56a1ae6f88c9c7122fc76141c395b6c342a63800abed8c813f48b85 |
|
MD5 | 405bc29011cc92257d791179f4bf9496 |
|
BLAKE2b-256 | a12ad837ad2213a79ae1db7043408d79fe5a6cdccd5b271f674883d3b9c42dc4 |
Hashes for gnureadline-8.2.13-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23b43c8e9e2e6566cb3094749826181a86dba1d94b1e023b5f9923dc26e37876 |
|
MD5 | 691a163ee1abf4fecb039b7d52c2dfc7 |
|
BLAKE2b-256 | 42aeb71bd8292e17dc176cc71afeaa04c05861fd2d502fcfb1f9221f6a89428c |
Hashes for gnureadline-8.2.13-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f1050ecf789f34d0ab0aacdb605f177725009a864e0038e70380614af92dc0d |
|
MD5 | 99e296eb5c9a876cf1c4687950e60492 |
|
BLAKE2b-256 | a4a9296030ca08600a9dff627e071a5a3834fbc5df7dbfcf39f830a3051a3f9f |
Hashes for gnureadline-8.2.13-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59c5505026646da6d5ced6a5316d6d191d011e8be422cba4abce71730ef37dc6 |
|
MD5 | ea1aab37d41c9fe610b2001bb8787e63 |
|
BLAKE2b-256 | 53e8f8ada64e8a72c637e660d51389e3d1d460e7cd688aa283ccb325cf41a969 |