简体   繁体   中英

how to compile a python .app from ubuntu or windows

I am still very new to Python and any freezing programs.

Recently I made a very short text adventure game I'd like to send to a few friends, most of whom have Snow Leopard. I don't want them to have to bother downloading python just to play the game though.

Is there a way to convert my game from Ubuntu so that it is playable on Mac? That is, make an.app file from ubuntu? Or even from Windows, I suppose.

I tried using cx_freeze on Windows but that just compiles an exe which is not playable on Mac.

Thanks for any help and suggestions.

EDIT: I am using Python 3.2.2. I think Macs come standard with an older version else there would be no problem just sending them the game, I imagine.

As far as I remember, last I used Mac OSX, it already had Python installed. This was with Mac OSX Snow Leopard.

No need do compile to a native binary if you can run your code through Python on any machine.

Your code could run in Python 2.6, the default which comes with Snow Leaopard, unless you used version 3 specific features. Try if it does. If so just package your code so it runs the.py through python /path/to/code.py

You can also make your.py file self-executable with a shebang first line,

#! /usr/bin/env python
# this should be the first line in your .py file

and setting the file executable flag, perhaps through your packager on installation:

$ chmod +x code.py

You will notice shebang does not point to a specific python binary like /usr/bin/python , but to the /env environment path, so it will use the default interpreter on whichever machine it is run on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM