Are .pyc files portable?

Roy Smith roy at panix.com
Fri Nov 7 21:36:41 EST 2008


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.




More information about the Python-list mailing list