Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 21st, 2006, 10:02 PM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 855
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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?
titaniumdecoy is offline   Reply With Quote
Old Jun 21st, 2006, 10:10 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,884
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Jun 22nd, 2006, 9:12 AM   #3
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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.
Game_Ender is offline   Reply With Quote
Old Jun 22nd, 2006, 3:54 PM   #4
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 855
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Thanks for the replies, Sane and Game Ender.

Sane, I think you mixed up '\n' and '\r\n' in your explanation.
titaniumdecoy is offline   Reply With Quote
Old Jun 22nd, 2006, 5:30 PM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,884
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Jun 22nd, 2006, 5:53 PM   #6
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 855
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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
titaniumdecoy is offline   Reply With Quote
Old Jun 22nd, 2006, 5:55 PM   #7
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,884
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to 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.
Sane is offline   Reply With Quote
Old Jun 22nd, 2006, 8:58 PM   #8
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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.
Game_Ender is offline   Reply With Quote
Old Jun 22nd, 2006, 9:05 PM   #9
Yegg
Newbie
 
Join Date: Jan 2006
Posts: 20
Rep Power: 0 Yegg is on a distinguished road
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.
Yegg is offline   Reply With Quote
Old Jun 23rd, 2006, 4:02 AM   #10
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC