cfangmeier / tuijam

A fancy TUI client for Google Play Music
MIT License
129 stars 9 forks source link

Windows Support #25

Open cfangmeier opened 5 years ago

cfangmeier commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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: https://github.com/jaseg/python-mpv/issues/60#issuecomment-352719773

longtomjr commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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:

https://github.com/urwid/urwid/issues/240

cfangmeier commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

I made a temp channel on freenode #tuijam.

longtomjr commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

that's great! looking forward to a PR.

longtomjr commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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

longtomjr commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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