[Pythonmac-SIG] buildapp.py --standalone with -O

Bob Swerdlow rswerdlow at transpose.com
Wed Nov 12 14:16:07 EST 2003


I've been able to build my application standalone with the optimizer flag
(-O) on, but only with a nasty hack.  I'm hoping you can point me to a
better solution.

Previously, I built the application with this command:
    python
buildapp.py -v --standalone --package=encodings --package=_strpTime --packag
e=urllib2 build
and it worked fine.

However, when I changed this to:
    python -O
buildapp.py -v --standalone --package=encodings --package=_strpTime --packag
e=urllib2 build
I got these errors:
    'import site' failed; use -v for traceback
    Traceback(most recent call last):
    file "./build/MyApp.app/Contents/Resources/myapp.py", line 6, in ?
        import copy
    ImportError: No module named copy

The "import copy" problem is simply cascaded off the "import site" problem.
A site.pyo file was generated in the /build/MyApp.app/Contents/Resources/
folder, but it is obviously not being used properly.

To get it to work, I first built the application without the -O flag, saved
the site.pyc file, then built it again with the -O flag and restored the
site.pyc file.  With this hack, the application works fine.

Changing the CFBundleExecutable string in the infoPList to "python -O" did
not help - I don't think this is used for standalone applications.

So, here are my questions:
1. Is a standalone application that is build optimized launched with the
"-O" optimization flag on?
2. If not, is there a way to get it to launch with that flag on?
3. If so, would the site.pyo file be properly read or would we still need
the site.pyc file?

Bottom line: is there some work-around for this hack of building twice and
saving the site.pyc file?

Thanks for your help.

Bob Swerdlow
COO
Transpose
rswerdlow at transpose.com
207-781-8284
http://www.transpose.com

----------------------------------
Fight Spam!
Add this link to your signature (as I did): http://wecanstopspam.org
Click through to find out more.
----------------------------------





More information about the Pythonmac-SIG mailing list