py2app semi-standalone semi-works

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Stroud

    #1

    py2app semi-standalone semi-works

    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:

    "ImportErro r: 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
  • Dave Opstad

    #2
    Re: py2app semi-standalone semi-works

    In article <ulMUg.13149$7I 1.6975@newssvr2 7.news.prodigy. net>,
    James Stroud <jstroud@mbi.uc la.eduwrote:
    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:
    >
    "ImportErro r: 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

    Comment

    • James Stroud

      #3
      Re: py2app semi-standalone semi-works

      Dave Opstad wrote:
      In article <ulMUg.13149$7I 1.6975@newssvr2 7.news.prodigy. net>,
      James Stroud <jstroud@mbi.uc la.eduwrote:
      >>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:
      >>
      > "ImportErro r: 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 programmaticall y 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={'py2ap p': 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


      Comment

      Working...