[Pythonmac-SIG] creating file associations with apps via bundlebuilder?

Kevin Altis altis at semi-retired.com
Wed Aug 18 16:54:50 CEST 2004


On Aug 17, 2004, at 11:10 PM, Bob Ippolito wrote:

> On Aug 17, 2004, at 8:50 PM, Kevin Altis wrote:
>
>> I have a few bundlebuilder scripts that all seem to be making  
>> standalones from my PythonCard/wxPython scripts just fine, so thanks  
>> to Bob, etc. for that. However, I can't figure out what I need to do  
>> to get file extension assocations for those apps. For example, the  
>> CodeEditor standalone should be able to open .txt, .text, .xml, .htm,  
>> .html, .py, and .pyw at a minimum. If I try and choose the CodeEditor  
>> app I built via the Finder Get Info dialog with a .py file it doesn't  
>> think CodeEditor is a recommended application. So, I'm assuming there  
>> is some .plist file I have to create as well or do some other magic?
>
> Yes, Info.plist.  It's not magic, everything that LaunchServices knows  
> about is in that one file.
>
> http://developer.apple.com/documentation/MacOSX/Conceptual/ 
> BPRuntimeConfig/Concepts/PListKeys.html#//apple_ref/doc/uid/20001431/ 
> TPXREF107
>
> -bob
>
Thanks. I cobbled together my own Info.plist file using PythonIDE and  
SubEthaEdit and the doc page as examples. I have a script that I've  
been using to make the standalone rather than providing a whole lot of  
command-line args to bundlebuilder. I've included the script below in  
case it points out some fundamental mistake on my part. I can't figure  
out a way to provide my own Info.plist file as a variable. Glancing at  
the bundlebuilder.py script it looks like I would have to read in and  
parse the Info.plist file using plistlib.PlistParser before setting the  
parsed XML to myapp.plist? Is there another way?

ka
---

import os, sys
import bundlebuilder

# I set this to make adding subfolders into the package easier
# KEA 2004-07-22
# rather than hard-coding the path
# we'll just get the path from this module
##packageroot = "/Users/kevino/oss/eclass/eclass_builder"
packageroot = os.path.abspath(os.path.dirname(__file__))
# for the purposes of building the standalone
# change to the directory the build script is in to simplify imports
os.chdir(packageroot)

# Create the AppBuilder
myapp = bundlebuilder.AppBuilder(verbosity=1)

# Tell it where to find the main script - the one that loads on startup
myapp.mainprogram = os.path.join(packageroot, "codeEditor.py")

# drag&dropped filenames show up in sys.argv
myapp.argv_emulation=1
# make this app self contained
myapp.standalone = 1
myapp.name = "CodeEditor"
# need to specify --plist=Info.plist as command-line arg?
# the line below doesn't work
#myapp.plist = os.path.join(packageroot, "Info.plist")

# includePackages forces certain packages to be added to the app bundle
##myapp.includePackages.append("encodings")
##myapp.includePackages.append("_xmlplus")


# Here you add supporting files and/or folders to your bundle
myapp.resources.append(os.path.join(packageroot, "scriptlets"))
myapp.resources.append(os.path.join(packageroot, "codeEditor.rsrc.py"))
myapp.resources.append(os.path.join(packageroot, "..", "..",  
"templates", "dialogs", "runOptionsDialog.rsrc.py"))

# bundlebuilder does not yet have the capability to detect what shared  
libraries
# are needed by your app - so in this case I am adding the wxPython  
libs manually
myapp.libs.append("/usr/local/lib/wxPython-2.5.2.7/lib/libwx_macd 
-2.5.2.dylib")
myapp.libs.append("/usr/local/lib/wxPython-2.5.2.7/lib/libwx_macd 
-2.5.2.rsrc")
myapp.libs.append("/usr/local/lib/wxPython-2.5.2.7/lib/libwx_macd_stc 
-2.5.2.dylib")

# Here we build the app!
myapp.setup()
myapp.build()
 



More information about the Pythonmac-SIG mailing list