Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   Compiled Python code dependencies (http://www.programmingforums.org/showthread.php?t=10483)

titaniumdecoy Jun 21st, 2006 11:02 PM

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?

Sane Jun 21st, 2006 11:10 PM

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.

Game_Ender Jun 22nd, 2006 10:12 AM

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.

titaniumdecoy Jun 22nd, 2006 4:54 PM

Thanks for the replies, Sane and Game Ender.

Sane, I think you mixed up '\n' and '\r\n' in your explanation.

Sane Jun 22nd, 2006 6:30 PM

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.

titaniumdecoy Jun 22nd, 2006 6:53 PM

Check Wikipedia:

Quote:

Originally Posted by Wikipedia
LF: Unix and Unix-like systems, Linux, AIX, Xenix, Mac OS X, BeOS, Amiga, RISC OS and others
CR+LF: CP/M, MP/M, DOS, Microsoft Windows


Sane Jun 22nd, 2006 6:55 PM

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.

Game_Ender Jun 22nd, 2006 9:58 PM

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.

Yegg Jun 22nd, 2006 10:05 PM

Quote:

Originally Posted by Game_Ender
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.

In an attempt to make it sound simpler: py2exe (plus others) puts the Python interpreted inside of an executable and relies on files outside of the executable to do things.

Arevos Jun 23rd, 2006 5:02 AM

Quote:

Originally Posted by Sane
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.

How strange. The only thing I can think of is that you were sending data across a network. IIRC, HTTP, SMTP and other protocols of similar era, use \r\n as the line delimiter. Perhaps Python automatically converted the newline characters to their native equivalent, so that under Windows it became \r\n, and under Linux \n. If that was the case, then you'd need to add an extra specific \r to the Linux version.

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