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.23k stars 54 forks source link

[BUG] Missing dependency #22

Closed developomp closed 2 years ago

developomp commented 2 years ago

Describe the bug package PyYAML is used in file_loaders.py but it's not listed as its dependencies.

To Reproduce Steps to reproduce the behavior:

  1. Fresh install python 3
  2. Install pytermgui via pip
  3. Clone repo and navigate to the examples directory
  4. run krm

Expected behavior There should be no error.

Screenshots

This ain't no screenshot but I think it's more helpful.

Traceback (most recent call last):
  File "/home/pomp/.local/lib/python3.10/site-packages/pytermgui/file_loaders.py", line 138, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/media/pomp/data/projects/setup/./setup.py", line 97, in <module>
    main()
  File "/media/pomp/data/projects/setup/./setup.py", line 93, in main
    entry()
  File "/media/pomp/data/projects/setup/src/entry.py", line 8, in entry
    show_main_menu()
  File "/media/pomp/data/projects/setup/src/ui/show_main_menu.py", line 87, in show_main_menu
    with ptg.WindowManager() as manager:
  File "/home/pomp/.local/lib/python3.10/site-packages/pytermgui/window_manager.py", line 381, in __exit__
    raise exception
  File "/media/pomp/data/projects/setup/src/ui/show_main_menu.py", line 88, in show_main_menu
    loader = ptg.YamlLoader()
  File "/home/pomp/.local/lib/python3.10/site-packages/pytermgui/file_loaders.py", line 402, in __init__
    raise RuntimeError(
RuntimeError: YAML implementation module not found. Please install `PyYAML` to use `YamlLoader`.

System information

fatal: not a git repository (or any of the parent directories): .git
PyTermGUI v2.0.0+
Python: 3.10.2
Platform: Linux-5.16.2-arch1-1-x86_64-with-glibc2.33
Git commit: Could not determine due to CalledProcessError:
        Command '['git', 'rev-parse', '--short', 'HEAD']' returned non-zero exit status 128..

Possible cause Described above

Possible solution Add PyYAML as pytermgui's dependency.

RIP Zero dependencies :(

bczsalba commented 2 years ago

This is actually intended behaviour. The only part of the code that requires PyYAML as a dependency is YamlLoader, so adding it as a full dependency is odd as it's a fully optional feature.

My idea is, if you use YAML in your project you should include it in the dependencies yourself, but the users who don't shouldn't have to install it when it will never get used.

developomp commented 2 years ago

I think it'd be a good idea to put that in the documentation then.

bczsalba commented 2 years ago

Good call.