sugarlabs / sugar

Sugar GTK shell
GNU General Public License v3.0
255 stars 241 forks source link

Port to Python 3 #787

Closed quozl closed 4 years ago

quozl commented 6 years ago

Port Sugar to Python 3 and the Sugar Toolkit for GTK+ 3, providing a Python 3 implementation of this package with no Python 2 dependencies.

Requires most of https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/382, most of https://github.com/sugarlabs/sugar-datastore/issues/7 and some of https://github.com/sugarlabs/hello-world-fork/issues/2 to be completed.

Progress goals:

this is an issue for tracking a major project which is larger than one person's contributions, so developers should make pull requests to satisfy any of these items, and not ask to own the issue.

ghost commented 5 years ago

Hi.I'm interested in working on this(starting with goal one) but I wanted to ask that do I have to make only one PR for one goal or are multiple PRs for a single goal acceptable.

quozl commented 5 years ago

Thanks for your interest. We have a pull request for some of this, see https://github.com/sugarlabs/sugar/pull/805, linked above. Please test the code in the pull request, along with the corresponding code in all other dependencies, and let us know. See the other Python 3 projects linked from the https://github.com/sugarlabs organisation.

This is not an easy one. You'll need to budget several weeks. You will need to solve a few hundred systems integration problems along the way. If you need us to help you solve these problems, then sorry, you're not really the right person to add to our progress on this task.

manddy commented 5 years ago

@quozl which framework do you use for automated testing in this project?

quozl commented 5 years ago

@manddy, there is no automated testing of Sugar or activities. Over past ten years it has been suggested a few times, but nobody has completed more than a brief attempt. Our advice to reviewers includes testing.

GauthamSks commented 5 years ago

I went through #805 [0] and found that a lot of the files in src/jarabe has already been changed. So only the rest of the files needs to be changed right?

quozl commented 5 years ago

@GauthamSks, see the opening comment in this issue for a breakdown of the progress goals in this issue. Also included are the dependent issues that must be solved to some extent first.

If there's something I've missed, let me know and I'll edit the opening comment accordingly.

bhulsken commented 5 years ago

I have built fedora (29) RPMS to do some testing (if you're interested, you can find rpm and src.rpm at: https://steadydecline.net/public/sugar-python3/) . While the toolkit and such work, and most activities run (both python2 as well as python3 ones), sugar itself does not, due to a dependency on gwebsockets (sugar -> jarabe -> gwebsockets )

gwebsockets hasn't been maintained since 2014, and currently does not support python3

what is your plan? Port gwebsockets to python 3? Or just like telepathy, remove the dependency and use gi.repositories directly?

I'm asking, as I might spend a bit of time on porting gwebsockets, but wouldn't want to waste my time if you've decided to go another route.

P.S. this is the error in shell.log:

Traceback (most recent call last): File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/lib/python3.7/site-packages/jarabe/main.py", line 83, in from jarabe import apisocket File "/usr/lib/python3.7/site-packages/jarabe/apisocket.py", line 26, in from gwebsockets.server import Server ModuleNotFoundError: No module named 'gwebsockets'

bhulsken commented 5 years ago

Well.. since the port seemed trivial, I've given porting gwebsocket a shot, please see https://steadydecline.net/public/sugar-python3/ for a full set of RPM and .src.rpm that should lead to a running sugar desktop.

Sugar starts for me now with gwebsockets-python3, and the Python 3 port of Browse works, the Python 2 Physics activity works as well... some others (e.g. Speak) seem broken. And there's still quite a bit of chatter in shell.log about porting issues... see below.

I've submitted the python3 port of gwebsockets to redhat bugzilla, let's see if they update it..

----------- shell.log for a quick session... quite a few string decode issues and others due to porting issues -------------


failed to open /usr/lib64/dri/hybrid_drv_video.so
Not using hybrid_drv_video.so
Not using hybrid_drv_video.so
/usr/lib/python3.7/site-packages/jarabe/main.py:341: PyGIDeprecationWarning: Since version 3.11, calling threads_init is no longer needed. See: https://wiki.gnome.org/PyGObject/Threading
  GLib.threads_init()
/usr/lib/python3.7/site-packages/jarabe/main.py:249: PyGIDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "schema" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  settings = Gio.Settings('org.sugarlabs.date')
/usr/lib/python3.7/site-packages/jarabe/main.py:256: PyGIDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "schema" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  settings = Gio.Settings('org.sugarlabs.font')
/usr/lib/python3.7/site-packages/jarabe/main.py:270: PyGIDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "schema" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  g_mode = Gio.Settings('org.sugarlabs.system.proxy').get_string('mode')
Traceback (most recent call last):
  File "/usr/lib64/python3.7/site-packages/dbus/connection.py", line 604, in msg_reply_handler
    reply_handler(*message.get_args_list(**get_args_opts))
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 298, in __get_devices_reply_cb
    self._check_device(dev_o)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 317, in _check_device
    self._box.add_adhoc_networks(device)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 552, in add_adhoc_networks
    self._adhoc_manager = get_adhoc_manager_instance()
  File "/usr/lib/python3.7/site-packages/jarabe/model/adhoc.py", line 35, in get_adhoc_manager_instance
    _adhoc_manager_instance = AdHocManager()
  File "/usr/lib/python3.7/site-packages/jarabe/model/adhoc.py", line 76, in __init__
    self._add_connection(channel)
  File "/usr/lib/python3.7/site-packages/jarabe/model/adhoc.py", line 199, in _add_connection
    settings.wireless.ssid = dbus.ByteArray(ssid)
TypeError: string argument without an encoding
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 506, in _ap_props_changed_cb
    self._add_ap_to_network(ap)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 476, in _add_ap_to_network
    icon.set_filter(self._query)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/networkviews.py", line 408, in set_filter
    normalized_name = normalize_string(self._display_name.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 506, in _ap_props_changed_cb
    self._add_ap_to_network(ap)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 476, in _add_ap_to_network
    icon.set_filter(self._query)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/networkviews.py", line 408, in set_filter
    normalized_name = normalize_string(self._display_name.decode('utf-8'))
1566148473.024936 WARNING root: Activity bundle /home/julia/Activities/Musicpainter.activity does not specify a license
1566148473.051665 WARNING root: Activity bundle /home/julia/Activities/SpaceWar.activity does not specify a license
1566148473.084297 WARNING root: Activity bundle /home/julia/Activities/Tessellations.activity does not specify a license
1566148473.113232 WARNING root: Activity bundle /home/julia/Activities/Fractionauts.activity does not specify a license
1566148473.138590 WARNING root: Activity bundle /home/julia/Activities/PJ.activity does not specify a license
1566148473.161572 ERROR root: ATTENTION: service_name property in the activity.info file is deprecated, should be changed to bundle_id
1566148473.163107 WARNING root: Activity bundle /home/julia/Activities/Tuxmath.activity does not specify a license
1566148473.242804 WARNING root: Activity bundle /home/julia/Activities/SuperChef.activity does not specify a license
1566148473.299110 WARNING root: Activity bundle /home/julia/Activities/Pacman.activity does not specify a license
1566148473.428368 WARNING root: Activity bundle /home/julia/Activities/Domino.activity does not specify a license
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 506, in _ap_props_changed_cb
    self._add_ap_to_network(ap)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 476, in _add_ap_to_network
    icon.set_filter(self._query)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/networkviews.py", line 408, in set_filter
    normalized_name = normalize_string(self._display_name.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
/usr/lib64/python3.7/site-packages/gi/overrides/Gtk.py:1641: Warning: g_value_transform: assertion 'G_IS_VALUE (src_value)' failed
  return _Gtk_main(*args, **kwargs)
/usr/lib64/python3.7/site-packages/gi/overrides/Gtk.py:1641: Warning: unable to set property 'buddy' of type 'PyObject' from value of type '(null)'
  return _Gtk_main(*args, **kwargs)
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/journal/listmodel.py", line 166, in do_get_value
    metadata = self._result_set.read()
  File "/usr/lib/python3.7/site-packages/jarabe/journal/model.py", line 152, in read
    entries, self._total_count = self.find(query)
  File "/usr/lib/python3.7/site-packages/jarabe/journal/model.py", line 226, in find
    byte_arrays=True)
  File "/usr/lib64/python3.7/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib64/python3.7/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Python.TypeError: Traceback (most recent call last):
  File "/usr/lib64/python3.7/site-packages/dbus/service.py", line 707, in _message_cb
    retval = candidate_method(self, *args, **keywords)
  File "/usr/lib/python3.7/site-packages/carquinyol/datastore.py", line 400, in find
    return self._find_all(query, properties)
  File "/usr/lib/python3.7/site-packages/carquinyol/datastore.py", line 425, in _find_all
    uids = uids[offset:offset + limit]
TypeError: slice indices must be integers or None or have an __index__ method

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/journal/listview.py", line 425, in __select_set_data_cb
    uid = tree_model[tree_iter][ListModel.COLUMN_UID]
  File "/usr/lib64/python3.7/site-packages/gi/overrides/Gtk.py", line 1126, in __getitem__
    return self.model.get_value(self.iter, key)
TypeError: unknown type (null)
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/journal/listmodel.py", line 166, in do_get_value
    metadata = self._result_set.read()
  File "/usr/lib/python3.7/site-packages/jarabe/journal/model.py", line 152, in read
    entries, self._total_count = self.find(query)
  File "/usr/lib/python3.7/site-packages/jarabe/journal/model.py", line 226, in find
    byte_arrays=True)
  File "/usr/lib64/python3.7/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib64/python3.7/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Python.TypeError: Traceback (most recent call last):
  File "/usr/lib64/python3.7/site-packages/dbus/service.py", line 707, in _message_cb
    retval = candidate_method(self, *args, **keywords)
  File "/usr/lib/python3.7/site-packages/carquinyol/datastore.py", line 400, in find
    return self._find_all(query, properties)
  File "/usr/lib/python3.7/site-packages/carquinyol/datastore.py", line 425, in _find_all
    uids = uids[offset:offset + limit]
TypeError: slice indices must be integers or None or have an __index__ method

/usr/lib64/python3.7/site-packages/gi/overrides/Gtk.py:1641: Warning: unable to set property 'text' of type 'gchararray' from value of type '(null)'
  return _Gtk_main(*args, **kwargs)
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/model/shell.py", line 624, in _window_opened_cb
    home_activity.add_window(window, is_main_window(window,
AttributeError: 'NoneType' object has no attribute 'add_window'
1566148516.760332 ERROR dbus.proxies: Introspect error on :1.31:/org/laptop/Activity/a31cf2599c594a3b2b7d387c43469fd4bf084225: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying
1566148516.762414 ERROR root: set_active() failed: org.freedesktop.DBus.Error.ServiceUnknown: The name :1.31 was not provided by any .service files
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/model/shell.py", line 624, in _window_opened_cb
    home_activity.add_window(window, is_main_window(window,
AttributeError: 'NoneType' object has no attribute 'add_window'
1566148544.876915 ERROR root: Incorrect bundle
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/journal/misc.py", line 149, in get_bundle
    return get_bundle_instance(file_path)
  File "/usr/lib/python3.7/site-packages/sugar3/bundle/activitybundle.py", line 456, in get_bundle_instance
    _bundle_instances[path] = ActivityBundle(path, translated=translated)
  File "/usr/lib/python3.7/site-packages/sugar3/bundle/activitybundle.py", line 118, in __init__
    info_file = self.get_file('activity/activity.info')
  File "/usr/lib/python3.7/site-packages/sugar3/bundle/bundle.py", line 126, in get_file
    f = six.StringIO(data)
1566148547.389607 ERROR root: set_active() failed: org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying
1566148547.398303 ERROR root: Model for activity id ba1ae2c0797226aa44e8df7765fbc667374ee17f does not exist.
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 506, in _ap_props_changed_cb
    self._add_ap_to_network(ap)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/meshbox.py", line 476, in _add_ap_to_network
    icon.set_filter(self._query)
  File "/usr/lib/python3.7/site-packages/jarabe/desktop/networkviews.py", line 408, in set_filter
    normalized_name = normalize_string(self._display_name.decode('utf-8'))
1566148756.423295 ERROR root: set_active() failed: org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying
1566148790.639280 ERROR root: Launcher was not registered for None

(metacity:1327): metacity-WARNING **: 13:55:48.101: CurrentTime used to choose focus window; focus window may not be correct.
Gdk-Message: 13:55:48.191: metacity: Fatal IO error 11 (Hulpbron is tijdelijk onbeschikbaar) on X server :0.```
quozl commented 5 years ago

Thanks. We had already ported gwebsockets, and tagged 0.5, see repository. Your port seems about the same, except for imports in the test harness, which we haven't got working yet. You might let Fedora know that we have a new version ready.

I've raised separate issues for the other errors. Thanks for testing on Fedora.