-
-
Notifications
You must be signed in to change notification settings - Fork 50
Add support for resources in namespace packages #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Filipe Laíns <[email protected]>
That is changing, we want to add support for resources in namespace packages. Signed-off-by: Filipe Laíns <[email protected]>
Signed-off-by: Filipe Laíns <[email protected]>
I don't know how the this project exactly relates to the built-in importlib.resources (I see in the README that you recommend to use the buillt-in module for Python >= 3.9), but I wonder: does the built-in |
This project and |
Makes sense, thank you for the clarification |
Fix Python 3.9 compatibility issue with importlib.resources Fixes TypeError: expected str, bytes or os.PathLike object, not NoneType when importing mex.model in Python 3.9 due to namespace package issues with importlib.resources.files(). ### Changes - Added importlib_resources fallback for Python < 3.10 compatibility - Added error handling with pkgutil fallback for namespace packages - Updated dependencies to include importlib-resources>=1.3 for Python < 3.10 ### Technical Details The issue occurred because spec.origin is None for namespace packages in Python 3.9, causing pathlib.Path() to fail. The fix: 1. Uses importlib_resources backport which has proper namespace package support 2. Provides fallback using pkgutil.iter_modules() when primary approach fails ### Files Changed - mex/model/__init__.py - Added fallback logic and refactored resource loading - pyproject.toml - Added conditional dependency on importlib-resources ### References - [Add support for resources in namespace packages](python/importlib_resources#196) - importlib_resources backport library - Python 3.9's built-in `importlib.resources` lacks namespace package support, requiring the backport library for compatibility
Fixes #68