diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c47f89e..57859947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 3.4.2 + +### Changed + +* [#402](https://github.com/stlehmann/pyads/pull/402) Universal DLL path for TwinCat 4026 and 4024 + ## 3.4.1 ### Changed @@ -111,7 +117,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed * fixed error with source distribution not containing adslib directory - + ### Removed ## 3.3.1 diff --git a/pyads/__init__.py b/pyads/__init__.py index bbde837b..f4d0abd9 100644 --- a/pyads/__init__.py +++ b/pyads/__init__.py @@ -118,4 +118,4 @@ from .symbol import AdsSymbol -__version__ = '3.4.1' +__version__ = '3.4.2' diff --git a/pyads/pyads_ex.py b/pyads/pyads_ex.py index 66b6bdd6..6a7e4459 100644 --- a/pyads/pyads_ex.py +++ b/pyads/pyads_ex.py @@ -57,22 +57,16 @@ # load dynamic ADS library if platform_is_windows(): # pragma: no cover, skip Windows test dlldir_handle = None - if sys.version_info >= (3, 8): + 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. - if "TWINCATSDK" in os.environ: - dll_path = os.environ["TWINCATSDK"] + "\\..\\.." - if platform.architecture()[0] == "64bit": - dll_path += "\\Common64" - else: - dll_path += "\\Common32" - dlldir_handle = os.add_dll_directory(dll_path) - elif "TWINCAT3DIR" in os.environ: - dll_path = os.environ["TWINCAT3DIR"] + "\\..\\AdsApi\\TcAdsDll" - if platform.architecture()[0] == "64bit": - dll_path += "\\x64" - dlldir_handle = os.add_dll_directory(dll_path) + 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 finally: diff --git a/tox.ini b/tox.ini index fa54e786..aa05b256 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ commands = discover deps = discover changedir = tests whitelist_externals=* -passenv = TWINCATSDK TWINCAT3DIR +passenv = TWINCAT3DIR [pytest] testpaths = tests