[Pyobjc-dev] py2app glory
Brought to you by:
ronaldoussoren
|
From: Diez B. R. <de...@we...> - 2009-02-23 22:32:59
|
Hi,
after posting here a few weeks ago & finding that py2app didn't work
with XCode-generated PyObjc-projects anymore, I dug deeper and finally
found a solution. No need to use xcode, no need to use some compiled
code, and the ability to develop using an aliased bundle, which makes
turn-around much faster.
Also, you can use a python of your choice, not only the os x
pre-installed one.
This is what you need to do to develop using py2app:
- create a python-cocoa-project using xcode
- rename the main.py to MyProject.py
- place a setup.py in the project-root that looks like this:
---------
"""
Usage:
python setup.py py2app
Append -A to
"""
from setuptools import setup
import subprocess
import os
plist = dict(
CFBundleDocumentTypes=[ # this you need if you have a
document-based app
{
"CFBundleTypeExtensions" :["????"],
"CFBundleTypeIconFile" : "",
"CFBundleTypeName" : "DocumentType",
"CFBundleTypeOSTypes" : ["????"],
"CFBundleTypeRole" : "Editor",
"NSDocumentClass" : "CameraCalibratorDocument",
}
]
)
for base, dirnames, filenames in os.walk(os.getcwd()):
for filename in filenames:
name, ext = os.path.splitext(filename)
if ext == ".xib":
inf = os.path.join(base, filename)
outf = os.path.join(base, "%s.nib" % name)
cmd = ["ibtool", "--errors", "--warnings", "--notices",
"--output-format", "human-readable-text", "--compile", outf, inf]
if subprocess.call(cmd):
raise Exception("ibtool puked.")
setup(
data_files=['English.lproj'],
app=[
dict(script="MyProject.py", plist=plist),
],
install_requires=["pyobjc"],
setup_requires=["py2app"],
)
---------
That's it.
Please be aware that due to the new XIBs & the need to compile them
using ibtool, the changes to them aren't applied immediatly - you need
to re-run the py2app-command. But that's pretty cheap.
Maybe this helps others,
Diez
|