Skip to content

Allow for specifiying "TcAdsDll.dll" location #473

@premnetsuwan-tpeng

Description

@premnetsuwan-tpeng

Hi! I'm using pyads on windows I'm interested in being able to specify the location of the ads dll.

Currently, pyads seems to check if the dll is in system directories, the directory of the python executable, and if "$TWINCAT3DIR" is set then "$TWINCAT3DIR/Common64".

# load dynamic ADS library
if platform_is_windows(): # pragma: no cover, skip Windows test
dlldir_handle = None
if sys.version_info >= (3, 8) and "TWINCAT3DIR" in os.environ:
# Starting with version 3.8, CPython does not consider the PATH environment
# variable any more when resolving DLL paths. The following works with the default
# installation of the Beckhoff TwinCAT ADS DLL.
dll_path = os.environ["TWINCAT3DIR"] + "\\.."
if platform.architecture()[0] == "64bit":
dll_path += "\\Common64"
else:
dll_path += "\\Common32"
dlldir_handle = os.add_dll_directory(dll_path)
try:
_adsDLL = ctypes.WinDLL("TcAdsDll.dll") # type: ignore

For distribution of my app, it is somewhat cumbersome to install the dll in one of these directories and it would be convenient if I could set it to something local.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions