0.12.3 replace resource_filename() with importlib.resources API

This commit is contained in:
Yusur 2026-03-11 13:10:54 +01:00
parent 634d251395
commit 6b3e4d5403
4 changed files with 49 additions and 2 deletions

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## 0.12.3
+ Replace `resource_filename()` (from deprecated pkg_resources) with API from `importlib.resources`
## 0.12.2 ## 0.12.2
+ Fix imports in module `sqlalchemy.quart` + Fix imports in module `sqlalchemy.quart`

View file

@ -38,7 +38,7 @@ from .http import WantsContentType
from .color import OKLabColor, chalk, WebColor, RGBColor, LinearRGBColor, XYZColor, OKLCHColor from .color import OKLabColor, chalk, WebColor, RGBColor, LinearRGBColor, XYZColor, OKLCHColor
from .mat import Matrix from .mat import Matrix
__version__ = "0.12.2" __version__ = "0.12.3"
__all__ = ( __all__ = (
'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue', 'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue',

31
src/suou/pkg_resources.py Normal file
View file

@ -0,0 +1,31 @@
"""
Drop-in replacement for pkg_resources (kind of), using importlib.resources.
*New in 0.12.3*
---
Copyright (c) 2025 Sakuragasaki46.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
See LICENSE for the specific language governing permissions and
limitations under the License.
This software is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
from importlib.resources import files
def resource_filename(package_name, resource_name: str) -> str:
"""
Backport of resource_filename() from pkg_resources, using importlib.resources
"""
return str(files(package_name) / resource_name)
__all__ = (
'resource_filename',
)

View file

@ -1,5 +1,17 @@
""" """
---
Copyright (c) 2025 Sakuragasaki46.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
See LICENSE for the specific language governing permissions and
limitations under the License.
This software is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
""" """
@ -16,7 +28,7 @@ from .validators import must_be
from .asgi import _MiddlewareFactory, ASGIApp, ASGIReceive, ASGIScope, ASGISend from .asgi import _MiddlewareFactory, ASGIApp, ASGIReceive, ASGIScope, ASGISend
from . import __version__ as _suou_version from . import __version__ as _suou_version
from pkg_resources import resource_filename from .pkg_resources import resource_filename
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)