Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Support #25

Open
cfangmeier opened this issue Apr 27, 2019 · 26 comments
Open

Windows Support #25

cfangmeier opened this issue Apr 27, 2019 · 26 comments

Comments

@cfangmeier
Copy link
Owner

It would be nice if there was a nice way to install TUIJam on Windows. Naively I tried doing just a

pip install tuijam

But the dependent version of scrypt failed to compile. I changed to the latest version and that worked. Next, there is a problem with PyGObject which requires, from what I can tell, the GTK+ runtime to be installed for it to work properly. According to the docs installing this involves installing mingw, which I'd really like to avoid. One alternative would be to simply drop the use of PyGObject on windows since it's just used for the external control and on windows maybe a different system that GObject is preferred anyway.

@t1meshift
Copy link
Contributor

AFAIK Windows 10 has native Media Playback API, but I haven't seen any Python bindings for it.
For example, there is a native module for NodeJS for that purpose: https://github.com/NodeRT/NodeRT. GPMDP uses it, seems like it's not that complicated: https://github.com/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/blob/master/src/renderer/windows/GPMWebView/playback/systemMediaService/win10.js

The main problem is that is not for Python, so we have to write our own UWP API binding.

@t1meshift
Copy link
Contributor

Also, have found out that python-mpv works with Windows not so smoothly as it does on Unix-like systems, we need to put a workaround on installation process: jaseg/python-mpv#60 (comment)

@longtomjr
Copy link

Just a note - to build on windows you will need to install the C++ build tools for pycairo. Dont have a successfull build yet - but will keep you updated

@longtomjr
Copy link

I decided to not try going down the mingw route, and to see what it will take to write a wrapper for the windows media playback api in python

@longtomjr
Copy link

longtomjr commented Aug 19, 2019

So from some quick poking around. The ideal would be to build a generator on top of NodeRT's templates to generate Python bindings instead of C# bindings.

The other option is to generate the JS/TS code and see if it is easier to convert it by hand and then maintain it.

Another option:
https://docs.microsoft.com/en-us/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2019

With:
https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt

@longtomjr
Copy link

Ok, so turning off the media integration - it fails because the loop defined for the uirwid loop is not there.

To make this work in windows, we first have to get urwid working. There is several topics related to it here:

urwid/urwid#240

@cfangmeier
Copy link
Owner Author

Hi @longtomjr, Thanks for looking into this. Is there any way to leverage the linux subsystem for windows 10 to get around any of these issues?

@longtomjr
Copy link

Ok - so urwid is built heavily using events, sockets and file descriptors. It will take some work to get it working smoothly with windows without implementing a POSIX layer.

@longtomjr
Copy link

longtomjr commented Aug 19, 2019

@cfangmeier I think the WSL should just work with this out of the box - have not tried though. It would make sense to use WSL if you want to - but I would like to see if there is a way to build this for windows and to work in powershell.

I have to use windows at work - and I have a rabid antivirus making even things like git slow, so having the WSL running when there is a antivirus that monitors every file bieng opened etc. would be a bit of a nightmare.

@longtomjr
Copy link

I have the feeling that it might be easier and quicker to just rewrite the ui layer in something that is cross platform. Is there any specific reasons urwid was chosen? (Also, is there a irc [or similar] channel it might be easier to discuss this on?)

@cfangmeier
Copy link
Owner Author

urwid was chosen because it's a nice wrapper around doing lower level curses programming, and I initially had no plans for making this work on anything other than linux. Do you know of a cross-platform alternative?

I'm not really an IRC user, but am willing to give it a go.

(also, I just noticed that the old style login has broken and I need to update to the new oauth based one, but that's another issue)

@longtomjr
Copy link

hehe - yep, saw that too. I cannot vouch for any alternatives (have not used them) but found the folowing:

https://npyscreen.readthedocs.io/introduction.html
https://github.com/pfalcon/picotui
https://github.com/prompt-toolkit/python-prompt-toolkit
https://github.com/jquast/blessed
and python's curses library.

Don't know the cross platform support of any of the above, but they all seem to be maintained to some extent.

@longtomjr
Copy link

longtomjr commented Aug 19, 2019

I made a temp channel on freenode #tuijam.

@longtomjr
Copy link

longtomjr commented Aug 19, 2019

@cfangmeier If we use the curses_display Screen without an event loop, we might have windows support. Got it working using the curses_display. Color might need reconfig - but it might be a useful fallback for win users.

There is other issues as well - but it seems to be something to work from

@longtomjr
Copy link

longtomjr commented Aug 19, 2019

I have to bounce now - gotta sleep, but will tinker a bit more tomorrow. Also, should get my environment set up, new install so only raw vim and pyenv so far. Need to get everything configured and my dotifiles in place before I do more dev work.

Will do some more testing on windows tomorrow at work during lunch.

@longtomjr
Copy link

longtomjr commented Aug 20, 2019

Ok, got it working on windows - had to tweak urwid a bit, the graphics is not correct, but everything looks workable if I use curses.

Music plays, search works, music stops etc. Performance is really bad though, but that might be my env

Will get a branch working tomorrow - have to do other things now and this evening.

@cfangmeier
Copy link
Owner Author

that's great! looking forward to a PR.

@longtomjr
Copy link

Got busy at work - will try to get a WIP PR in this weekend. There is still some testing and other work that needs to be done. Cannot get the performance ready and there is some other issues that I will investigate once I get a bit more time. Will to to get the code visible though, so that people can start discussing it.

@longtomjr
Copy link

Still here, and still working on it when I have time. Trying to make it work without having to change the source of urwid if posible. Meanwhile - here is a link to a rice including tuijam https://forum.manjaro.org/t/august-aberrations-2019-screenshots/96987/156?u=longtomjr

@cfangmeier
Copy link
Owner Author

Hi @longtomjr, have you made any progress on this? No hurry, just looking forward to having this implemented.

@longtomjr
Copy link

@cfangmeier Still here. Was having issues with getting it working reliably. I have been extremely busy lately - got a lot of things happening. Sorry - will get back to this as soon as I can.

@longtomjr
Copy link

longtomjr commented May 19, 2020

@cfangmeier Hey - sorry, will not be able to tackle this since I have not been on a windows machine for a while. The issue is the curses display backend used. Sorry.

@cfangmeier
Copy link
Owner Author

Hi @longtomjr . No worries. Thanks for the efforts you've put into investigating this feature. Hopefully someone else (possibly myself) can pick up the torch.

@longtomjr
Copy link

If you have any questions, feel free to ask. I had to go into urwid's internals and use a different library to do the rendering. I think the biggest issue were getting urwid to play along with windows.

@cfangmeier
Copy link
Owner Author

Sure, any details you can share would be helpful. For example, how invasive were your changes to urwid, and is it something that we could reasonably monkeypatch in? And what was the different library you tried for the rendering?

@longtomjr
Copy link

I have had a look, and cannot seem to find the code changes I did. Some of the details are a bit fuzzy. I know that there were several layers of incompatibility. There were some calls in urwid that were not compatible. I remember something about having to switch out the urwid window that were used by tuijam.

I think what I did, and what might be a good approach, might be to run the urwid examples in windows, and see if they work / what it takes to get them working. Also, if you run into anything in particular, feel free to ask, an error message or more specific issue might jog my memory.

When I have time later, I will see if I can find the changes I did, and see if there is anything useful. Will post if I find anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants