fix: replace pkg_resources with importlib.resources for Python 3.12+ (closes #359)#360
Open
marcm0de wants to merge 1 commit intoJaDogg:developfrom
Open
fix: replace pkg_resources with importlib.resources for Python 3.12+ (closes #359)#360marcm0de wants to merge 1 commit intoJaDogg:developfrom
marcm0de wants to merge 1 commit intoJaDogg:developfrom
Conversation
…loses JaDogg#359) pkg_resources (from setuptools) was removed from the Python standard library in 3.12+. This caused a ModuleNotFoundError on Python 3.13 when setuptools wasn't explicitly installed. Fix: Use importlib.resources.files() (available since Python 3.9) as the primary resource lookup, with pkg_resources as fallback for older environments, and a final fallback to __file__-relative path.
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.
Summary
Fixes #359 — pydoro fails to start on Python 3.13 with
ModuleNotFoundError: No module named 'pkg_resources'.Problem
pkg_resources(fromsetuptools) is no longer bundled with Python 3.12+. When pydoro tries to resolve resource paths via_from_resource(), it fails on fresh Python 3.13 installs that don't havesetuptools.Fix
Updated
_from_resource()inpydoro_core/util.pyto use a cascading fallback:importlib.resources.files()(Python 3.9+, stdlib) — primarypkg_resources.resource_filename()— fallback for older environments__file__-relative path — final fallbackThis maintains backward compatibility while fixing the crash on modern Python.