Cross platform py2exe alternative

py2exe is excellent, and I use it whenever I want to package a python program to run on a Windows system.

My question is, is there an equivalent tool that I can use to package a program on Windows, but what can I run on Linux?

+13
source share
3 answers

Ok, I did it. It is a bit hacky, but it works great for my use.

Its essence is to use ModuleFinder to find all imported modules, filter out any system modules, compile them, and pin them.

Unfortunately, my code for this is studded with additional complications that have nothing to do with this issue, so I canโ€™t insert a working program, just some fragments:

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) 
+1
source

here is also PyInstaller , which supports Linux, MacOS and Windows - I have not used it yet (yet), so I donโ€™t know if you can package things in windows for linux, but looking at manual it seems possible.

EDIT: The FAQ explicitly states that you cannot create a Windows package from linux and without the mac os package from linux - there is nothing about creating linux from two other sources, but this may not work.

EDIT2: After a little search, I found cx_freeze , which may also be worth a look.

+6
source

I really doubt that you can do something like this.

What you can do is simply configure your own 3 built-in virtual machines for Windows, one for MacOS and one for Linux, which has everything you need to run your program.

Then use the combination py2exe / py2app / pyinstaller to create a distribution for each platform. You will have 3 different pacakges, but each one will be well packaged and without the need to install anything else on client machines.

+5
source

All Articles