[Pythonmac-SIG] py2app: how to force packages into application bundle?

weddingmusic at partybombe.de weddingmusic at partybombe.de
Tue Sep 16 14:55:41 CEST 2008


thanks Joe,
i modified setup.py to:

#!/usr/bin/env python
from setuptools import setup
import py2app

setup(
    app=['myApp.py'],
    options=dict(
        py2app=dict(
            packages=['mechanize'],
            site_packages=True,
        ),
    ),
)

running:
/usr/local/bin/python setup.py py2app

gets me the following output:
running py2app
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.6-py2.5.egg/py2app/build_app.py", line 548, in _run
    self.run_normal()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.6-py2.5.egg/py2app/build_app.py", line 600, in run_normal
    mf = self.get_modulefinder()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.6-py2.5.egg/py2app/build_app.py", line 508, in get_modulefinder
    debug=debug,
  File "build/bdist.macosx-10.3-i386/egg/modulegraph/find_modules.py", line 243, in find_modules
    find_needed_modules(mf, scripts, includes, packages)
  File "build/bdist.macosx-10.3-i386/egg/modulegraph/find_modules.py", line 179, in find_needed_modules
    path = m.packagepath[0]
TypeError: 'NoneType' object is unsubscriptable
> /Users/me/python_test/build/bdist.macosx-10.3-i386/egg/modulegraph/find_modules.py(179)find_needed_modules()
(Pdb)

please allow some more questions:
1) is it correct that there is a directory "build/bdist.macosx-10.3-i386"? (I'm running macosx 10.4.11)
2) i want to use python 2.5.2 which i installed in "/Library/Frameworks/Python.framework/Versions/2.5"
i do not want to use the system installed python 2.3.5 in "/System/Library/Frameworks/Python.framework/Versions/2.3"
is it correct to set PYTHONPATH to "/Library/Frameworks/Python.framework/Versions/2.5" in ~/.MacOSX/environment.plist ?
does the first line in my setup.py probably refere to a wrong python2.3?
3) did i install the mechanize package correct, when i find the file "mechanize-0.1.8-py2.5.egg" in "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages"?

hope to get some more help
greets
axel

-------- Original-Nachricht --------
> Datum: Mon, 15 Sep 2008 11:36:45 -0400
> Von: Joe Losco <joelosco at frontiernet.net>
> An: weddingmusic at partybombe.de
> CC: pythonmac-sig at python.org
> Betreff: Re: [Pythonmac-SIG] py2app: how to force packages into application bundle?

> On Sep 15, 2008, at 10:36 AM, weddingmusic at partybombe.de wrote:
> >
> > setup.py looks like this:
> > [code]
> > from setuptools import setup
> >
> > APP = ['myApp.py']
> > DATA_FILES = []
> > OPTIONS = {'argv_emulation': True}
> >
> > setup(
> >    app=APP,
> >    data_files=DATA_FILES,
> >    options={'py2app': OPTIONS},
> >    setup_requires=['py2app'],
> > )
> > [/code]
> >
>
> I had an app that I needed to include other modules.  I think you need  
> to add some lines to your options area of your setup.py.
> You have the argv_emulation but not site_packages which allows your  
> Pythonpath to be explored or the specific packages that you wish to  
> include specifically.
>
> My Setup.py file is included below for reference.   I made mine a kind  
> of default that I include in my packages that I only really need to  
> modify a couple of variable for my builds.
> Hope this helps some.
>
> Joe Losco
>
>
>
> #!/usr/bin/env python
> """
> setup.py - script for building MyApplication
>
> Usage:
>      % python setup.py py2app
> """
> from distutils.core import setup
> import py2app
> from plistlib import Plist
> import os
>
> name = 'CalendarSync'
> version = '1.0.0'
> Icon = name+".icns"
>
> # Build the .app file
> setup(
>      app=[ name + '.py' ],
>      options=dict(
>          py2app=dict(
>              iconfile=Icon,
>              packages=['wx','appscript'],
>              site_packages=True,
>              resources=['resources/COPYING',Icon],
>              plist=dict(
>                  CFBundleName               = name,
>                  CFBundleShortVersionString = version,     # must be  
> in X.X.X format
>                  CFBundleGetInfoString      = name+" "+ version,
>                  CFBundleExecutable         = name,
>              ),
>          ),
>      ),
>
> )


More information about the Pythonmac-SIG mailing list