Fix startup crash on setuptools 81+ (drop pkg_resources) - #32
Open
kapshytar wants to merge 1 commit into
Open
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The app crashes on launch with:
setuptools81 removed the long-deprecated bundledpkg_resourcesmodule, and modern virtualenvs (setuptools 81+) no longer ship it. Sincecore/configurations.pyimportsresource_filenamefrompkg_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 pinningsetuptools<81.Fix
Replace the single
pkg_resources.resource_filenameimport with a tiny standard-library shim built onimportlib.resources(available since Python 3.9). All ~30 call sites are left untouched:This resolves the same packages (
app,resources.styles,resources.icons, …) to filesystem paths, including the namespace packages without__init__.py.Also:
requirements.txtas UTF-8 (it was UTF-16, which trips some tools).PyQt5,adb-shell[usb]); transitive deps are resolved automatically.Testing
Launched on Python 3.12 with setuptools 82.0.1 (where
import pkg_resourcesraisesModuleNotFoundError). The app now starts, lists the device, browses folders (including names with spaces) and downloads files — nopkg_resources, nosetuptools<81pin needed.