Are .pyc files portable?
Lie Ryan
lie.1296 at gmail.com
Sun Nov 9 05:36:56 EST 2008
On Fri, 07 Nov 2008 18:36:41 -0800, Roy Smith wrote:
> I'm using Python as part of a test fixture for a large (mostly C++)
> software project. We build on a lot of different platforms, but Solaris
> is a special case -- we build on Solaris 8, and then run our test suite
> on Solaris 8, 9, and 10. The way the build system is set up (driven by
> Build Forge), the Sol 8, 9, and 10 test passes can happen in any order.
> The tests all run in a common directory, shared by NFS on all three
> machines.
>
> If (for example) the Sol 10 tests run first, and create .pyc files, will
> those .pyc files work correctly when the Sol 8 and Sol 9 test passes
> come along and run them in the same directories?
>
> The python binary is a build of 2.5.1 that we did on Solaris 8. The
> same binary is used on all Solaris platforms. Although we do separate
> 32-bit and 64-bit builds of our product, the python binary we use for
> the test driver is the same 32-bit build on all of them.
>
> A related question: is there any way to tell Python to put the .pyc
> files in some other directory, i.e. NOT the same directory where the .py
> sources are. That would make things cleaner, since we could just tell
> each system to put its .pyc's in a different place.
>
> We've also got some games we play with symlink farms (lndir), which may
> be part of the solution here, but I want to explore all the
> possibilities first.
If all that responses confuse you, the simple answer is:
1. Python bytecode is cross-platform
2. but is not cross-version
i.e. as long as the .pyc can be run accross different platforms as long
as the version number of the compiling python and executing python is
equal.
A simple solution if you've got different version of python across many
platform is to provide a .py file that redirects the program to each
version-specific .pyc (cross-platform and cross-version if written with
some care)
More information about the Python-list
mailing list