Debugging a Gnome Builder generated Python Flatpak project

I recently tried to use Gnome Builder on Fedora 39 to build and debug a new Gnome Python Flatpak project, but couldn’t figure out how to make the debugging work (setting breakpoints), or if it’s even currently supported (language servers etc). Is there a good up-to-date guide anywhere for that?


To get Gnome Python Flatpak debugging working on Visual Studio Code, with a few tips from these forums and elsewhere, here are the changes needed required to a default generated project. After you run the the Flatpak: Build and Run command (from this extension), the application will wait until you run the Python Debugger: Remote Attach launch profile, and then you can continue debugging.

--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+    "recommendations": [
+        "bilelmoussaoui.flatpak-vscode"
+    ]
+}
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,23 @@
+{
+	// Use IntelliSense to learn about possible attributes.
+	// Hover to view descriptions of existing attributes.
+	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+	"version": "0.2.0",
+	"configurations": [
+		{
+			"name": "Python Debugger: Remote Attach",
+			"type": "debugpy",
+			"request": "attach",
+			"connect": {
+				"host": "localhost",
+				"port": 9002
+			},
+			"pathMappings": [
+				{
+					"localRoot": "${workspaceFolder}/src",
+					"remoteRoot": "/app/share/gnomepythontest/gnomepythontest/"
+				}
+			]
+		}
+	]
+}
--- a/org.example.someguy.gnomepythontest.json
+++ b/org.example.someguy.gnomepythontest.json
@@ -23,6 +23,18 @@
         "*.a"
     ],
     "modules" : [
+        {
+            "name": "debugpy",
+            "buildsystem": "simple",
+            "build-options": {
+              "build-args": [
+                "--share=network"
+              ]
+            },
+            "build-commands": [
+                "pip3 install --prefix=/app --no-cache-dir debugpy"
+            ]
+        },
         {
             "name" : "gnomepythontest",
             "builddir" : true,
--- a/src/main.py
+++ b/src/main.py
@@ -1,3 +1,9 @@
+import debugpy
+debugpy.listen(('127.0.0.1', 9002))
+debugpy.wait_for_client()
+debugpy.breakpoint()
+
+
 # MIT License
 #
 # Copyright (c) 2024 Some Guy
1 Like

This is public utility information. It should be fixed somewhere as a guideline for creating flatpaks. Many people use VSCode instead of Gnome Builder.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.