From 235459197a8baf46fea408fdd660e14dceeb9ef4 Mon Sep 17 00:00:00 2001 From: kapshytar Date: Sat, 27 Jun 2026 00:22:10 +0300 Subject: [PATCH] Fix startup crash on setuptools 81+; modernize requirements setuptools 81 removed the bundled pkg_resources module, so the app crashed on launch with ModuleNotFoundError: No module named 'pkg_resources'. Replace the single pkg_resources.resource_filename call with a small stdlib shim built on importlib.resources (Python 3.9+), keeping every call site unchanged. Also re-encode requirements.txt as UTF-8 (was UTF-16) and relax the stale pins. Tested: launches on Python 3.12 with setuptools 82 (no pkg_resources). --- requirements.txt | Bin 380 -> 37 bytes src/app/core/configurations.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a5786ee798183258d6c8d0bf85c3af0b80d7f7ce..70bfe084d99f989cdb42248addd7fac28cf65232 100644 GIT binary patch literal 37 qcmWHj3@kCVvo+N-1R_JO#FQl6;*8XsoaoZxq*yy!13eQx6D|PFBMONC literal 380 zcmZutTMmLS5S(ulkAk5^L_fHL9-+ktCPYb#A6{Oa-6|w%HhrWsJ2Tto!(k7P3=u63 z=vXx?#{x^P0&~pJ;K({FV)$xM>YlKGJ9-Sb;)DRld&?J5DNvD@w1nGH!{bITPmRP# zc&q)yS5_PEq;QjXJ#mz2P)j diff --git a/src/app/core/configurations.py b/src/app/core/configurations.py index 5e1e06b..7b9e5a9 100644 --- a/src/app/core/configurations.py +++ b/src/app/core/configurations.py @@ -4,12 +4,22 @@ import platform from PyQt5.QtCore import QFile, QIODevice -from pkg_resources import resource_filename +from importlib.resources import files as _resource_files from app.data.models import Device from app.helpers.tools import Singleton, json_to_dict +def resource_filename(package: str, resource: str) -> str: + """Return a filesystem path to a resource bundled inside a package. + + Standard-library replacement for ``pkg_resources.resource_filename``, + which is unavailable once setuptools 81+ drops the ``pkg_resources`` + package. Uses ``importlib.resources`` (available since Python 3.9). + """ + return str(_resource_files(package).joinpath(resource)) + + class Application(metaclass=Singleton): __version__ = '1.4.0' __author__ = 'Azat Aldeshov'