Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal DLL path for 4024 / 4026 #402

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@

from .symbol import AdsSymbol

__version__ = '3.4.1'
__version__ = '3.4.2'
20 changes: 7 additions & 13 deletions pyads/pyads_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ commands = discover
deps = discover
changedir = tests
whitelist_externals=*
passenv = TWINCATSDK TWINCAT3DIR
passenv = TWINCAT3DIR

[pytest]
testpaths = tests
Loading