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

Installation fails on Python 3.10/Windows #6

Closed alexlawriewood closed 2 years ago

alexlawriewood commented 2 years ago

Cool library! Didn't install easily, though, on WIndows 10 and with Python 3.10:

C:\Users\awood\AppData\Local\Temp\1
λ py -3.10 -m venv pytermgui-env

C:\Users\awood\AppData\Local\Temp\1
λ pytermgui-env\scripts\activate

C:\Users\awood\AppData\Local\Temp\1
(pytermgui-env) λ pip install pytermgui==1.0.1
Looking in indexes: https://pypi.org/simple, http://b******
Collecting pytermgui==1.0.1
  Downloading http://btc-asic-dev01/root/pypi/%2Bf/144/5199ce1d54d82/pytermgui-1.0.1.tar.gz (56 kB)
     |████████████████████████████████| 56 kB 325 kB/s
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\awood\AppData\Local\Temp\1\pytermgui-env\Scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\awood\\AppData\\Local\\Temp\\1\\pip-install-l21qgegv\\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\\setup.py'"'"'; __file__='"'"'C:\\Users\\awood\\AppData\\Local\\Temp\\1\\pip-install-l21qgegv\\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\awood\AppData\Local\Temp\1\pip-pip-egg-info-fv_vf4ds'
         cwd: C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\
    Complete output (17 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\setup.py", line 3, in <module>
        import pytermgui
      File "C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\pytermgui\__init__.py", line 98, in <module>
        from .parser import *
      File "C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\pytermgui\parser.py", line 76, in <module>
        from .ansi_interface import foreground
      File "C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\pytermgui\ansi_interface.py", line 285, in <module>
        terminal = _Terminal()
      File "C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\pytermgui\ansi_interface.py", line 221, in __init__
        self.size: tuple[int, int] = self._get_size()
      File "C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\pytermgui\ansi_interface.py", line 239, in _get_size
        return tuple(val - org for val, org in zip(screen_size(), self.origin))  # type: ignore
      File "C:\Users\awood\AppData\Local\Temp\1\pip-install-l21qgegv\pytermgui_0883789d0f7b4af58fb5d9b512057f2b\pytermgui\ansi_interface.py", line 202, in screen_size
        width, height = get_terminal_size()
    OSError: [WinError 6] The handle is invalid
    ----------------------------------------

Cloning the repo, patching pytermgui.ansi_interface.screen_size to return 0, 0 for errorno in (9, 25) instead of just 25 allowed me to install it, and then seemed to work fine! I'm no terminal expert, but I guess there's no interactive terminal available to pip's install targets.

bczsalba commented 2 years ago

That's one very odd issue! I assume its something to do with terminal size functionality not quite working on Windows, so I will look into it later! Thank you.

bczsalba commented 2 years ago

@alexlawriewood

So the commit automatically closed this issue, but as a sanity check could you test if it actually did?

Thanks for your help!

alexlawriewood commented 2 years ago

Yup, installs properly now! And MarkApp seems to work, as a basic test.

bczsalba commented 2 years ago

That's great to hear! I wonder if there is any way to replace SIGWINCH, as it allows for some neat features.