How Would a Python Script Running on Linux Call a Routine in a Python Script Running Under Wine

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



Leave a reply



Submit