|
|
Log in / Subscribe / Register

Showing up for Python in GNOME

By Joe Brockmeier
July 31, 2024

GUADEC

A few years ago, PyGObject—the Python package that provides bindings for GTK and GNOME applications—was not faring particularly well. Several maintainers had left the project and its development was not keeping pace with changes in GTK. At this year's GUADEC, Dan Yeaw presented a talk about the project's decline, improvements in the last year, and his experience getting involved in an undermaintained project.

[Dan Yeaw]

Yeaw said that he worked for Ford Motor Company in functional safety, and part of his job was to do systems modeling to help ensure that "complex systems don't malfunction and cause harm". He wanted to be able to do that with open-source software, which led him to a project called Gaphor, a modeling application written in Python, about six years ago. From there, he got involved in the Python community and helping to "fix pain points" he encountered running Gaphor on Windows. In the past year, he had started contributing to PyGObjects.

Yeaw explained that he felt Python should be a language of choice for writing GNOME applications. Python was easy to learn, he said, and "scales easily with your skill set". It's suitable for kids to pursue their interests and learn just what they need, but it's also used by researchers, students, data scientists, web developers, and many others. His ten-year-old son was already writing simple games with Python, and had embarked on a larger project, making a Pokédex to keep track of Pokémon.

Yeaw also said that it had "never been easier" to build an application for GNOME thanks to applications like Builder, Workbench, and Cambalache. Flatpak, likewise, makes it easy to package them. Python is the perfect "big tent" language that makes it easy for anyone to build applications, but "we need to make sure the GNOME experience with it lives up to this" so all of the people using Python will join the community.

Call to action

The problem was, PyGObject was not living up to this. He referenced a blog post that Emmanuele Bassi wrote at the end of 2022 with a "call to action" for others to get involved in the project. Bassi said that PyGObject was "undermaintained, even after the heroic efforts of Christoph Reiter to keep the fires burning" and needed more people from the Python community to pitch in "if we want Python to be a first class citizen of the ecosystem".

Bassi had three major complaints about the state of PyGObject. First, it was missing support for several GTK4 types, including GtkExpression. Bassi said that "not having access to the expressions API makes writing list widgets incredibly more complicated". Secondly, PyGObject did not have automatic access to the constructing and disposing virtual functions, making it much harder in GTK4 to create and remove child widgets. And, finally, the documentation was spread out over several sites, and missing important components, like a tutorial for GTK4.

The project was running on fumes, with only one primary maintainer (Christoph Reiter) still keeping the project alive. Other major contributors had left the project, which Yeaw pointed out is a natural part of open-source projects. He showed a slide (page six in this presentation) that illustrated the drop off in commits over time.

Challenges getting involved

There's a catch-22 in getting involved in projects that are unmaintained or undermaintained, Yeaw said. When few people—or even a single person—are doing all the work, they have little time to spare to help newcomers get up to speed. Community building, he said, "requires many hands to get involved to help newcomers triage issues, answer questions, and provide support". If the person maintaining the project does not have the time to manage issues or address merge requests, it does not feel welcoming to the new contributors. And then, often, those contributors go where they feel their work will make more of a difference.

It is even worse with GNOME, Yeaw said, because there are extra layers of complexity to figure out. "It kind of feels like GNOME is this walled city, and you're at a gate and trying to knock and there's no one there." Here he gave a shout-out to the recently released GNOME Handbook as a resource to help people get involved.

It should not take someone like Bassi writing a blog post to elicit involvement in a struggling project, Yeaw said. He suggested that the GNOME Foundation or other communities consider ways to track key GNOME projects with metrics and provide community building support for at-risk projects before it becomes a problem.

Getting better

The project has made a number of improvements in the past year, he said. It has made "major inroads" to reducing the number of total issues and outstanding merge requests. The project has closed more than 200 issues to bring the total number down from more than 300 to 175. Although there are still more than he would like, "getting issues in the 100 to 200 range is something that contributors can get their head around. Much more than this can feel overwhelming".

The project has added some of the fundamental types that are used by GTK4 and its related libraries. Yeaw walked through an example of using the Workbench application to create a table that would sort book data. GTK4 provides an easy way to do this by using the Gtk.Expression type, but that had been missing from PyGObject. The implementation to support that had been in the works since 2010, but Arjan Molenaar "brushed it off and brought it home this year".

In addition, the community has been working to centralize the documentation for PyGObject. The project's documentation was, previously, hosted on Read the Docs, which is often home to Python project documentation. The existing documentation, plus a guide by Rafael Mardojai, were re-licensed from the GNU Free Documentation License (GFDL) to LGPL and merged with other documentation on the PyGObject project site.

The project has also modernized the way it builds its API documentation, by moving from GTK-Doc to GI-DocGen, which reuses introspection data generated by GObject-based libraries to generate API references. This means, he said, that previously missing documentation for things such as Gtk.Template were now available, and that the API documentation would require less maintenance in the future.

Another major change that Benjamin Berg had been working on for two years, and which had just landed the week before GUADEC, is initial support for asynchronous I/O (asyncio).

The future

Of course, the work of maintaining a project like PyGObject is never really done. Yeaw had a few things that he expected the project to tackle in the future. The first one he discussed, possibly of lesser interest for LWN readers, is building wheels with the dynamic link libraries (DLLs) included. The reason for this is that Python 3.8 and later changed the way that DLLs are loaded on Windows for security reasons. This means that applications that relied on the old behavior would have to manually handle loading DLLs. The plan is to build wheels of PyGObject with the necessary DLLs included, which he said would also "significantly improve install time".

Yeaw also said that there was work to port PyGObject to libgirepository 2.0, which he described as "more of a chore" to ensure that the project was using the latest libraries. That work had been started by Philip Withnall and was being picked up by Molenaar. The project is also working to combine and merge the API documentation to the PyGObject site, which would centralize all of the Python for GNOME documentation.

Yeaw closed by asking attendees to get involved with PyGObject, and thanking all the contributors who had helped with the project so far. He asked for help with any kind of contribution, whether that was submitting bug reports or triaging issues, improving documentation, fixing bugs, implementing new features, or simply building new applications using PyGObject.

The "Showing up for Python in GNOME" talk is available on YouTube.

[Thanks to the Linux Foundation, LWN's travel sponsor, for supporting our travel to this event.]


Index entries for this article
ConferenceGUADEC/2024
PythonLibraries


to post comments

What other languages does GTK support well?

Posted Aug 1, 2024 9:26 UTC (Thu) by aragilar (subscriber, #122569) [Link] (1 responses)

I thought Python was strongly supported by GTK, but apparently there was (is?) a question of whether that was true. If Python is out, and we exclude C and C++ (as the former is what GTK is written is, and the latter can be written in a very C-like way), what other languages could users write their apps in (especially scripting languages)?

What other languages does GTK support well?

Posted Aug 1, 2024 12:13 UTC (Thu) by rahulsundaram (subscriber, #21946) [Link]

I don't think Python is out. The entire article is about how Python is getting more maintenance help. The best supported bindings for scripting are likely to be Python and Javascript since several core or popular applications are written in one or the other.

Python

* Showtime (expected to replace Totem as the video player)
* Music
* Tweaks
* Decibels

Javascript

* GNOME Shell
* Weather
* Maps
* Characters
* Sound recorder

A number of the newer applications are using Rust however.

* Loupe (core GNOME app for viewing images)
* Papers (expected to replace Evince as the document viewer)

Python makes it easy to build things?

Posted Aug 2, 2024 7:35 UTC (Fri) by taladar (subscriber, #68407) [Link] (12 responses)

I would question the base assumption that Python makes it easy to build things.

Not only does the language require a runtime of matching versions to even run things and has horrible tooling, making it hard to deploy, it also offers little support to the developer to avoid bugs or verify the structure of their code.

Python makes it easy to build things?

Posted Aug 5, 2024 8:38 UTC (Mon) by LtWorf (subscriber, #124958) [Link] (11 responses)

The deploy stuff is not a problem on linux distributions, which is where gnome exists.

Python makes it easy to build things?

Posted Aug 5, 2024 8:53 UTC (Mon) by Wol (subscriber, #4433) [Link] (10 responses)

Given the grief Python dependencies regularly cause on gentoo, I would beg to differ ...

It's not the deployment of apps that depend on Python, it's the deployment of Python itself as all those apps depend on different versions ...

"You are in a maze of twisty little dependencies, all similar"

Cheers,
Wol

Python makes it easy to build things?

Posted Aug 5, 2024 10:29 UTC (Mon) by pizza (subscriber, #46) [Link] (1 responses)

> It's not the deployment of apps that depend on Python, it's the deployment of Python itself as all those apps depend on different versions

At $dayjob-1, I spent a significant portion of my time chasing after "okay what sub-sub-sub dependency broke the six-hour build [1] THIS time?" issues.

Our actual code was primarily Juypter notebooks, but they had to run on a custom SBC with a massive Xilinx FPGA. (And yes, we relied on Python code that was derived from the FPGA bitstream)

Python might be really nice for protoyping but it is absolutely *horrible* to deploy in any sort of supportable manner unless *every* sub-dependency is pinned and/or you have an exhastingly comprehensive test suite for not only your code but every sub-dependency as well.

[1] Going from a change in the FPGA definition to a bootable SD card image popping out the other side..

Python makes it easy to build things?

Posted Aug 5, 2024 12:58 UTC (Mon) by Wol (subscriber, #4433) [Link]

I guess that's why Rust has editions.

And in my own little world, lilypond has the "version" keyword, which you are encouraged to use ... primarily to enable easy auto-conversion/update of source, but also to prevent you using an older compiler on newer source. To what extent it discourages/prevents running a newer compiler on older source, I'm not sure, but you're supposed to run convert-ly to make sure that never happens.

Cheers,
Wol

Python makes it easy to build things?

Posted Aug 5, 2024 14:01 UTC (Mon) by LtWorf (subscriber, #124958) [Link] (7 responses)

> It's not the deployment of apps that depend on Python, it's the deployment of Python itself as all those apps depend on different versions ...

That doesn't happen on distributions.

Python makes it easy to build things?

Posted Aug 5, 2024 14:17 UTC (Mon) by Wol (subscriber, #4433) [Link] (6 responses)

What is gentoo, if not a distro?

What if you want to deploy a python app, and it requires a newer version than your distro has?

Less likely, what if it requires a version your distro has deprecated ...

Cheers,
Wol

Python makes it easy to build things?

Posted Aug 5, 2024 14:41 UTC (Mon) by LtWorf (subscriber, #124958) [Link] (5 responses)

If it's not packaged in your distro you package it in your distro and then you can install it. Otherwise you don't install it.

Either way the issue you described does not exist if you stick to distributions.

Python makes it easy to build things?

Posted Aug 5, 2024 14:54 UTC (Mon) by pizza (subscriber, #46) [Link]

> Either way the issue you described does not exist if you stick to distributions.

Only if the Python software in question is already packaged (and 100% supported) by said distribution.

...Which, in the real world, is quite rare.

Meanwhile, a problem that I have personally (and repeatedly) encountered is that your code has, say two major dependencies. One requires pyFoo <= 1.1 but the other requires pyFoo > 1.2. Python itself simply doesn't allow for that.

Python makes it easy to build things?

Posted Aug 5, 2024 16:12 UTC (Mon) by Wol (subscriber, #4433) [Link] (3 responses)

> Either way the issue you described does not exist if you stick to distributions.

In case you hadn't noticed, when I originally brought it up, I brought it up BECAUSE OF a distribution. I stick to gentoo. It happens all the time as far as I can tell ... and gentoo is exactly the distro where these sort of things are Not Supposed (tm) to happen!

Cheers,
Wol

Python makes it easy to build things?

Posted Aug 5, 2024 16:22 UTC (Mon) by LtWorf (subscriber, #124958) [Link] (2 responses)

If you download a .tar.gz and unpack it, you're not running a distribution (for that one thing).

Python makes it easy to build things?

Posted Aug 5, 2024 16:33 UTC (Mon) by Wol (subscriber, #4433) [Link] (1 responses)

Pardon? Who said I went anywhere near a .tar.gz?

"emerge --update blah-blah".

You know the saying about ASSuME?

Cheers,
Wol

Enough?

Posted Aug 5, 2024 16:43 UTC (Mon) by corbet (editor, #1) [Link]

By the time you are eight or so levels into back-and-forth, perhaps you can conclude that this conversation isn't going anywhere. Please, this is just silly, can we stop it here?

Thanks Dan!

Posted Aug 2, 2024 15:12 UTC (Fri) by sam.thursfield (subscriber, #94496) [Link]

It's fantastic to see Dan putting in new energy here and sharing the work that goes in so app developers can build apps. There are quite a lot of volunteers making apps for GNOME these days, which is great to see but its a lot harder to get new people to join in and work on the "plumbing" layers.


Copyright © 2024, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds