bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.21k stars 54 forks source link

[BUG] Missing cached_property dependency on Python 3.7 #66

Closed pawamoy closed 2 years ago

pawamoy commented 2 years ago

Describe the bug cached_property was only introduced in functools in Python 3.8. To support Python 3.7, you'd need to add "cached_property; python_version < '3.8'" to your setup.py install_requires.

Example PDM traceback

Traceback (most recent call last):
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 363, in <module>
    main()
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
    return hook(config_settings)
  File "/tmp/pdm-build-env-6lb9o84s-shared/lib/python3.7/site-packages/setuptools/build_meta.py", line 178, in get_requires_for_build_wheel
    config_settings, requirements=['wheel'])
  File "/tmp/pdm-build-env-6lb9o84s-shared/lib/python3.7/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires
    self.run_setup()
  File "/tmp/pdm-build-env-6lb9o84s-shared/lib/python3.7/site-packages/setuptools/build_meta.py", line 282, in run_setup
    self).run_setup(setup_script=setup_script)
  File "/tmp/pdm-build-env-6lb9o84s-shared/lib/python3.7/site-packages/setuptools/build_meta.py", line 174, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 3, in <module>
    import pytermgui
  File "/tmp/pdm-build-8bgr4d0i/pytermgui/__init__.py", line 20, in <module>
    from .parser import *
  File "/tmp/pdm-build-8bgr4d0i/pytermgui/parser.py", line 121, in <module>
    from .colors import str_to_color, Color, StandardColor
  File "/tmp/pdm-build-8bgr4d0i/pytermgui/colors.py", line 18, in <module>
    from functools import lru_cache, cached_property
ImportError: cannot import name 'cached_property' from 'functools' (/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.12/lib/python3.7/functools.py)
bczsalba commented 2 years ago

I literally just found out about a pretty sizeable chunk of things not working in 3.7 2 days ago. Not sure if they are "worth" fixing, as a lot of it will introduce redundant reimplementations of things that are already part of stdlib Python in later versions, but doing it in a less efficient manner.

It seems that 3.7 EOL is set in about a year, so there is probably still a lot of people using it. Of course, it would be ideal to support it but I don't want to restrict the rest of the users as a result.

Is there any way you can use >=3.8 for now?

pawamoy commented 2 years ago

Sure, I'm just testing docs building on 3.7 up to 3.11. I can drop 3.7 for this one project :slightly_smiling_face: You should still update python_requires in setup.py (whether you add support for 3.7 later or not) :smile:

bczsalba commented 2 years ago

Yeah, it's a big conundrum at the moment. pypistats reports 5% of downloads of the project on 3.7, though 50% is annotated as null. This issue, as far as I know, should be present for releases months back, so the fact that no one has pointed it out until this thread seems to suggest either a very quiet population of developers, or practically no usage.