Skip to content

Fix startup crash on setuptools 81+ (drop pkg_resources) - #32

Open
kapshytar wants to merge 1 commit into
Aldeshov:masterfrom
kapshytar:fix/setuptools81-pkg-resources
Open

Fix startup crash on setuptools 81+ (drop pkg_resources)#32
kapshytar wants to merge 1 commit into
Aldeshov:masterfrom
kapshytar:fix/setuptools81-pkg-resources

Conversation

@kapshytar

Copy link
Copy Markdown

Problem

The app crashes on launch with:

ModuleNotFoundError: No module named 'pkg_resources'

setuptools 81 removed the long-deprecated bundled pkg_resources module, and modern virtualenvs (setuptools 81+) no longer ship it. Since core/configurations.py imports resource_filename from pkg_resources, the app no longer starts on a fresh, up-to-date environment (e.g. Python 3.12 + setuptools 82). The only workaround today is pinning setuptools<81.

Fix

Replace the single pkg_resources.resource_filename import with a tiny standard-library shim built on importlib.resources (available since Python 3.9). All ~30 call sites are left untouched:

from importlib.resources import files as _resource_files

def resource_filename(package: str, resource: str) -> str:
    return str(_resource_files(package).joinpath(resource))

This resolves the same packages (app, resources.styles, resources.icons, …) to filesystem paths, including the namespace packages without __init__.py.

Also:

  • Re-encoded requirements.txt as UTF-8 (it was UTF-16, which trips some tools).
  • Relaxed the stale pins to current releases (PyQt5, adb-shell[usb]); transitive deps are resolved automatically.

Testing

Launched on Python 3.12 with setuptools 82.0.1 (where import pkg_resources raises ModuleNotFoundError). The app now starts, lists the device, browses folders (including names with spaces) and downloads files — no pkg_resources, no setuptools<81 pin needed.

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant