After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688024 - port gnome-sudoku to python3
port gnome-sudoku to python3
Status: RESOLVED FIXED
Product: gnome-sudoku
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: GNOME Games maintainers
GNOME Games maintainers
Depends on:
Blocks: python3
 
 
Reported: 2012-11-10 00:28 UTC by Dimitri John Ledkov
Modified: 2013-10-28 13:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-gnome-sudoku-python-2to3-port.patch (52.79 KB, patch)
2012-11-13 09:25 UTC, Dimitri John Ledkov
accepted-commit_after_freeze Details | Review
gnome-sudoku python 2to3 port. (51.74 KB, patch)
2013-10-05 19:32 UTC, Michael Catanzaro
none Details | Review
gnome-sudoku python 2to3 port. (51.58 KB, patch)
2013-10-27 02:09 UTC, Michael Catanzaro
committed Details | Review

Description Dimitri John Ledkov 2012-11-10 00:28:11 UTC
it's actually ok, a few things here and there.
I'm doing it and will submit a patch.
Comment 1 Dimitri John Ledkov 2012-11-13 09:25:16 UTC
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/
Comment 2 Javier Jardón (IRC: jjardon) 2012-12-09 06:55:05 UTC
Hi, what is the status of this?

It would be nice if we can have this merged
Comment 3 Michael Catanzaro 2013-09-05 19:25:51 UTC
Review of attachment 228858 [details] [review]:

Thanks for your work on this, Dmitrijs.  I'll merge it after we branch gnome-3-10.
Comment 4 Dimitri John Ledkov 2013-09-06 09:16:10 UTC
better late than never =) not sure how much this patch suffered from bit rot.
Comment 5 Michael Catanzaro 2013-09-06 12:17:09 UTC
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.
Comment 6 Michael Catanzaro 2013-10-05 19:32:07 UTC
Created attachment 256548 [details] [review]
gnome-sudoku python 2to3 port.
Comment 7 Michael Catanzaro 2013-10-05 19:38:31 UTC
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):
  • File "/home/mcatanzaro/jhbuild/install/bin/gnome-sudoku", line 19 in <module>
    from lib.gnome_sudoku import start_game
ImportError: No module named 'lib'

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.
Comment 8 Dimitri John Ledkov 2013-10-27 01:58:11 UTC
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.
Comment 9 Michael Catanzaro 2013-10-27 02:09:41 UTC
Created attachment 258195 [details] [review]
gnome-sudoku python 2to3 port.
Comment 10 Dimitri John Ledkov 2013-10-27 02:49:58 UTC
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
Comment 11 Michael Catanzaro 2013-10-27 03:09:47 UTC
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):
  • File "/home/mcatanzaro/jhbuild/install/bin/gnome-sudoku", line 23 in <module>
    start_game()
  • File "/home/mcatanzaro/jhbuild/install/lib/python3.3/site-packages/gnome_sudoku/gnome_sudoku.py", line 24 in start_game
    from . import main
  • File "/home/mcatanzaro/jhbuild/install/lib/python3.3/site-packages/gnome_sudoku/main.py", line 5 in <module>
    import gi
  • File "/usr/lib64/python3.3/site-packages/gi/__init__.py", line 27 in <module>
    from ._gi import _API, Repository
ImportError: /usr/lib64/python3.3/site-packages/gi/_gi.so: undefined symbol: pyglib_gil_state_release

It needs to "just work"; whether that requires changes in jhbuild or in gnome-sudoku is unfortunately beyond me. Silly imports.
Comment 12 Dimitri John Ledkov 2013-10-28 09:55:33 UTC
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.
Comment 13 Dimitri John Ledkov 2013-10-28 10:22:15 UTC
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.
Comment 14 Michael Catanzaro 2013-10-28 13:19:07 UTC
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.