469,913 Members | 2,475 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

Are ActivePython scripts compatible with Linux?

A.M
Hi,

I am planning to develop python applications on windows and run them on
Linux. Are ActivePython scripts compatible with Linux? Is there any
guideline that explains the compatibility issues between python in different
platforms?

What would be the best approach for what I am trying to do?

Any help would be appreciated,

Alan
May 31 '06 #1
3 1539
Short answer: yes

Things to watch out for:

1) Versions on both Windows/Linux need to be compatible. If Linux
has same or later version, you are normally OK. If Linux version
is older, you will have to use only Python Libraries and functions
that are in the oldest version.

2) Don't use OS-specific constructs. Things like backslashes
in filenames, etc. Use os.path.join, os.path.basename, etc. to work
with paths. Linux has OS-specific code that handles all the
cross-OS problems for you if you use these methods. Don't hard
code drive letters in your code, Linux/Mac don't have drive letters.

3) Obviously you can't use Python Windows extensions, which won't
port. You can't move something that is written as COM object or
as a Windows service (sorry those were probably too obvious ;-).

4) If you use GUI, use something that is cross-platform (like
wxWindows, TK, etc.). You can't use Windows-specific GUI calls.

5) You can be affected by word length issues if you move from
32-bit Windows to 64-bit Linux. Normally this is only only
a problem if you use struct module to pack/unpack buffers or if
you do bit shift operations (e.g. <<, >>).

6) Don't depend on Windows line endings in files. Linux/Mac
use different ones than Windows.

7) Some Linux machine have different endian storage of bytes.
If you do bit shifting or struct pack/unpack you will need to
take that into account.

8) If you have OS-specific "things" in your code, put them in
a function or class that can easily be rewritten for the
specific OS you are porting to. Don't spread them out all
through your code. It is much easier to rewrite a couple of
functions/classes that are OS-specific than it is to try to
find problems all over your program.

Hope info helps at least a little.

-Larry
A.M wrote:
Hi,

I am planning to develop python applications on windows and run them on
Linux. Are ActivePython scripts compatible with Linux? Is there any
guideline that explains the compatibility issues between python in different
platforms?

What would be the best approach for what I am trying to do?

Any help would be appreciated,

Alan

May 31 '06 #2
A.M
Thanks alot Larry for your comprehensive answer.

"Larry Bates" <la*********@websafe.com> wrote in message
news:SY******************************@comcast.com. ..
Short answer: yes

Things to watch out for:

1) Versions on both Windows/Linux need to be compatible. If Linux
has same or later version, you are normally OK. If Linux version
is older, you will have to use only Python Libraries and functions
that are in the oldest version.

2) Don't use OS-specific constructs. Things like backslashes
in filenames, etc. Use os.path.join, os.path.basename, etc. to work
with paths. Linux has OS-specific code that handles all the
cross-OS problems for you if you use these methods. Don't hard
code drive letters in your code, Linux/Mac don't have drive letters.

3) Obviously you can't use Python Windows extensions, which won't
port. You can't move something that is written as COM object or
as a Windows service (sorry those were probably too obvious ;-).

4) If you use GUI, use something that is cross-platform (like
wxWindows, TK, etc.). You can't use Windows-specific GUI calls.

5) You can be affected by word length issues if you move from
32-bit Windows to 64-bit Linux. Normally this is only only
a problem if you use struct module to pack/unpack buffers or if
you do bit shift operations (e.g. <<, >>).

6) Don't depend on Windows line endings in files. Linux/Mac
use different ones than Windows.

7) Some Linux machine have different endian storage of bytes.
If you do bit shifting or struct pack/unpack you will need to
take that into account.

8) If you have OS-specific "things" in your code, put them in
a function or class that can easily be rewritten for the
specific OS you are porting to. Don't spread them out all
through your code. It is much easier to rewrite a couple of
functions/classes that are OS-specific than it is to try to
find problems all over your program.

Hope info helps at least a little.

-Larry
A.M wrote:
Hi,

I am planning to develop python applications on windows and run them on
Linux. Are ActivePython scripts compatible with Linux? Is there any
guideline that explains the compatibility issues between python in
different
platforms?

What would be the best approach for what I am trying to do?

Any help would be appreciated,

Alan

May 31 '06 #3
A.M wrote:
I am planning to develop python applications on windows and run them on
Linux. "Larry Bates" <la*********@websafe.com> wrote in message
news:SY******************************@comcast.com. ..
Short answer: yes

A.M wrote: Thanks alot Larry for your comprehensive answer.


Small addition: test, test, test. This is the only way to make sure
your program works on another platform. VMware is offering now free
virtual machine emulator, vmplayer. You have no excuse not to install
linux! :) If you have dual-core processor or an idle machine you can
even setup http://buildbot.sf.net to continuously test your source code
changes.

May 31 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by JZ | last post: by
1 post views Thread by Justin Stockton | last post: by
4 posts views Thread by Hoang | last post: by
1 post views Thread by Steve M | last post: by
1 post views Thread by Fuzzyman | last post: by
5 posts views Thread by Frank Swarbrick | last post: by
3 posts views Thread by kodaliece | last post: by
14 posts views Thread by Trent Mick | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.