ulfalizer / Kconfiglib

A flexible Python 2/3 Kconfig implementation and library
ISC License
450 stars 161 forks source link

Kconfiglib cannot be installed from MSYS #77

Closed dobairoland closed 4 years ago

dobairoland commented 4 years ago
$ pip install kconfiglib
Collecting kconfiglib
  Downloading https://files.pythonhosted.org/packages/13/3b/836b3af23701728830771d5c45fc3bd1c67ea646b49f6384a44343aa0b3e/kconfiglib-12.14.1-py2.py3-none-any.whl (142kB)
     |################################| 143kB 2.2MB/s
Collecting windows-curses; sys_platform == "win32" (from kconfiglib)
  ERROR: Could not find a version that satisfies the requirement windows-curses; sys_platform == "win32" (from kconfiglib) (from versions: none)
ERROR: No matching distribution found for windows-curses; sys_platform == "win32" (from kconfiglib)

I closed this https://github.com/zephyrproject-rtos/windows-curses/issues/4 accepting that windows-curses cannot be installed in MSYS but I think Kconfiglib should not request it there if it cannot be installed.

ulfalizer commented 4 years ago

Didn't know it reported as win32 to be honest. I'll look into it once I get back to a Windows box.

Maybe you could try playing around a bit in MSYS 2 and see what some different Python system identification functions return?

dobairoland commented 4 years ago

Usually, we test for MSYSTEM if it is in os.environ but I don't see anything like that here: https://www.python.org/dev/peps/pep-0508/#environment-markers

ulfalizer commented 4 years ago

Got MSYS2 installed now.

Usually, we test for MSYSTEM if it is in os.environ but I don't see anything like that here: https://www.python.org/dev/peps/pep-0508/#environment-markers

Yeah, I don't see a way to identify MSYS2 with environment markers either. Bit messy that it doesn't distinguish itself from the "official" Python. Would be nice if there was an "install if compatible package available" option in setuptools/wheels, but I didn't see anything like that.

Looking at https://github.com/msys2/msys2/wiki/Terminals, MSYS2 doesn't use the regular Windows Console API for its terminal (it uses Mintty), so it won't be compatible with windows-curses. Might be possible to get Python's curses working with it though, since it comes with an ncurses package by default (I ran into the same _curses.error: setupterm: could not find terminfo database error you did from some testing though).

I could drop windows-curses from install_requires in setup.py and require it to be installed manually, but since people might depend on it being automatically installed, it might be a bit mean.

I'll dig some more to see if I can find a way to detect MSYS2 or only install windows-curses if possible, but seems messy so far.

Have you considered just copying Kconfiglib into ESP-IDF by the way? It's the solution I recommend in general for third-party dependencies that don't have any complicated dependencies themselves, because it's so stupid that it can't break. I'm a bit stone-age though. :)

dobairoland commented 4 years ago

Yes, unfortunately it is very messy and inconvenient either for Windows console users or MSYS users.

Thank you for looking into this.

I ran into the same _curses.error: setupterm: could not find terminfo database error you did from some testing though

You can get a little further if you set the TERMINFO environment variable.

Have you considered just copying Kconfiglib into ESP-IDF by the way?

Yes, we are including it now but would like to install by pip in the future. We are including also menuconfig.py and that why we ran into the issue how to support both Windows console and MSYS.

ulfalizer commented 4 years ago

Maybe I could make a major version bump and drop the windows-curses dependency later, if it gets too messy.

Back on the grind atm, but I'll think over it.

dobairoland commented 4 years ago

Maybe a sufficient solution would be for now to make windows-curses to be installable in MSYS but not installing any wheel at all. But I'm not sure if it is possible...

ulfalizer commented 4 years ago

Fixed by removing the windows-curses dependency, in https://github.com/ulfalizer/Kconfiglib/commit/068bc48cb60bac7b7c241e313b60e7f7707c07f3.

menuconfig now prints a hint re. installing windows-curses if curses can't be imported on Windows (though it won't work on MSYS2).