greenbone / autohooks

Library for managing git hooks
https://greenbone.github.io/autohooks/
GNU General Public License v3.0
190 stars 22 forks source link

Windows Support? #43

Closed scruffaluff closed 4 years ago

scruffaluff commented 4 years ago

autohooks/terminal.py depends on the curses package, which I believe is not supported on Windows. When I run the command poetry run autohooks activate, I receive the error ModuleNotFoundError: No module named _curses. Am I suppose to use a different command to activate the git hooks on Windows?

bjoernricks commented 4 years ago

Internally autohooks uses blessings to provide colorization of the console output. After looking at it I don't think it supports Windows :-/

Personally I am not able to write any code for Windows because my knowledge about it is very small. And I also don't have access to any Windows system.

But this doesn't mean autohooks shouldn't get support for Windows. I am only relying on PRs from external contributors.

bjoernricks commented 4 years ago

As far as I know curses should be at least importable at windows. Could you paste the whole taceback? Maybe it is already possible to support windows by using https://github.com/tartley/colorama

scruffaluff commented 4 years ago

FYI, I am using powershell on Windows with poetry and pyenv. I haven’t tried colorama, but here is the trace back:

 Windows: poetry run autohooks activate
Traceback (most recent call last):
  File "C:\Users\user\.pyenv\pyenv-win\versions\3.8.0-amd64\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\user\.pyenv\pyenv-win\versions\3.8.0-amd64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\user\tmp\ahook\.venv\Scripts\autohooks.exe\__main__.py", line 5, in <module>
  File "c:\users\user\tmp\ahook\.venv\lib\site-packages\autohooks\cli\__init__.py", line 20, in <module>
    from autohooks.terminal import Terminal
  File "c:\users\user\tmp\ahook\.venv\lib\site-packages\autohooks\terminal.py", line 17, in <module>
    import curses
  File "C:\Users\user\.pyenv\pyenv-win\versions\3.8.0-amd64\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
bjoernricks commented 4 years ago

Could you do me a favor and just run import curses in a python shell?

scruffaluff commented 4 years ago

Sure. Here is the trace back:

Windows: python -i
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\user\.pyenv\pyenv-win\versions\3.8.0-amd64\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
bjoernricks commented 4 years ago

ok. I've done some research. Python in windows doesn't support curses. It seems you need to install an additional library to get it working https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses

From https://docs.python.org/3/howto/curses.html#curses-howto

The Windows version of Python doesn’t include the curses module. A ported version called UniCurses is available. You could also try the Console module written by Fredrik Lundh, which doesn’t use the same API as curses but provides cursor-addressable text output and full support for mouse and keyboard input.

bjoernricks commented 4 years ago

Hmm maybe blessings doesn't work at all on windows https://github.com/erikrose/blessings/issues/21

jquast commented 4 years ago

(FWIW, blessed, a fork of blessings, does work on windows)