Skip to main content

Calling routines in Windows DLLs from Python scripts running under Linux, MacOS or BSD

Project description

Build Status: master / release Documentation Status: master / release Build Status: development branch Documentation Status: development branch Project License: LGPLv2 Project Development Status Available on PyPi - the Python Package Index Available on PyPi - the Python Package Index

zugbruecke repository

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

  • CPython 3.x (tested with 3.{4,5,6,7}) - no additional Python packages required

  • Wine 2.x/3.x/4.x (tested with regular & staging) - expected to be in the user’s PATH

for tests

for documentation

Installation

branch

status

installation

documentation

master (release)

Build Status: master / release

pip install zugbruecke

Documentation Status: master / release

develop

Build Status: development branch

pip install git+https://github.com/pleiszenburg/zugbruecke.git@develop

Documentation Status: development branch

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?

A lot of code, which was written with ctypescdll, 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

Make sure you have read the chapter on bugs in zugbruecke’s documentation.

Miscellaneous

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!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zugbruecke-0.0.15.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

zugbruecke-0.0.15-py3-none-any.whl (71.1 kB view details)

Uploaded Python 3

File details

Details for the file zugbruecke-0.0.15.tar.gz.

File metadata

  • Download URL: zugbruecke-0.0.15.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for zugbruecke-0.0.15.tar.gz
Algorithm Hash digest
SHA256 9c95457682a2bb148cf772b814e4f917741bb73c8886cb2461d4abffe19b42b5
MD5 3511e9d1b401d1bfe1ab5bd1b43b8352
BLAKE2b-256 8375d3b13f814e05dfec3d5dac8609deff3a5e852ce7279a3ebf70d262c219aa

See more details on using hashes here.

File details

Details for the file zugbruecke-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: zugbruecke-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 71.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for zugbruecke-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 4be331823196b257be28c0ee8a35a4dcf75c9883686c562d34b54eef76f24960
MD5 621a79926d47ee37618362c9df55c967
BLAKE2b-256 68e77ba9dacbb34822bf5fc453704ba3c35453d2250d33aa705e45f0ca4b9309

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page