[Pythonmac-SIG] py2app Enforces Directory Structure?

Erik Westra ewestra at gmail.com
Wed Dec 22 04:29:41 CET 2004


Greetings, Pythonmac folks!

I was wondering if someone could help me with a problem I'm having with py2app.

I'm in the process of converting a large wxPython application written
for MS Windows to run on the Mac.  The application itself now works,
and I'm at the stage of trying to bundle it up using py2app for
distribution.  Unfortunately, it seems that the application's
directory structure is causing problems for py2app, and after two days
of mucking about I still can't get it working.

The application has the following overall directory structure:

    app/

        build/
            setup.py
            build-exe.bat
            ...

        framework/
            Framework.py
            main.py

        data/
            ...

There are other top-level directories as well, but these are the
important ones.  As you can see the "main.py" file is in the
"framework" sub-directory, and the application accesses its data files
using relative paths like "../data/file.dat".  All temporary files,
scripts, etc, which are used to build standalone versions of the
system are placed into the "build" sub-directory.

This works well under MS Windows, both for the standalone system and
when its running in source-code form, and also works fine on the Mac
when running the source directory -- but I haven't been able to get
py2app to build this application at all.

It seems that py2app requires that the main.py file and the setup.py
file are both stired in the top-most directory for the application,
with other files/modules/packages in sub-directories beneath that
topmost directory.  Is this really the case?  If so, it seems like a
rather major limitation -- surely there must be lots of applications
that put all their build-related files into a separate sub-directory,
quite separate from the application's main source files.

Because I need to be able to share one common set of source code
across multiple platforms, I don't have much choice in terms of
altering this directory structure -- somehow, I need to get py2app to
build a standalone Mac application which includes the "Framework.py"
and "main.py" modules, runs main.py on startup, and stores setup.py
and all temporary files inside the "build" directory.  I don't need to
include anything else in the application, as the system will store the
contents of the "data" and other directories outside of the
application bundle itself.

Here's my attempt at creating a "setup.py" file:

    from distutils.core import setup
    import py2app

    setup(
        app = ["main.py"],
        options={'py2app' :
                    {'bdist_base' : "../build/build",
                     'dist_dir'   : "../build/dist",
                     'includes'   : "Framework"}}
    )

This setup script is stored in the "build" sub-directory, and I access
it by typing:

    cd framework
    python ../build/setup.py py2app

This works in terms of creating a standalone wxPython app that
includes the "main.py" file, but the "Framework.py" file isn't
included, and the app fails at the "import Framework" statement within
"main.py".

The only other idea I can think of would be to create aliases to the
"main.py" and "Framework.py" files, put the aliases into the "build"
directory, and treat the entire system as if it all resided in a
single directory.  But there must be a better solution than that!

What I really need, I guess, is a way of specifying the source
directory in which the modules in the "includes" list will be found. 
There doesn't seem to be any such option, though, and including a
relative pathname in the "includes" list just generates an error when
I try to build the app.

Any suggestions?

Thanks,

 - Erik.


More information about the Pythonmac-SIG mailing list