Search code examples
pythonpyc

Python: can 2.X be patched so as to totally ignore *.pyc files?


executive summary: python lib on NFS, duelling pythons 2.6 and 2.7.

context: several groups maintain their own python interpreters, but access common python libraries on an NFS server.

Is there an easy way to build python so that it ignores pyc files? It's not practical to try and ensure that every script is executed with a -B option.

It seems to be the actual statting to see if the files exist that is causing the NFS load.


Solution

  • If the oldest python being run is at least 2.6, no patching is necessary.

    Add

    import sys
    sys.dont_write_bytecode = True
    

    to

    site-packages/usercustomize.py