Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Port to python 3 and GTK3 #56

Closed
wants to merge 24 commits into from

Conversation

nikolaik
Copy link

@nikolaik nikolaik commented Mar 22, 2020

This is a WIP of a basic port from the GTK2 UI to GTK3. This also moves to python 3 only. I've tried to keep the changes as minimal as possible, leaving out formatting with PEP8/black, travis tests and refactoring.

Note that I am pretty unfamiliar with gtk, so be kind. I have not been able to test on mac yet, and will need help on windows. Any feedback is welcome 😊

Summary of changes:

  • Add basic gtk test with pytest.
  • Start using gobject style imports of gtk, pango, glib, etc.
  • Remove some python 2 specifics like OrderedDict backport and use of xrange.
  • Fix usage of map and filter in python 3 and wrap them in list().
  • Fix relative imports in python 3.
  • Updated .glade file to gtk 3.0+.
  • In FAHControl, get_visible_dialogs, store_dimensions and preferences_dialog_init now works
  • Use bytes where appriate and strings elsewhere in connection handling.
  • Use quote from urllib.parse
  • Replaced sys.maxint with sys.maxsize
  • Removed FAHControl.set_proc_name

TODO:

  • Icon is garbled
  • Migrate preference 'donor_stats_link' and one more to Gtk.ComboBoxText Initilize donor_stats_link prefs properly
  • Linux build, deb
  • Update packaging with correct deps
  • Linux build, rpm
  • MacOS build
  • Windows build

- Add basic gtk test with pytest
- Start using gobject style imports of gtk, pango, glib, etc
- Remove some py2 specifics like OrderedDict backport and use of xrang
- Fix usage of map and filter in python 3
- Fix relative imports in python 3
-
Opened with glade 3.16, changed toolkit version to 3.0 and saved.
get_visible_dialogs, store_dimensions and preferences_dialog_init
now works
- Use bytes where appriate and strings elsewhere in connection handling.
- More gobject style imports
- Wrap lazy map()s and filter()s in list()
- use quote from urllib.parse
- sys.maxint is gone in py3
@nikolaik nikolaik mentioned this pull request Mar 23, 2020
@guystreeter
Copy link

I am very familiar with GTK 3 in Python 3. Can I help?

@nikolaik
Copy link
Author

nikolaik commented Mar 25, 2020

@guystreeter Yes you can 😊 I'll add you as a collaborator on my forked repo. If you want look at the FIXME(nikolaik) things, the TODOs in the PR description or anything else you find bad or broken, that would help a lot!

I have researched a bit on how to package python gtk3 apps for windows, mac and linux and found that the gaphor project is pretty successful (found from this list). I think I'll have a look at getting things building on macos next.

@guystreeter
Copy link

guystreeter commented Mar 25, 2020 via email

@nikolaik
Copy link
Author

nikolaik commented Mar 25, 2020

Cool. I'm a Linux geek (Fedora/Red Hat). I don't know much about Windows or Mac OS, but I do have one of each available. I'm well versed in rpm packaging, and have made a few simple deb packages.

Let's work together on the linux packaging then 😊

(...) I've written Gtk 2/3 applications in Python 2/3 from scratch, so converting the program to Gtk 3 and Python 3 is probably where I can best help.

Perfect 👌

I have to say that the current code style is painful to look at. I'd really like to reformat it :).

Agreed. To keep the scope of this PR down and to make it easier to review, I think code style and formatting should be left as a followup PR. As I see it, the most important contribution would be to make stuff run on a relative modern setup of Linux, to help other people contribute.

@guystreeter
Copy link

I've pushed 3 commits.
One corrects an encoding problem in the configuration dialog.
One may not be specific to Python 3. Could just be a corner case I encountered, but it fixes an exception handling problem.
The last one corrects the display of the icons. I think I got all of them, let me know if there are still some wonky ones.

In Python 3, map() doesn't do anything until its result is iterated.
@guystreeter
Copy link

I've pushed some more changes.
The comboboxes in the preference dialog initialize correctly.
The icon on the Viewer button shows up now.
The windows no longer get larger every time you start the application.

@jasontitus
Copy link

What is the best way to test this branch? Do I need to build and install it? Or is there a way to run it from the build directory without installing.

Keep up the good work!

@guystreeter
Copy link

You can run it from source.

 git clone https://github.com/nikolaik/fah-control.git
 cd fah-control
 git checkout feature/gtk3-python3
 ./FAHControl

Just to be sure you're only using the new stuff, I'd suggest you un-install the FAHControl package if you have it.

@Locke
Copy link

Locke commented Mar 28, 2020

You can run it from source.

 git clone https://github.com/nikolaik/fah-control.git
 cd fah-control
 git checkout feature/gtk3-python3
 ./FAHControl

I think there is a step missing. After a fresh clone I cannot start FAHControl:

 Traceback (most recent call last):
  File "./FAHControl", line 25, in <module>
    from fah import FAHControl, single_app_addr
  File "/data/git/fah-control/fah/__init__.py", line 24, in <module>
    from .Version import *
ModuleNotFoundError: No module named 'fah.Version'

I found out that this file is ignored from git as it is generated by setup.py. However, after I manually created that file I could start FAHControl on debian/buster.

@nikolaik
Copy link
Author

@guystreeter excellent work! I'll test the changes this weekend. Hopefully will have time to look at building on mac soon.

@guystreeter
Copy link

You can run it from source.

 git clone https://github.com/nikolaik/fah-control.git
 cd fah-control
 git checkout feature/gtk3-python3
 ./FAHControl

I think there is a step missing. After a fresh clone I cannot start FAHControl:

 Traceback (most recent call last):
  File "./FAHControl", line 25, in <module>
    from fah import FAHControl, single_app_addr
  File "/data/git/fah-control/fah/__init__.py", line 24, in <module>
    from .Version import *
ModuleNotFoundError: No module named 'fah.Version'

I found out that this file is ignored from git as it is generated by setup.py. However, after I manually created that file I could start FAHControl on debian/buster.

Yes, sorry I forgot about that step. You can just run

python3 setup.py build

to create that file. Your app won't show the correct version number, but it will still run.

@guystreeter
Copy link

guystreeter commented Mar 28, 2020

While I'm waiting for testing of the source changes, I'll start updating the rpm packaging.

@bhack
Copy link

bhack commented Mar 28, 2020

I suppose that https://github.com/FoldingAtHome/fah-control/blob/master/stdeb.cfg Is outdated.

Remove is_old_gtk and it's usage
Remove osx_window_focus_workaround since it's probably not needed
anymore with gtk3
@MasterCATZ
Copy link

well it seems to be working for me Ubuntu 19.10 , glad to finally have the apt errors not showing
how can I rebuild this into a deb installer so package manager can launch it again ?

@PokefanSean
Copy link

I am willing to contribute.

@nikolaik
Copy link
Author

nikolaik commented Apr 5, 2020

I've been looking at building for debian and have an experimental branch build-linux which uses circleci to build. If you want to try out the new deb you'll find that as an artifact of the circleci job here (link to deb).

  • Does it work for you?

There are a few remaining known issues with it:

  • package name should be fahcontrol like before
  • After downloading and running dpkg -I python3-fahcontrol_8.0.0-1_all.deb I see fewer dependencies than in stdeb.cfg, namely Depends: python3-gi, python3:any (>= 3.5~) instead of Depends: python3-gi-cairo, gir1.2-gtk-3.0.

Update: Fixed the issues and made another build.

On the build side of things I see the next steps as

  • Reading the version from tags (instead of hardcoded version to v8.0.0).
  • Upload the deb to a github release.

@guystreeter
Copy link

I haven't done anything with the rpm build yet. I was hoping to hear there was already a .spec file somewhere. It isn't difficult to create a new one, and I can do that. I remain confused, though, about the mention of RPM in the scripts SConstruct and rpm/build. Perhaps they are artifacts.

@brjhaverkamp
Copy link

Hi Nikolaik,

I tried the new deb package on Ubuntu 19.10. It installed perfectly:
root@shark:/home/bert/Downloads# dpkg -i fahcontrol_8.0.0-1_all.deb
Selecting previously unselected package fahcontrol.
(Reading database ... 345286 files and directories currently installed.)
Preparing to unpack fahcontrol_8.0.0-1_all.deb ...
Unpacking fahcontrol (8.0.0-1) ...
Setting up fahcontrol (8.0.0-1) ...
root@shark:/home/bert/Downloads#

Also the usage looks good. But this is the first time I started fahcontrol. So I am not fully qualified to judge the functionalitty:-)

Great work though! Thx

Bert

@Huffleme
Copy link

Installed on Siduction, no problems. I put in the number for my team, that was used in the /etc/fahclient/config.xml, replacing the team name that had been there, so it's definitely doing something. I didn't see anything in there about the Covid-19 setting I'd enabled, though. Perhaps that's held in FAHControl.db?
Thanks for getting this going.

Pip

@bhack
Copy link

bhack commented Apr 24, 2020

Do we have a duplicated effort #70?

@guystreeter
Copy link

I have added an RPM .spec file and a script to build RPM packages. I tested it on Fedora 31.

Depends: python-gnome2, python-support | dh-python
XS-Python-Version: >= 2.4
Depends: python3-gi, python3-gi-cairo, gir1.2-gtk-3.0 | dh-python
X-Python3-Version: >= 3.5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI: X-Python3-Version is optional. https://www.debian.org/doc/packaging-manuals/python-policy/module_packages.html#specifying_versions

Only o-o-stable uses < 3.5, so it can be removed.

ffissore pushed a commit to cdberkstresser/fah-control that referenced this pull request Apr 30, 2020
ffissore pushed a commit to cdberkstresser/fah-control that referenced this pull request Apr 30, 2020
ffissore pushed a commit to cdberkstresser/fah-control that referenced this pull request Apr 30, 2020
ffissore pushed a commit to cdberkstresser/fah-control that referenced this pull request Apr 30, 2020
@moshe742
Copy link

Will it be possible to be PEP8 compliant? it will help the project be more consistent with other projects of python and easier to read.
I would love to help with the effort of porting to python3 and the PEP8 one

@Davilink
Copy link

any progress ?

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

Successfully merging this pull request may close these issues.