From b32de35afdee258d35d4c0b1af7a87e5afc31460 Mon Sep 17 00:00:00 2001
From: Laurent Trinques
Date: Mon, 6 Apr 2026 08:34:20 +0200
Subject: [PATCH] Add files via upload
---
build-aux/flatpak/fix-appdata.patch | 54 +++++++
build-aux/flatpak/pypi-dependencies.json | 40 +++++
build-aux/flatpak/tkinter-build.patch | 184 +++++++++++++++++++++++
build-aux/flatpak/tkinter.json | 58 +++++++
4 files changed, 336 insertions(+)
create mode 100644 build-aux/flatpak/fix-appdata.patch
create mode 100644 build-aux/flatpak/pypi-dependencies.json
create mode 100644 build-aux/flatpak/tkinter-build.patch
create mode 100644 build-aux/flatpak/tkinter.json
diff --git a/build-aux/flatpak/fix-appdata.patch b/build-aux/flatpak/fix-appdata.patch
new file mode 100644
index 000000000..4deb3d91a
--- /dev/null
+++ b/build-aux/flatpak/fix-appdata.patch
@@ -0,0 +1,54 @@
+From 5cb80674cec7363ed00bab5248b3674ca5241c2f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Sabri=20=C3=9Cnal?=
+Date: Fri, 20 Feb 2026 22:56:52 +0300
+Subject: [PATCH] Fix appdata paper cuts
+
+---
+ misc/qelectrotech.appdata.xml | 26 ++++++++++++++++++++------
+ 1 file changed, 20 insertions(+), 6 deletions(-)
+
+diff --git a/misc/qelectrotech.appdata.xml b/misc/qelectrotech.appdata.xml
+index dd06ab7..eb02119 100644
+--- a/misc/qelectrotech.appdata.xml
++++ b/misc/qelectrotech.appdata.xml
+@@ -1,7 +1,8 @@
+
+
+-
+- qelectrotech.desktop
++
++ org.qelectrotech.QElectroTech
++ qelectrotech.desktop
+ MIT
+ GPL-2.0-or-later
+ QElectroTech
+@@ -83,9 +84,22 @@
+ QET は要素と回路図に XML 形式を利用し、回路図エディタ、要素エディタ、表題欄エディタを含みます。
+
+
+- http://qelectrotech.org
++ https://qelectrotech.org
++ https://qelectrotech.org/bugtracker
++ https://github.com/qelectrotech/qelectrotech-source-mirror
++
++ QElectroTech
++
+
+- http://download.tuxfamily.org/qet/screens/qelectrotech5.png
++
++ https://qelectrotech.org/screenshots/qet_overview04.png
++
++
++ https://qelectrotech.org/screenshots/qet_overview06.png
++
++
++ https://qelectrotech.org/screenshots/qet_overview09.png
++
+
+- qet@lists.tuxfamily.org
+-
++ qet@lists.tuxfamily.org
++
+--
+2.53.0
+
diff --git a/build-aux/flatpak/pypi-dependencies.json b/build-aux/flatpak/pypi-dependencies.json
new file mode 100644
index 000000000..c6eae1906
--- /dev/null
+++ b/build-aux/flatpak/pypi-dependencies.json
@@ -0,0 +1,40 @@
+{
+ "name": "pypi-dependencies",
+ "buildsystem": "simple",
+ "build-commands": [],
+ "modules": [
+ {
+ "name": "python3-PySimpleGUI",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"PySimpleGUI\" --no-build-isolation"
+ ],
+ "sources": [
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/4d/d9/3de4b7ca71a7779e4f4a160088621b072a29d9b814a7fa9b5411571f4849/pysimplegui-5.0.8.3-py3-none-any.whl",
+ "sha256": "67e35ad6dd76e9369051261114f4711308e87815a0488f7fa28b37c29a546f8b"
+ }
+ ]
+ },
+ {
+ "name": "python3-qet-tb-generator",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"qet-tb-generator\" --no-build-isolation"
+ ],
+ "sources": [
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/4d/d9/3de4b7ca71a7779e4f4a160088621b072a29d9b814a7fa9b5411571f4849/pysimplegui-5.0.8.3-py3-none-any.whl",
+ "sha256": "67e35ad6dd76e9369051261114f4711308e87815a0488f7fa28b37c29a546f8b"
+ },
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/63/d6/81de49a3ccec259583241fec4d79c668eff4acf9eb4d0226db36e1399f2d/qet_tb_generator-1.3.1-py3-none-any.whl",
+ "sha256": "80fb4af229edfd5774e61f96fa387ff394d5060abd0ca45c3c74d29de1ce9b53"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/build-aux/flatpak/tkinter-build.patch b/build-aux/flatpak/tkinter-build.patch
new file mode 100644
index 000000000..7f46d4d12
--- /dev/null
+++ b/build-aux/flatpak/tkinter-build.patch
@@ -0,0 +1,184 @@
+commit 3bbb09a0598fc976d2bf8dac932b27740086c1bd
+Author: Hubert Figuière
+Date: Sun Dec 21 17:49:43 2025 -0500
+
+ Port to Python 3.13
+
+ Signed-off-by: Hubert Figuière
+
+diff --git a/_tkinter.c b/_tkinter.c
+index e537707..dfc5789 100644
+--- a/_tkinter.c
++++ b/_tkinter.c
+@@ -21,7 +21,6 @@ Copyright (C) 1994 Steen Lumholt.
+
+ */
+
+-#define PY_SSIZE_T_CLEAN
+ #ifndef Py_BUILD_CORE_BUILTIN
+ # define Py_BUILD_CORE_MODULE 1
+ #endif
+@@ -32,6 +31,9 @@ Copyright (C) 1994 Steen Lumholt.
+ # include "pycore_fileutils.h" // _Py_stat()
+ #endif
+
++#include "pycore_long.h" // _PyLong_IsNegative()
++#include "pycore_sysmodule.h" // _PySys_GetOptionalAttrString()
++
+ #ifdef MS_WINDOWS
+ #include
+ #endif
+@@ -135,7 +137,7 @@ _get_tcl_lib_path()
+ struct stat stat_buf;
+ int stat_return_value;
+
+- prefix = PyUnicode_FromWideChar(Py_GetPrefix(), -1);
++ (void) _PySys_GetOptionalAttrString("base_prefix", &prefix);
+ if (prefix == NULL) {
+ return NULL;
+ }
+@@ -143,9 +145,11 @@ _get_tcl_lib_path()
+ /* Check expected location for an installed Python first */
+ tcl_library_path = PyUnicode_FromString("\\tcl\\tcl" TCL_VERSION);
+ if (tcl_library_path == NULL) {
++ Py_DECREF(prefix);
+ return NULL;
+ }
+ tcl_library_path = PyUnicode_Concat(prefix, tcl_library_path);
++ Py_DECREF(prefix);
+ if (tcl_library_path == NULL) {
+ return NULL;
+ }
+@@ -959,7 +963,8 @@ AsObj(PyObject *value)
+ (unsigned char *)(void *)&wideValue,
+ sizeof(wideValue),
+ PY_LITTLE_ENDIAN,
+- /* signed */ 1) == 0) {
++ /* signed */ 1,
++ /* with_exceptions */ 1) == 0) {
+ return Tcl_NewWideIntObj(wideValue);
+ }
+ PyErr_Clear();
+@@ -1988,7 +1993,7 @@ _tkinter_tkapp_getboolean(TkappObject *self, PyObject *arg)
+ int v;
+
+ if (PyLong_Check(arg)) { /* int or bool */
+- return PyBool_FromLong(Py_SIZE(arg) != 0);
++ return PyBool_FromLong(!_PyLong_IsZero((PyLongObject *)arg));
+ }
+
+ if (PyTclObject_Check(arg)) {
+diff --git a/clinic/_tkinter.c.h b/clinic/_tkinter.c.h
+index 9103565..f43510d 100644
+--- a/clinic/_tkinter.c.h
++++ b/clinic/_tkinter.c.h
+@@ -2,6 +2,8 @@
+ preserve
+ [clinic start generated code]*/
+
++#include "pycore_modsupport.h" // _PyArg_BadArgument()
++
+ PyDoc_STRVAR(_tkinter_tkapp_eval__doc__,
+ "eval($self, script, /)\n"
+ "--\n"
+@@ -426,7 +428,7 @@ _tkinter_tkapp_createfilehandler(TkappObject *self, PyObject *const *args, Py_ss
+ goto exit;
+ }
+ file = args[0];
+- mask = _PyLong_AsInt(args[1]);
++ mask = PyLong_AsInt(args[1]);
+ if (mask == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+@@ -490,7 +492,7 @@ _tkinter_tkapp_createtimerhandler(TkappObject *self, PyObject *const *args, Py_s
+ if (!_PyArg_CheckPositional("createtimerhandler", nargs, 2, 2)) {
+ goto exit;
+ }
+- milliseconds = _PyLong_AsInt(args[0]);
++ milliseconds = PyLong_AsInt(args[0]);
+ if (milliseconds == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+@@ -524,7 +526,7 @@ _tkinter_tkapp_mainloop(TkappObject *self, PyObject *const *args, Py_ssize_t nar
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+- threshold = _PyLong_AsInt(args[0]);
++ threshold = PyLong_AsInt(args[0]);
+ if (threshold == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+@@ -558,7 +560,7 @@ _tkinter_tkapp_dooneevent(TkappObject *self, PyObject *const *args, Py_ssize_t n
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+- flags = _PyLong_AsInt(args[0]);
++ flags = PyLong_AsInt(args[0]);
+ if (flags == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+@@ -741,29 +743,29 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+ if (nargs < 4) {
+ goto skip_optional;
+ }
+- interactive = _PyLong_AsInt(args[3]);
+- if (interactive == -1 && PyErr_Occurred()) {
++ interactive = PyObject_IsTrue(args[3]);
++ if (interactive < 0) {
+ goto exit;
+ }
+ if (nargs < 5) {
+ goto skip_optional;
+ }
+- wantobjects = _PyLong_AsInt(args[4]);
+- if (wantobjects == -1 && PyErr_Occurred()) {
++ wantobjects = PyObject_IsTrue(args[4]);
++ if (wantobjects < 0) {
+ goto exit;
+ }
+ if (nargs < 6) {
+ goto skip_optional;
+ }
+- wantTk = _PyLong_AsInt(args[5]);
+- if (wantTk == -1 && PyErr_Occurred()) {
++ wantTk = PyObject_IsTrue(args[5]);
++ if (wantTk < 0) {
+ goto exit;
+ }
+ if (nargs < 7) {
+ goto skip_optional;
+ }
+- sync = _PyLong_AsInt(args[6]);
+- if (sync == -1 && PyErr_Occurred()) {
++ sync = PyObject_IsTrue(args[6]);
++ if (sync < 0) {
+ goto exit;
+ }
+ if (nargs < 8) {
+@@ -814,7 +816,7 @@ _tkinter_setbusywaitinterval(PyObject *module, PyObject *arg)
+ PyObject *return_value = NULL;
+ int new_val;
+
+- new_val = _PyLong_AsInt(arg);
++ new_val = PyLong_AsInt(arg);
+ if (new_val == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+diff --git a/setup.py b/setup.py
+index f379305..cf7b6ad 100644
+--- a/setup.py
++++ b/setup.py
+@@ -3,11 +3,11 @@ from distutils.core import setup, Extension
+ module1 = Extension('_tkinter',
+ libraries=['tcl8.6', 'tk8.6'],
+ sources=['_tkinter.c'],
+- include_dirs=['/app/include/'])
++ include_dirs=['/app/include/', '/usr/include/python3.13/internal/'])
+
+ setup(
+ name='tkinter-standalone',
+- version='3.11',
++ version='3.13',
+ description='Tkinter packaged as an external package for flatpak.',
+ ext_modules=[module1],
+ packages=["tkinter"]
diff --git a/build-aux/flatpak/tkinter.json b/build-aux/flatpak/tkinter.json
new file mode 100644
index 000000000..8efd88c99
--- /dev/null
+++ b/build-aux/flatpak/tkinter.json
@@ -0,0 +1,58 @@
+{
+ "//note": "The `tkinter` module is missing from the Freedesktop Sdk's Python installation",
+ "name": "tkinter",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --prefix=${FLATPAK_DEST} --no-build-isolation ."
+ ],
+ "sources": [
+ {
+ "type": "git",
+ "url": "https://github.com/iwalton3/tkinter-standalone",
+ "commit": "88aa05075d90d393a29a484bce676e237d311082"
+ },
+ {
+ "type": "patch",
+ "path": "patches/tkinter-build.patch"
+ }
+ ],
+ "modules": [
+ {
+ "name": "tcl",
+ "buildsystem": "autotools",
+ "subdir": "unix",
+ "post-install": [
+ "chmod 755 /app/lib/libtcl*.so"
+ ],
+ "cleanup": [
+ "/bin"
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://prdownloads.sourceforge.net/tcl/tcl8.6.17-src.tar.gz",
+ "sha256": "a3903371efcce8a405c5c245d029e9f6850258a60fa3761c4d58995610949b31"
+ }
+ ]
+ },
+ {
+ "name": "tk",
+ "buildsystem": "autotools",
+ "subdir": "unix",
+ "post-install": [
+ "chmod 755 /app/lib/libtk*.so"
+ ],
+ "cleanup": [
+ "/bin",
+ "/lib/tk*/demos"
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://prdownloads.sourceforge.net/tcl/tk8.6.17-src.tar.gz",
+ "sha256": "e4982df6f969c08bf9dd858a6891059b4a3f50dc6c87c10abadbbe2fc4838946"
+ }
+ ]
+ }
+ ]
+}