ludwigschwardt / python-gnureadline

The standard Python readline extension statically linked against the GNU readline library, providing readline support to Python on platforms without it.
http://pypi.python.org/pypi/gnureadline
GNU General Public License v3.0
78 stars 30 forks source link

Error When Attempting to Override #74

Open creese opened 6 days ago

creese commented 6 days ago

When I try to override, I end up getting an error. I'm using Mise and fish on macOS, if that makes a difference.

$ python -m override_readline

This script will attempt to install an override in Python's site customization
modules that replaces the default readline module with gnureadline.

First check the existing readline module and its replacement
------------------------------------------------------------

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/REDACTED/.local/share/mise/installs/python/3.12.5/lib/python3.12/site-packages/override_readline.py", line 160, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/REDACTED/.local/share/mise/installs/python/3.12.5/lib/python3.12/site-packages/override_readline.py", line 147, in main
    readline = check_module("readline")
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/REDACTED/.local/share/mise/installs/python/3.12.5/lib/python3.12/site-packages/override_readline.py", line 74, in check_module
    kwargs = dict(name=module_name, style=style, path=module.__file__)
                                                      ^^^^^^^^^^^^^^^
AttributeError: module 'readline' has no attribute '__file__'. Did you mean: '__name__'?
ludwigschwardt commented 6 days ago

Thanks for the report! I can recreate it by running:

brew install mise fish
fish
mise install python@3.12.5
mise exec python@3.12.5 -- pip install gnureadline
mise exec python@3.12.5 -- python -m override_readline

I suspect something fishy since I only ever use bash šŸ˜…

ludwigschwardt commented 6 days ago

Ah, yes, python-build-standalone, a decidedly quirky distribution. I've encountered this before in #68. It's what mise uses by default (sorry fish, you're off the hook!).

One workaround is to compile your mise pythons from scratch (slower but less quirky):

mise settings set python_compile true
mise install python@3.12.4

That even compiles with readline on my Homebrew setup, so no real need for the gnureadline package then šŸ™‚

It should be easy to fix this crash though.

ludwigschwardt commented 6 days ago

Please check if #75 fixes your issue.