1

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.

Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
  • Did you see http://stackoverflow.com/a/154617/2588818? As with other commenters there, `-B` doesn't work for me but the environment variable does. – Two-Bit Alchemist Mar 05 '15 at 05:12
  • Yes, I did see that. Our problem is that we have many ad hoc and one-off scripts that are sent to a compute farm, too many to try and enforce the setting of environment variables, etc. So it would be great if we could talk to each of the teams and have their python executable set this. – Mark Harrison Mar 06 '15 at 01:03
  • @Mark I was thinking along the lines of [another answer](http://stackoverflow.com/a/9562273) from the above - note the part about `usercustomize` in the comments... not sure if that's feasible given your scenario though... – Jon Clements Mar 06 '15 at 01:14
  • There's also a comment on the answer I linked about a flag you can set if you're embedding the interpreter. Don't know if that's something you would be able to use in your setup. – Two-Bit Alchemist Mar 06 '15 at 17:34
  • Thanks all, those pointers are great. I've summarized the (pleasingly simple) answer below. – Mark Harrison Mar 07 '15 at 23:00

1 Answers1

0

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
Mark Harrison
  • 297,451
  • 125
  • 333
  • 465