Calling routines in Windows DLLs from Python scripts running under Linux, MacOS or BSD
Project description
Synopsis
zugbruecke is an EXPERIMENTAL Python module (currently in development status 3/alpha). It allows to call routines in Windows DLLs from Python code running on Unices / Unix-like systems such as Linux, MacOS or BSD. zugbruecke is designed as a drop-in replacement for Python’s standard library’s ctypes module. zugbruecke is built on top of Wine. A stand-alone Windows Python interpreter launched in the background is used to execute the called DLL routines. Communication between the Unix-side and the Windows/Wine-side is based on Python’s build-in multiprocessing connection capability. zugbruecke has (limited) support for pointers, struct types and call-back functions. zugbruecke comes with extensive logging features allowing to debug problems associated with both itself and with Wine. zugbruecke is written using Python 3 syntax and primarily targets the CPython implementation of Python.
About Wine (from winehq.org): Wine (originally an acronym for “Wine Is Not an Emulator”) is a compatibility layer capable of running Windows applications on several POSIX-compliant operating systems, such as Linux, MacOS and BSD. Instead of simulating internal Windows logic like a virtual machine or emulator, Wine translates Windows API calls into POSIX calls on-the-fly, eliminating the performance and memory penalties of other methods and allowing you to cleanly integrate Windows applications into your desktop.
This project is NEITHER associated NOR affiliated in any way or form with the Wine project.
Prerequisites
for usage |
|
for tests |
|
for documentation |
|
Installation
branch |
status |
installation |
documentation |
master (release) |
pip install zugbruecke |
||
develop |
pip install git+https://github.com/pleiszenburg/zugbruecke.git@develop |
||
Examples
Start an interactive Python session on your favorite Unix(-like) operating system and try the following:
import zugbruecke as ctypes
dll_pow = ctypes.cdll.msvcrt.pow
dll_pow.argtypes = (ctypes.c_double, ctypes.c_double)
dll_pow.restype = ctypes.c_double
print('You should expect "1024.0" to show up here: "%.1f".' % dll_pow(2.0, 10.0))
You have just witnessed msvcrt.dll, Microsoft’s C standard library (or Wine’s implementation of it), in action on Unix.
Interested in more?
Check the examples in zugbruecke’s documentation,
Read ctypes’ documentation,
Beyond ctypes syntax, learn about memory synchronization with the memsync routine attribute [or]
Have a look at zugbruecke’s test suite showcasing its entire range of capabilities.
A lot of code, which was written with ctypes’ cdll, windll or oledll in mind and which runs under Windows, should run just fine with zugbruecke on Unix (assuming it does not use Windows features not supported by Wine). For more complex calls, memory synchronization is potentially necessary.
Speed
zugbruecke performs reasonably well given its complexity with less than 0.2 µs overhead per call in average on modern hardware. It is not (yet) optimized for speed. Check the latest benchmarks for more details.
Security
zugbruecke is notoriously insecure. Never, ever, run it with root / super users privileges! Do not use it where security matters! For details, check the section on security in the documentation.
Need help?
Feel free to post questions in the GitHub issue tracker of this project.
Bugs & issues
Report bugs in zugbruecke here: GitHub issue tracker
Report bugs in ctypes here: Python tracker
Report bugs in Wine here: WineHQ Bug Tracking System
Make sure you have read the chapter on bugs in zugbruecke’s documentation.
Miscellaneous
Full project documentation
Change log (current) (changes in development branch since last release)
Change log (past) (release history)
Contributing (Contributions are highly welcomed!)
License (LGPL v2.1)
Missing features (for full ctypes compatibility)
Upstream issues (relevant bugs in dependencies)
For production environments
DO NOT run this code (as-is) in production environments unless you feel that you really know what you are doing or unless you are absolutely desperate! Being experimental in nature and of alpha quality, it is prone to fail in a number of unpredictable ways, some of which might not be obvious or might not even show any (intermediately) recognizable symptoms at all! You might end up with plain wrong, nonsensical results without noticing it!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zugbruecke-0.0.13.tar.gz
.
File metadata
- Download URL: zugbruecke-0.0.13.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d35815cbcb3a63df2f870e44f57915865e9c8a6a925f5c7f46361f01241f49a |
|
MD5 | 2249ad1a25c6d56b36a41a44343d9662 |
|
BLAKE2b-256 | 537eddc1c0d63e701a52a47361ed5dd1e1c20d4dd3f22cd6b79d05b4e93c7661 |
File details
Details for the file zugbruecke-0.0.13-py3-none-any.whl
.
File metadata
- Download URL: zugbruecke-0.0.13-py3-none-any.whl
- Upload date:
- Size: 71.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc290041ec08517a6f092cb33419d3741e10e283138fc6264b280573b7f8ea75 |
|
MD5 | 998da5c2c86300d5f74bb6c8caf215c4 |
|
BLAKE2b-256 | f3132f8c37640cfb37e2f697bc62359d25d60b2fdd948e47746409a3c244c0ba |