3

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?

3
  • You might be able to compile for linux by running under an environment like cygwin and using the linux compiler. A virtual machine would also work but it would be a bit more cumbersome. Commented Jul 11, 2012 at 16:42
  • 2
    As to "not everyone has Python", I think there will be few Linux or OSX installations that don't have Python of one version or another. Commented Jul 11, 2012 at 18:04
  • Interesting - thanks both. I might try the virtual machine idea, and I'll get back on that. Commented Jul 12, 2012 at 10:20

2 Answers 2

2
  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!

Sign up to request clarification or add additional context in comments.

3 Comments

Again, though, freeze needs me to be on Linux (doesn't it?) but I'll definitely give freeze a shot with a Linux USB. The thing is, having never even touched a virtual machine before and knowing 0 about them, it seems like such an investment of effort and mental energy for a single use, ie compiling one program in that system. That's why I'm hoping something can be solved on a friend's Mac/Linux, and without me having to virtual machine it. Anyway, I'll report back...
Addendum - people have managed to get the .exe working with wine, winetricks and vcrun2008, but I'm not sure (knowing nothing about wine) how 'easy' or difficult a solution that is for people.
If you change your mind, this can help your setup an Ubuntu virtual machine on windows, and it is fairly easy. Good luck!
2

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! :(

1 Comment

Ah, true! A friend has Linux on a USB, so I'm going to give that a shot later (I've never touched Linux before), and see if that's sufficient for compiling, testing, etc...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.