Skip to content

Commit

Permalink
#511 don't hardcode the library name
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Feb 27, 2025
1 parent 91db186 commit f92fcb4
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions xpra/codecs/amf/common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from typing import Dict
from ctypes import CDLL, c_uint64, c_int, c_void_p, byref, POINTER

from xpra.common import noop
from xpra.log import Logger

from libc.stddef cimport wchar_t
from libc.stdint cimport uint64_t, uintptr_t
from libc.string cimport memset
Expand All @@ -24,16 +27,9 @@ from xpra.codecs.amf.amf cimport (
RESULT_STR,
)

from xpra.common import noop
from xpra.log import Logger
cdef extern from "core/Factory.h":
cdef const char* AMF_DLL_NAMEA

log = Logger("amf")
LIBNAME = "amfrt64"
try:
amf = CDLL(LIBNAME)
except OSError as e:
raise ImportError(f"AMF library {LIBNAME!r} not found: {e}") from None
assert amf

cdef extern from "Python.h":
object PyUnicode_FromWideChar(wchar_t *w, Py_ssize_t size)
Expand All @@ -45,6 +41,23 @@ cdef extern from "string.h":
size_t wcslen(const wchar_t *str)


log = Logger("amf")


cdef object load_library():
libname = AMF_DLL_NAMEA.decode("latin1")
try:
amf = CDLL(libname)
except OSError as e:
log("CDLL({libname})", exc_info=True)
raise ImportError(f"AMF library {libname!r} not found: {e}") from None
assert amf
return amf


amf = load_library()


cdef AMFFactory *factory
cdef int initialized = 0
cdef U_XPRA_TRACER = "xpra-tracer"
Expand Down

0 comments on commit f92fcb4

Please # to comment.