diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c47f89..5785994 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 bbde837..f4d0abd 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 66b6bdd..6a7e445 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 fa54e78..aa05b25 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