How would a Python script running on Linux call a routine in a Python script running under Wine?
You can use the XMLRPC client and servers built-in Python's stdlib to do what you want. Just make your Wine-Python expose the desired functions as XMLRPC methods, and make an inter-process call from any other Python program to that.
It also works for calling functions running in Jython or IronPython from CPython, and also across Python2 and Python3 - the examples included in the module documentation themselves should be enough.Just check the docs: https://docs.python.org/2/library/xmlrpclib.html
If you need the calls to be asynchronous on the client side, or the server site to respond to more than one process, you can find other frameworks over which to build the calls - Celery should also work across several different Pythons while preserving call compatibility, and it is certainly enough performance-wise.
How to call Wine dll from python on Linux?
Doesn't Wine provide *.so
versions of the dlls? I seem to have /usr/lib32/wine/advapi32.dll.so
, for example.
If you're on a 64-bit machine, keep in mind that you'll need a 32-bit version of Python to load 32-bit libraries.
Packaging a Python script on Linux into a Windows executable
Did you look at PyInstaller?
It seems that versions through 1.4 support cross-compilation (support was removed in 1.5+). See this answer for how to do it with PyInstaller 1.5+ under Wine.
Documentation says:
Add support for cross-compilation: PyInstaller is now able to build Windows executables when running under Linux. See documentation for more details.
I didn't try it myself.
I hope it helps
Python subprocess.check_call([wine]..) has a synchronization issue
My understanding is that the wine
executable is not the actual emulator - it just launches a background process called wineserver
if it's not already running, tells it to run the Windows program, and then immediately exits itself - quite possibly before the Windows program has even started running.
One of the answers to this question suggests that piping the output of wine
to another program will delay things until the Windows program actually exits. In Python terms, this would be equivalent to using check_output()
instead of check_call()
, although I haven't tried this myself.
Invoking Wine From Apache
It's probably because $HOME
isn't set correctly...
Btw. Are you really sure invoking wine from mod_python is a good idea?
If you are sure, something like that could work...
from subprocess import Popen
HOME = '/the/home/of/www-data' #PLEASE edit
proc = Popen(cmd, shell=False, stdin=PIPE,
stdout=PIPE, stderr=PIPE, close_fds=True,
cwd=HOME, env={"HOME":HOME)
Related Topics
How to Retrieve the Process Start Time (Or Uptime) in Python
Setting Ld_Library_Path from Inside Python
Find the Oldest File (Recursively) in a Directory
Default Buffer Size for a File on Linux
Getting Another Program's Output as Input on the Fly
Running Process of Remote Ssh Server in the Background Using Python Paramiko
Mismatch Between Sys.Executable and Sys.Version in Python
Groupby Weighted Average and Sum in Pandas Dataframe
How to Setup Environment Variable R_User to Use Rpy2 in Python
What Are Python Pandas Equivalents for R Functions Like Str(), Summary(), and Head()
Why Xgrabkey Generates Extra Focus-Out and Focus-In Events
"E: Unable to Locate Package Python-Pip" on Ubuntu 18.04
How to Obtain Ports That a Process in Listening On
Pip Install Unable to Find Ffi.H Even Though It Recognizes Libffi