![]() |
Compiled Python code dependencies
I am considering writing an application in Python that would use wxPython for a GUI, Cheetah for making use of HTML templates, etc. My question is, once the program is written, will any computer I want to run it on need to have Python, wxPython, Cheetah, etc. installed? Or is there a way to compile it (using py2exe/py2app, for example) so that it can run on any computer?
|
When you compile it using py2exe, it should automatically package everything that you need. There are only certain situations where you might need to specify something extra to bundle, like the windows XP style with wxpython (search the python forums).
The only time that you run in to an issue involving running a python script on a different computer, is if you're doing something os-dependant, like system('cls'), or using a windows newline '\n' as opposed to the standard linux CRLF '\r\n'. Or perhaps doing something like sniffing traffic, which is handled differently in Linux than Windows. Basically any problems with running it on a different computer has something to do with using non cross-platform compatible functions. The compiled exe with py2exe has the python interpretor and all the script's libraries included. Most, if not all, of your programs should be natively compatible. |
Just to clarify, your program is not turned into native code. Its still python bytecode. From how I understand py2exe, py2app and freeze create an executable with python and all the needed libraries in embedded in it. This is why you might notice large executable size for you program.
|
Thanks for the replies, Sane and Game Ender.
Sane, I think you mixed up '\n' and '\r\n' in your explanation. |
Nah. When I switched a program over from Windows to Linux, Linux was not registering a plain '\n' as a new line when streaming to a binary file. I had to make it '\r\n' to work.
|
Check Wikipedia:
Quote:
|
I don't care what Wikipedia says. I'm stating what I had to do. That's what I know, and I know that's what happened.
|
Regardless to what your problem was, LF is the proper Unix/Linux line endings. You can look at the subversion manual which goes on in depth about there system to keep these straight. I have also opened windows files in emacs and seen all the ^M that the '\r' were turned into.
|
Quote:
|
Quote:
Why Python would be acting like that, I couldn't say. However, everyone else is correct in saying that the Linux newline delimiter is \n, whilst the Windows one is \r\n. Something else must have been going on if you needed to apply the Windows delimiter to Linux and vice versa. |
| All times are GMT -5. The time now is 8:03 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC