Skip to content

Commit 1408fd2

Browse files
Replace deprecated pkg_resources (#129)
1 parent a36ebf4 commit 1408fd2

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

livekit-rtc/livekit/rtc/_ffi_client.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,21 @@
1313
# limitations under the License.
1414

1515
import asyncio
16-
import logging
1716
import ctypes
17+
import importlib.resources
18+
import logging
1819
import os
1920
import platform
2021
import threading
2122
from typing import Generic, List, Optional, TypeVar
2223

23-
import pkg_resources
24-
2524
from ._proto import ffi_pb2 as proto_ffi
2625
from ._utils import Queue, classproperty
2726

2827
logger = logging.getLogger("livekit")
2928

3029

31-
def get_ffi_lib_path():
30+
def get_ffi_lib():
3231
# allow to override the lib path using an env var
3332
libpath = os.environ.get("LIVEKIT_LIB_PATH", "").strip()
3433
if libpath:
@@ -46,13 +45,12 @@ def get_ffi_lib_path():
4645
Set LIVEKIT_LIB_PATH to specify a the lib path"
4746
)
4847

49-
libpath = pkg_resources.resource_filename(
50-
"livekit.rtc", os.path.join("resources", libname)
51-
)
52-
return libpath
48+
with importlib.resources.path("livekit.rtc.resources", libname) as resource_path:
49+
ffi_lib = ctypes.CDLL(resource_path)
50+
return ffi_lib
5351

5452

55-
ffi_lib = ctypes.CDLL(get_ffi_lib_path())
53+
ffi_lib = get_ffi_lib()
5654
ffi_cb_fnc = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_uint8), ctypes.c_size_t)
5755

5856
# C function types

0 commit comments

Comments
 (0)