GNOME Bugzilla – Bug 688024
port gnome-sudoku to python3
Last modified: 2013-10-28 13:19:10 UTC
it's actually ok, a few things here and there. I'm doing it and will submit a patch.
Created attachment 228858 [details] [review] 0001-gnome-sudoku-python-2to3-port.patch * Loads * Generates games * Saves in-progress * Prints games Most of the port is automatic using 2to3 tool. I had to tweak s/file/open calls and whether to open files as text or bytes. Also had to teak one compare call. Changed the autoconf / shebang to python 3. Since it's interpreted code, please test other code-paths and check: * that it doesn't crash * no new / extra / unexpected warnings are printed Also it would be nice to test: * loading python2 saved games in python3 As I didn't test that. But the patch does make the game run under pythone \0/
Hi, what is the status of this? It would be nice if we can have this merged
Review of attachment 228858 [details] [review]: Thanks for your work on this, Dmitrijs. I'll merge it after we branch gnome-3-10.
better late than never =) not sure how much this patch suffered from bit rot.
Not much has happened except on the Vala branch. There will be a minor conflict or two, but it should be nearly as safe as it was when you posted it.
Created attachment 256548 [details] [review] gnome-sudoku python 2to3 port.
I did a very quick rebase of your patch onto master. Here's what I get when I try to run: [mcatanzaro@victory-road gnome-sudoku]$ jhbuild run gnome-sudoku Traceback (most recent call last):
+ Trace 232576
from lib.gnome_sudoku import start_game
During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/mcatanzaro/jhbuild/install/bin/gnome-sudoku", line 21, in <module> from gnome_sudoku.gnome_sudoku import start_game ImportError: No module named 'gnome_sudoku.gnome_sudoku' I'm not very familiar with Python imports, so I'm not sure how to fix it. As a heads-up, there's a good chance of the Vala port being merged this cycle, so this might never see a stable release. I was only checking this out because I thought it might be easy to apply.
There is a small bug: http://paste.ubuntu.com/6309721/ I have no idea about your jhbuild, or how broken it is. There is actually no need to install anything: $ cd src/ $ ./gnome-sudoku In python3 install paths should be something like: /usr/bin/gnome-sudoku /usr/lib/python3/dist-packages/gnome_sudoku/*.py From the snippet you provide it's impossible to tell what's your python path, environmenal variables and full install. How is Vala port suppose to excite me at all??????? So gnome announces GNOME3 porting goal, I do the port, it's ignored for ever, and then it's rewritten in vala....... Honestly, I shall not ever write any code for GNOME.
Created attachment 258195 [details] [review] gnome-sudoku python 2to3 port.
Review of attachment 258195 [details] [review]: Applied in the Ubuntu package and uploaded into development series, thus closing https://bugs.launchpad.net/ubuntu/+source/gnome-sudoku/+bug/1078720 . https://launchpad.net/ubuntu/+source/gnome-sudoku/1:3.8.1-1ubuntu1
Sorry Dmitrijs. Sudoku was without active maintainership until very recently. Your help with the migration away from Python 2 is very much appreciated. (In reply to comment #8) > There is a small bug: > http://paste.ubuntu.com/6309721/ Fixed above, thank you! I can run the game just fine from the source directory; that's not the issue. The problem is that it does not work when run installed, as it does without this patch. > In python3 install paths should be something like: > /usr/bin/gnome-sudoku > /usr/lib/python3/dist-packages/gnome_sudoku/*.py > > From the snippet you provide it's impossible to tell what's your python path, > environmenal variables and full install. Within a jhbuild shell, I see PYTHONPATH=/home/mcatanzaro/jhbuild/install/lib/python2.7/site-packages Changing that forcibly gets me a bit farther, but leads to an entirely different error, so I guess we're not supposed to do that: PYTHONPATH=/home/mcatanzaro/jhbuild/install/lib/python2.7/site-packages/:/home/mcatanzaro/jhbuild/install/lib/python3.3/site-packages/ gnome-sudoku Traceback (most recent call last):
+ Trace 232671
start_game()
from . import main
import gi
from ._gi import _API, Repository
It needs to "just work"; whether that requires changes in jhbuild or in gnome-sudoku is unfortunately beyond me. Silly imports.
It works fine as installed using a .deb package. that python path is wrong, as it's using incompatible python2.7. You need to point your pythonpath in jhbuild to python3 instead. Python2.7 and Python3 are two different languages.... (incompatible API and ABI). I don't know how jhbuild detects / sets the pythonpath, but you need to instruct your environment to use python3. Please seek help from jhbuild maintainers. When installed like this: drwxr-xr-x root/root 0 2013-10-27 02:57 ./ drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/ drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/lib/ drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/lib/python3/ drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/lib/python3/dist-packages/ drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/ -rw-r--r-- root/root 1761 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/pausable.py -rw-r--r-- root/root 32964 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/gsudoku.py -rw-r--r-- root/root 8737 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/printing.py -rw-r--r-- root/root 7546 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/tracker_info.py -rw-r--r-- root/root 2125 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/defaults.py -rw-r--r-- root/root 34 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/defs.py -rw-r--r-- root/root 2296 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/colors.py -rw-r--r-- root/root 494 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/gnome_sudoku.py -rw-r--r-- root/root 39412 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/main.py -rw-r--r-- root/root 33690 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/sudoku.py -rw-r--r-- root/root 11692 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/game_selector.py -rw-r--r-- root/root 4319 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/dancer.py -rw-r--r-- root/root 24 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/__init__.py -rw-r--r-- root/root 10446 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/saver.py -rw-r--r-- root/root 2785 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/timer.py drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/gtk_goodies/ -rw-r--r-- root/root 24 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/gtk_goodies/__init__.py -rw-r--r-- root/root 9354 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/gtk_goodies/dialog_extras.py -rw-r--r-- root/root 20357 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/gtk_goodies/Undo.py -rw-r--r-- root/root 1432 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/simple_debug.py -rw-r--r-- root/root 2073 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/dialog_swallower.py -rw-r--r-- root/root 29168 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/number_box.py -rw-r--r-- root/root 5337 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/sudoku_thumber.py -rw-r--r-- root/root 22788 2013-10-27 02:57 ./usr/lib/python3/dist-packages/gnome_sudoku/sudoku_maker.py drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/games/ -rwxr-xr-x root/root 563 2013-10-27 02:57 ./usr/games/gnome-sudoku drwxr-xr-x root/root 0 2013-10-27 02:58 ./usr/share/ drwxr-xr-x root/root 0 2013-10-27 02:57 ./usr/share/applications/ -rw-r--r-- root/root 436 2013-10-27 02:57 ./usr/share/applications/gnome-sudoku.desktop gnome-sudoku rans correctly without setting PYTHONPATH at all. From your traceback it doesn't seem like you have dependencies compiled and installed inside jhbuild, specifically python-gi compiled for python3. Maybe you can seek more help from people who made the python3 goal and made it work for their modules with jhbuild? https://wiki.gnome.org/GnomeGoals/Python3Porting Regards, Dmitrijs.
Apperantly jhbuild is crap with python3. See: https://bugzilla.gnome.org/show_bug.cgi?id=688353 https://bugzilla.gnome.org/show_bug.cgi?id=688070 And it doesn't look like a blocker for other modules to getting ported to python3.
Thanks for investigating. I don't feel like holding up this bug due to that issue, since there's nothing wrong on the gnome-sudoku end. I've pushed your patch; it will be included in 3.11.2. Thanks again! Attachment 258195 [details] pushed as da048b6 - gnome-sudoku python 2to3 port.