[Pythonmac-SIG] building extensions for 2.3 (darwin build), and UUID generation

Bob Ippolito bob at redivi.com
Wed Dec 31 14:01:55 EST 2003


On Dec 31, 2003, at 1:46 PM, Paul Miller wrote:

>
>> from __init__.py to determine the base location).  You just need to 
>> know the absolute path of the framework.  Besides, I showed you how 
>> to use the interfaces, it takes three lines of code to load PyObjC 
>> and the framework then get a uuid string out of it ;)
>
> Oh, er, yeah, you did. Er, thanks. :-)
>
> Okay, I'll give that a try. As long as I can stick that Framework 
> right in my Python include path, I'll be happy.

For reference, here is my "__init__.py template" for simply wrapped 
ObjC frameworks.  It will look for the framework in several places, but 
it looks in the same folder as the python script first, which is the 
general case.

# change this to the name of the framework sans extension
FRAMEWORKNAME = 'UNSystemConfiguration'
# leave this alone
import objc, Foundation, os
def _findFramework(framework):
     SEARCHPATH = (
         os.path.split(__file__)[0],
         Foundation.NSBundle.mainBundle().resourcePath(),
         os.path.expanduser('~/Library/Frameworks'),
         '/Library/Frameworks',
         '/System/Library/Frameworks',
         '/Network/Library/Frameworks',
     )
     for path in SEARCHPATH:
         path = os.path.realpath(os.path.join(path, 
framework+'.framework'))
         if os.path.exists(path):
             return path
     else:
         raise ImportError, "Couldn't find %s.framework" % (framework,)
objc.loadBundle(FRAMEWORKNAME, globals(), 
bundle_path=_findFramework(FRAMEWORKNAME))
del objc, Foundation, os, _findFramework
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20031231/e1f01731/smime.bin


More information about the Pythonmac-SIG mailing list