PyWine - Containerized Wine with Python to test project under Windows environment
Posted by tymonx@reddit | Python | View on Reddit | 8 comments
- What My Project Does - PyWine allows to test Python code under Windows environment using containerized Wine. Useful during local development when you natively use Linux or macOS without need of using heavy Virtual Machine. Also it can be used in CI without need of using Windows CI runners. It unifies local development with CI.
- Target Audience - Linux/macOS Python developers that want to test their Python code under Windows environment. For example to test native Windows named pipes when using Python built-in multiprocessing.connection module.
- Comparison - https://github.com/webcomics/pywine, project with the same name but it doesn't provide the same seamless experience. Like running it out-of-box with the same defined CI job for
pytest
or locally without need of executing some magic script like/opt/mkuserwineprefix
- Check the GitLab project for usage: https://gitlab.com/tymonx/pywine
- Check the real usage example from gitlab.com/tymonx/pytcl/.gitlab-ci.yml with GitLab CI job pytest-windows
loyoan@reddit
This is really useful! We are using something similar by tobix/pywine:3.13 for compiling PyInstaller Windows builds. Is yours different?
RedEyed__@reddit
That's great idea, thanks!
Fluid_Classroom1439@reddit
This looks super useful! I imagine it should work out of the box with GitHub actions as well right?
PlasticSoul266@reddit
But you're not testing a real Windows environment; you're just testing the Wine APIs. How useful is that?
tymonx@reddit (OP)
u/PlasticSoul266 True, it is not a real Windows environment. But Python correctly identify environment running under Wine as Windows and it will use Windows specific capabilities. Like Windows named pipes
\\.\pipe\<name>
by multiprocessing.connection module.In my opinion, it is still quiet useful. Not so long ago, someone asked me to add support for Windows in my another project PyTCL. In short, PyTCL allows to control EDA tools (FPGA, ASIC, ...) from Python that are TCL oriented. To achieve that, I was originally using Unix socket to make IPC (Inter-Process Communication) between Python and TCL. Because I'm a Linux only user, I wanted to test it properly. PyWine allowed me to run the same set of tests with Windows specific capabilities like Windows named pipes. Also with PyWine I was able detect and fix some misaligned between Unix and Windows environment when using TCL.
At the end, that user of PyTCL was able to ran it under real Windows system without any issues. And we didn't waste both of our time in back-to-back comments in Merge Requests or over chat.
GitLab Merge Request as reference to above story https://gitlab.com/tymonx/pytcl/-/merge_requests/1 That silly fix in TCL from
concat
tolist
was nasty. Linux happy, Windows not :/Dubsteprhino@reddit
Why not use a windows container in docker compose?
tymonx@reddit (OP)
u/Dubsteprhino Windows containers can be run only on native Windows because containers use the same kernel as the main host system. Without using Virtual machine/KVM on Linux, it is not possible to run Windows containers. For local development, still you need to obtain some kind of Windows ISO image with paid license that must be run on KVM/QEMU/libvirt.
Dubsteprhino@reddit
I stand corrected, thank you. TIL