[Pythonmac-SIG] Python control/integration of a Cocoa/Quicktime application?

Dethe Elza delza at livingcode.org
Sat Nov 3 08:00:41 CET 2007


On 11/2/07, Darran Edmundson <darran at edmstudio.com> wrote:
> Now that we have a proof-of-concept Objective-C framework, I'm trying to
>   port a simple test application to python.   Keep in mind that I didn't
> write either of these.  I'm a complete neophyte in terms of Mac
> development and ObjectiveC; all I have going for me is a lot of python
> experience on Windows.  Issues I'm having:
>
> - In a terminal, 'python' still gives me Apple's native 2.3 rather than
>    MacPython 2.4.  Do I uninstall Apple's version or simply ensure that
>    the MacPython version comes earlier in the system path?

Just make sure python2.5 comes earlier in your path.  Never uninstall
Apple's version--your computer uses it for system operations.

> - The pyObjC online docs discuss XCode templates and a distutils
>    approach.  Is the latter deprecated, or still a reasonable approach?

I would use the distutils (actually, I think it is setuptools now)
approach.  The XCode templates have been fixed in Leopard (or so I
have heard), but I don't think they were very helpful in Tiger.

You can easy_install setuptools and py2app.  Below is a bare-bones
setup.py that you can customize by replacing variables with the word
"YOUR" in them.  Sorry about the over-abundance of ALL CAPS.  I have
this set up so I can re-use it quickly, so there are a bunch of
semi-constants I use in all caps, then I added more for your
customization.  Let me know if it is confusing.

'''
Minimal setup.py example, run with:
% python setup.py py2app
'''

from distutils.core import setup
import py2app

NAME = 'YOUR_APP_NAME'
SCRIPT = 'YOUR_PYTHON_SCRIPT.py'
VERSION = 'YOUR_VERSION'
ICON = ''
ID = 'A_UNIQUE_STRING
COPYRIGHT = 'Copyright 2007 YOUR_NAME'
DATA_FILES = ['English.lproj'] # This is needed if you use nib files
to define your UI

plist = dict(
    CFBundleIconFile            = ICON,
    CFBundleName                = NAME,
    CFBundleShortVersionString  = ' '.join([NAME, VERSION]),
    CFBundleGetInfoString       = NAME,
    CFBundleExecutable          = NAME,
    CFBundleIdentifier          = 'org.YOUR_DOMAIN.examples.%s' % ID,
    NSHumanReadableCopyright    = COPYRIGHT
)


app_data = dict(script=SCRIPT, plist=plist)
py2app_opt = dict(frameworks=['YOUR_FRAMEWORK_HERE.framework'],)
options = dict(py2app=py2app_opt,)

setup(
  data_files = DATA_FILES,
  app = [app_data],
  options = options,
)


More information about the Pythonmac-SIG mailing list