Skip to content
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

migrate importlib to resolve warning about pkg_resources #3061

Merged
merged 7 commits into from
Aug 30, 2024
19 changes: 18 additions & 1 deletion src_py/pkgdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@ def getResource(identifier, pkgname=__name__):
import os

try:
from pkg_resources import resource_stream, resource_exists
import importlib_resources
ankith26 marked this conversation as resolved.
Show resolved Hide resolved

def resource_exists(_package_or_requirement, _resource_name):
return (
importlib_resources.files(_package_or_requirement)
.joinpath(_resource_name)
.is_file()
)

def resource_stream(_package_or_requirement, _resource_name):
ref = (
importlib_resources.files(_package_or_requirement)
.joinpath(_resource_name)
.is_file()
raspofabs marked this conversation as resolved.
Show resolved Hide resolved
)
return ref.open('rb')


except ImportError:

def resource_exists(_package_or_requirement, _resource_name):
Expand Down