Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-compiling in Python in Windows TO Linux/OSX

I have a program I've written in Python 2.7 on Windows, and I've been using py2exe with total success to make it into an exe (and associated files). However, a reasonable number of people who I want to use it are on Linux/OSX, and while some have been able to make the Windows version work with Wine, others have not been so successful. I've looked thoroughly into py2installer, py2app, freeze and others, but if I understand correctly (I am new to Python and very new to compiling) you need to run them on the system you want to compile them for, i.e. you can only compile for Linux on Linux and OSX on OSX. I don't want to distribute just the raw files because I want the source code to be obfuscated as it is inside a .exe, amd obviously not everyone has Python.

So, my question is: is there any way to compile for OSX or Linux, in Python, while on a Windows machine? And if not, what do you think the best alternative solution might be?

like image 936
UltimaRatioRegum Avatar asked Jan 26 '26 14:01

UltimaRatioRegum


2 Answers

  1. Code obfuscation is really not 'pythonic'. Even when packed into an .exe file, it's basically just the python interpreter and you source code (well, the .pyc files) zipped into one file. It is not as much as cross-compiling as it is about using a python package which does the thing you want (e.g, pack you code in a specific way) on linux. Freeze will do this for you.

  2. Most linux dists come with python built-in.

  3. Get your linux box running! It's fun, useful, and you can always say 'On My Machine It Works!'. You can compile your code there / test your exe on Wine.

  4. If for some reason you still can't get it to run, post a question!

like image 140
Ohad Avatar answered Jan 29 '26 02:01

Ohad


Get Virtualbox, install Ubuntu in it, and build it "natively" in for Linux. These things work really well, and cross compilation is just asking for trouble. You're going to eventually need Linux to answer the support questions you'll get from these customers anyway! :(

like image 44
Ned Batchelder Avatar answered Jan 29 '26 03:01

Ned Batchelder