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

Replace deprecated pkg_resources #129

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions livekit-rtc/livekit/rtc/_ffi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@
# limitations under the License.

import asyncio
import logging
import ctypes
import importlib.resources
import logging
import os
import platform
import threading
from typing import Generic, List, Optional, TypeVar

import pkg_resources

from ._proto import ffi_pb2 as proto_ffi
from ._utils import Queue, classproperty

logger = logging.getLogger("livekit")


def get_ffi_lib_path():
def get_ffi_lib():
# allow to override the lib path using an env var
libpath = os.environ.get("LIVEKIT_LIB_PATH", "").strip()
if libpath:
Expand All @@ -46,13 +45,12 @@ def get_ffi_lib_path():
Set LIVEKIT_LIB_PATH to specify a the lib path"
)

libpath = pkg_resources.resource_filename(
"livekit.rtc", os.path.join("resources", libname)
)
return libpath
with importlib.resources.path("livekit.rtc.resources", libname) as resource_path:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resources.path is also deprecated, we need to use resources.files

ffi_lib = ctypes.CDLL(resource_path)
return ffi_lib


ffi_lib = ctypes.CDLL(get_ffi_lib_path())
ffi_lib = get_ffi_lib()
ffi_cb_fnc = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_uint8), ctypes.c_size_t)

# C function types
Expand Down
Loading