On Fri, Oct 14, 2011 at 1:31 PM, Chris Rebert <c...@rebertia.com> wrote: > On Fri, Oct 14, 2011 at 11:04 AM, Terry <twest...@gmail.com> wrote: >> I'm having a problem with my iPhone/iPad app, Python Math, a Python >> 2.7 interpreter. All the Python modules are delivered in what Apple >> calls the app bundle. They are in a read-only directory. This means >> that Python cannot write .pyc files to that directory. (I get a deny >> write error when doing this.) I tried using compileall to precompile >> all the modules, but now I get an unlink error because Python >> apparently wants to rebuild the .pyc files. > > You can stop Python from trying to write .pyc files by using the > environment variable PYTHONDONTWRITEBYTECODE, the interpreter's -B > command line option, or by setting sys.dont_write_bytecode to True.
This won't make Python use the .pyc files provided, though. It will just recompile the .py files and then not try to write out the bytecode. If you really want to force it to use the .pyc's, then don't include the .py files. Note that if you do this, you'll need to make sure that the version of Python used to compile the .pyc files is the same minor release as the version used to run them (more specifically, the two versions must return the same string from imp.get_magic()). HTH, Ian -- http://mail.python.org/mailman/listinfo/python-list