Skip to content

TLMC_SDK.try_load_library fails in Python XA SDK when current working directory is different #88

@brianm92

Description

@brianm92

Problem:

TLMC_SDK.try_load_library() currently calls:

cdll.LoadLibrary("./tlmc_xa_native.dll")

This is relative to the current working directory, not a user-specified folder containing the DLL. Scripts run from a different CWD then fail with:

FileNotFoundError: Could not find module '...tlmc_xa_native.dll'

This is strange behaviour as a lab user will typically call in a DLL like this via scripts that could live in a very different directory. The only way to use this function to open the DLL at present is to copy the DLL into the directory containing your Python script, or alternatively use

os.chdir("...path_to_dll_folder...")

inside your script before opening the library to change directory to the DLL folder.

Steps to reproduce:

  1. Place tlmc_xa_native.dll in the folder with the Python wrapper.

  2. Run a script from a different working directory.

  3. Call XASDK.try_load_library(), then see FileNotFoundError.

Suggested Fix:
Use an absolute path to the DLL in the try_load_library definition inside tlmc_core.py instead of a relative path. For example:

dll_path = os.path.join(os.path.abspath(dll_folder), "tlmc_xa_native.dll")
TLMC_SDK.xa_lib = cdll.LoadLibrary(dll_path)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions