py2exe is great, and I use it whenever I want to package up a python program to run on a Windows system.
My question is, is there an equivalent tool that I can use to package up the program on Windows, but that I can then run on Linux?
here is also PyInstaller that supports Linux, MacOS and Windows - I have not used it (yet) so I don't know if you can package stuff on windows for linux, but glancing over the manual it seems to be possible.
EDIT: The FAQ states explicitly that you can not create a windows package from linux and no mac os package from linux neither - there is nothing about creating a linux package from the other two sources, but it might not work.
EDIT2: After googling a bit I found cx_freeze which might also be worth a look.
I really doubt that you can do something like that at all.
What you could do is just configure yourself 3 build VMs one for Windows, one for MacOS and one for Linux that have everyhing you need to run your program.
Then use either a combination of py2exe/py2app/pyinstaller to generate a distribution for each of the platforms. You will have 3 different pacakges but each one of them will be nicely packed and with no need to install anything else on the client machines.
Ok, I've done this. It's a little hacky, but it works very well for my use case.
The gist of it is to use ModuleFinder to find all imported modules, filter out any system ones, compile them and zip them up.
Unfortunately my code for this is littered with additional complications that don't have any relevance to this question, so I can't paste a working program, just some snippets:
zipfile = ZipFile(os.path.join(dest_dir, zip_name), 'w', ZIP_DEFLATED)
sys.path.insert(0, '.')
finder = ModuleFinder()
finder.run_script(source_name)
for name, mod in finder.modules.iteritems():
filename = mod.__file__
if filename is None:
continue
if "python" in filename.lower():
continue
subprocess.call('"%s" -OO -m py_compile "%s"' % (python_exe, filename))
zipfile.write(filename, dest_path)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With