py2app semi-standalone semi-works

Discussion in 'Python' started by James Stroud, Oct 4, 2006.

  1. James Stroud

    James Stroud Guest

    Hello All,

    I am trying to create a semi-standalone with the vendor python on OS X
    10.4 (python 2.3.5). I tried to include some packages with both
    --packages from the command and the 'packages' option in setup.py. While
    the packages were nicely included in the application bundle in both
    cases (at Contents/Resources/lib/python2.3/), they were not found by
    python when the program was launched, giving the error:

    "ImportError: No module named [whatever module]"

    Is this because semi-standalone is semi-broken or is it because I have
    semi-omitted something?

    Any advice on resolving this issue would be greatly appreciated and
    would greatly reduce the size of the download.

    James
     
    James Stroud, Oct 4, 2006
    #1
    1. Advertising

  2. James Stroud

    Dave Opstad Guest

    In article <ulMUg.13149$>,
    James Stroud <> wrote:

    > I am trying to create a semi-standalone with the vendor python on OS X
    > 10.4 (python 2.3.5). I tried to include some packages with both
    > --packages from the command and the 'packages' option in setup.py. While
    > the packages were nicely included in the application bundle in both
    > cases (at Contents/Resources/lib/python2.3/), they were not found by
    > python when the program was launched, giving the error:
    >
    > "ImportError: No module named [whatever module]"
    >
    > Is this because semi-standalone is semi-broken or is it because I have
    > semi-omitted something?
    >
    > Any advice on resolving this issue would be greatly appreciated and
    > would greatly reduce the size of the download.


    You might want to have a setup.cfg file in addition to the setup.py
    file. I've found that helps ensure the relevant packages and includes
    make it into the bundled application.

    For example, say you have a package named fred and also a separate
    module named george that are needed for your app. Your setup.cfg could
    look like this:

    #
    # setup.cfg
    #

    [py2app]
    packages=fred
    includes=george

    You can also have a section for [py2exe] if needed; that way, if there
    are modules that your Windows build needs that the Mac build doesn't (or
    vice versa), you can just include them where needed.

    Dave
     
    Dave Opstad, Oct 4, 2006
    #2
    1. Advertising

  3. James Stroud

    James Stroud Guest

    Dave Opstad wrote:
    > In article <ulMUg.13149$>,
    > James Stroud <> wrote:
    >>I am trying to create a semi-standalone with the vendor python on OS X
    >>10.4 (python 2.3.5). I tried to include some packages with both
    >>--packages from the command and the 'packages' option in setup.py. While
    >>the packages were nicely included in the application bundle in both
    >>cases (at Contents/Resources/lib/python2.3/), they were not found by
    >>python when the program was launched, giving the error:
    >>
    >> "ImportError: No module named [whatever module]"

    >
    > You might want to have a setup.cfg file in addition to the setup.py
    > file. I've found that helps ensure the relevant packages and includes
    > make it into the bundled application.
    >
    > For example, say you have a package named fred and also a separate
    > module named george that are needed for your app. Your setup.cfg could
    > look like this:
    >
    > #
    > # setup.cfg
    > #
    >
    > [py2app]
    > packages=fred
    > includes=george
    >
    > You can also have a section for [py2exe] if needed; that way, if there
    > are modules that your Windows build needs that the Mac build doesn't (or
    > vice versa), you can just include them where needed.
    >
    > Dave


    Hi Dave,

    Thank your for pointing me to setup.cfg. I make standalones for windows,
    linux, and OS X, so it will definitely help take some of the confusion
    out of my setup.py.

    However, when passing trying to build semi-standalone, the module does
    make it into the application bundle, but the python interpreter doesn't
    seem to know where to find it. Is there something I can specify in
    setup.cfg or setup.py that will point the interpreter to the included
    module, or will I need to make another test and programmatically set
    sys.path inside of my python code? If this is solved by setup.cfg, then
    forgive me--I haven't had a chance to try it yet.

    Below is the relevant part of my setup.py.

    James

    =====
    APP = ['%s.py' % appname]
    DATA_FILES = []
    OPTIONS = {
    'argv_emulation' : True,
    'strip' : True,
    'packages' : packages,
    'iconfile' : '%s.icns' % appname,
    }

    if not os.path.exists('dist'):
    setup(
    app=APP,
    name=appname,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
    )
    else:
    print 'Directory "dist" exists. Doing nothing.'
    =====


    --
    James Stroud
    UCLA-DOE Institute for Genomics and Proteomics
    Box 951570
    Los Angeles, CA 90095

    http://www.jamesstroud.com/
     
    James Stroud, Oct 4, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Austin

    py2app on Mac OS X 10.3

    Austin, Dec 31, 2004, in forum: Python
    Replies:
    1
    Views:
    394
    Ronald Oussoren
    Dec 31, 2004
  2. Bob Swerdlow

    py2app can't find boot_app.py

    Bob Swerdlow, Mar 14, 2005, in forum: Python
    Replies:
    0
    Views:
    308
    Bob Swerdlow
    Mar 14, 2005
  3. bex

    OS X py2app confusion

    bex, Jul 25, 2005, in forum: Python
    Replies:
    1
    Views:
    450
  4. tt
    Replies:
    0
    Views:
    280
  5. Tau
    Replies:
    0
    Views:
    283
Loading...

Share This Page