Falcon-Toolkit icon indicating copy to clipboard operation
Falcon-Toolkit copied to clipboard

Python 3.12 Support

Open ChristopherHammond13 opened this issue 2 years ago • 6 comments

It appears that the gnureadline package on PyPI will not build properly on macOS Sonoma with Python 12.0, potentially due to some changes in clang.

This issue acknowledges that we are aware of this, and for now recommend sticking with Python 3.11 if you require an alternative readline implementation. Note that this will apply to most macOS/Homebrew users, as Python is built against libedit by convention on macOS.

There are also some documented issues with the pick ibrary that we use on Python 3.12 (see: https://github.com/wong2/pick/issues/110).

Support Task List

  • [x] Get gnureadline built for Python 3.12 and onto PyPI (see: https://github.com/ludwigschwardt/python-gnureadline/pull/71).
  • [x] Either wait for a fix in the pick library, or migrate to Prompt Toolkit. As some of our internal tooling uses a combination of Prompt Toolkit and pick, I am not opposed to reducing dependencies here and fully migrating to Prompt Toolkit.
  • [ ] Fully test the application on 3.12, paying attention to things like command history, curses-based UIs (keyboard selection menus), etc.

ChristopherHammond13 avatar Nov 13 '23 14:11 ChristopherHammond13

The second bullet point is being addressed by #113

ChristopherHammond13 avatar Feb 26 '24 12:02 ChristopherHammond13

FYI for anyone else who stumbles on this issue when trying to install falcon-toolkit with multiple versions of python.

I have 3 versions of python installed via pyenv as well as python 3.12 installed directly on my mac.

❯ pyenv versions
  system
* 3.11.9 (set by PYENV_VERSION environment variable)
  3.12.2

Trying to install falcon-toolkit using the traditional command eventually gave me the readline error as described in this issue because it was defaulting to my system python version (3.12).

❯ pipx install falcon-toolkit
  installed package falcon-toolkit 3.4.1, installed using Python 3.12.3
  These apps are now globally available
    - falcon
done! ✨ 🌟 ✨

~
❯ falcon
Readline features including tab completion have been disabled because
no supported version of readline was found. To resolve this, install
pyreadline3 on Windows or gnureadline on Linux/Mac.

There is a workaround but it requires you to have prior versions of python installed and helps to have a manager like pyenv. To get falcon-toolkit to install correctly using a prior version of python, use the --python <path/to/python> flag in the install command.

❯ pyenv shell 3.11

~
❯ python --version
Python 3.11.9

~
❯ pipx install falcon-toolkit --python $(which python)
  installed package falcon-toolkit 3.4.1, installed using Python 3.11.9
  These apps are now globally available
    - falcon
done! ✨ 🌟 ✨

~
❯ falcon
Usage: falcon [OPTIONS] COMMAND [ARGS]...

the1337beauty avatar Apr 22 '24 21:04 the1337beauty

FYI just last week the gnureadline maintainer has created a new PR that they say they prefer: https://github.com/ludwigschwardt/python-gnureadline/pull/71

(the PR linked in the OP for gnureadline appears to be open even though ludwig disprefers that approach)

davclark avatar Apr 26 '24 20:04 davclark

Thanks Dav, I forgot to close that :-) Please let me know if the new PR works for you.

ludwigschwardt avatar Apr 26 '24 22:04 ludwigschwardt

Thank you to all who have commented above! I have updated the OP to link to Ludwig's new PR which I have tested as working under 3.12.

See: https://github.com/ludwigschwardt/python-gnureadline/pull/71#issuecomment-2088466514

Once this PR has been approved and pushed to PyPI, I will close this issue as we don't have any other (known) 3.12 compatibility issues.

Thanks to all for your patience on this one, and a massive thank you to Ludwig for his work on the gnureadline library which makes a lot of the shell functionality provided by Cmd2 work on non-readline systems!

ChristopherHammond13 avatar May 01 '24 13:05 ChristopherHammond13

Thanks to some great work from @ludwigschwardt, we now have a working version of gnureadline for Python 3.12!! 🎉 Thank you so much again, Ludwig!

We'll get some better documentation written around this to certify Python 3.12 here.

ChristopherHammond13 avatar Jul 08 '24 18:07 ChristopherHammond13

Thanks to this PR, we should also be fully compatible with Python 3.13! 🎉 https://github.com/ludwigschwardt/python-gnureadline/pull/76

ChristopherHammond13 avatar Dec 02 '24 17:12 ChristopherHammond13

I tried to be proactive for a change 😁

ludwigschwardt avatar Dec 02 '24 19:12 ludwigschwardt