From hengist.podd at virgin.net Mon Jul 2 10:52:59 2007 From: hengist.podd at virgin.net (has) Date: Mon, 2 Jul 2007 09:52:59 +0100 Subject: [Pythonmac-SIG] problem with CarbonEvt, Thread and sleep Message-ID: Hi all, Trying to implement a watchdog thread in a Carbon Event-based application. Trouble is, the thread's sleep() call never seems to return. (10.4.9/PPC/Python 2.5) Demonstration code below: #!/usr/local/bin/python from threading import Thread from time import sleep from Carbon.CarbonEvt import * def stop(): print 'sleep' sleep(2) print 'wake' # never executes QuitApplicationEventLoop() print 'start thread' t = Thread(target=stop) t.start() print 'start event loop' RunApplicationEventLoop() Any ideas? Thanks, has -- http://appscript.sourceforge.net http://rb-appscript.rubyforge.org http://appscript.sourceforge.net/objc-appscript.html From ronaldoussoren at mac.com Mon Jul 2 11:12:03 2007 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Mon, 02 Jul 2007 02:12:03 -0700 Subject: [Pythonmac-SIG] problem with CarbonEvt, Thread and sleep In-Reply-To: References: Message-ID: <697F1279-0113-1000-9EC2-0E28D72D04DB-Webmail-10014@mac.com> On Monday, July 02, 2007, at 10:54AM, "has" wrote: >Hi all, > >Trying to implement a watchdog thread in a Carbon Event-based >application. Trouble is, the thread's sleep() call never seems to >return. (10.4.9/PPC/Python 2.5) Demonstration code below: > [... snip code ...] > > >Any ideas? There is no threading support in the Carbon bindings. The wrapper for RunApplicationEventLoop doesn't give up the GIL, which means other Python threads don't get a chance to run unless the main thread is actually handling events in Python code. You might be able to get this to work with the autoGIL module, but I don't fully trust that approach. Ronald From hengist.podd at virgin.net Mon Jul 2 11:55:43 2007 From: hengist.podd at virgin.net (has) Date: Mon, 2 Jul 2007 10:55:43 +0100 Subject: [Pythonmac-SIG] problem with CarbonEvt, Thread and sleep In-Reply-To: <697F1279-0113-1000-9EC2-0E28D72D04DB-Webmail-10014@mac.com> References: <697F1279-0113-1000-9EC2-0E28D72D04DB-Webmail-10014@mac.com> Message-ID: <2F85BB4C-2A04-4593-B550-A5A0C7A479E8@virgin.net> On 2 Jul 2007, at 10:12, Ronald Oussoren wrote: >> Trying to implement a watchdog thread in a Carbon Event-based >> application. Trouble is, the thread's sleep() call never seems to >> return. > > There is no threading support in the Carbon bindings. The wrapper > for RunApplicationEventLoop doesn't give up the GIL, which means > other Python threads don't get a chance to run unless the main > thread is actually handling events in Python code. Ahh, should've guessed. I'll redo it in PyObjC then. Thanks, has -- http://appscript.sourceforge.net http://rb-appscript.rubyforge.org http://appscript.sourceforge.net/objc-appscript.html From skip at pobox.com Tue Jul 3 16:19:36 2007 From: skip at pobox.com (skip at pobox.com) Date: Tue, 3 Jul 2007 09:19:36 -0500 Subject: [Pythonmac-SIG] Can someone help me reverse engineer this installer? Message-ID: <18058.23288.747847.31115@montanaro.dyndns.org> A long time ago Sam Thorne created a Mac installer for SpamBayes. It's referenced here: http://entrian.com/sbwiki/MacOSXPackage and source is available here: http://www.s-j-t.co.uk/SpamBayes/SpamBayesPkg%200.5.zip The binary package here: http://www.s-j-t.co.uk/SpamBayes/SpamBayesPackage.pkg.tgz won't untar for me. It complains about a "lone zero block at 678". I'd like to start generating Mac installer packages for the normal SpamBayes distribution, but for that I need some help getting started (having never done any Mac package creation before). I sent email to the author asking about how he created the one he did but haven't heard back from him (maybe he's just on holiday). Can one of the MacPython experts here deduce how the above package was generated and suggest how to proceed? I don't even know what the best package creator is on the Mac for Python-based apps. Thx, Skip Montanaro From kw at codebykevin.com Wed Jul 4 00:38:25 2007 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 03 Jul 2007 18:38:25 -0400 Subject: [Pythonmac-SIG] Call PyObjC methods from wxPython? Message-ID: <468ACFE1.8000303@codebykevin.com> I hope this isn't a dumb question, but I am wondering if it's possible for me to call some non-windowing Cocoa routines (via PyObjC) from a wxPython application. Specifically, I am trying to retrieve a file icon via NSWorkspace for display in a wxPython window; I'm probably going to filter it through PIL first to convert it into a format readable by wxPython. Why not do the whole app in PyObjC? Mainly because wxPython fits my head better in terms of my prior background (it's fairly easy for me to translate Tkinter GUI concepts into wxPython--it's a much bigger leap to nib files). Any advice is appreciated. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From vmerritt at verizon.net Tue Jul 10 05:21:42 2007 From: vmerritt at verizon.net (vmerritt at verizon.net) Date: Mon, 09 Jul 2007 22:21:42 -0500 (CDT) Subject: [Pythonmac-SIG] (no subject) Message-ID: <17492131.3729371184037702464.JavaMail.root@vms229.mailsrvcs.net> Greetings All, I am an Visual Effects artist in need of a good Mac oriented Python book. I have been reading the online materials, but I don't always have the time to sit in front of a computer, thus my need for a good Mac focused Python Book. Any suggestions would be very helpful. Thank you in advance, Victor Merritt From bray at sent.com Tue Jul 10 16:33:11 2007 From: bray at sent.com (Brian Ray) Date: Tue, 10 Jul 2007 09:33:11 -0500 Subject: [Pythonmac-SIG] ChiPy Presenters Wanted Message-ID: <12C8F2B7-698F-49FA-A9F0-C08BA6EC1613@sent.com> Greetings: ChiPy is looking for presenters for our August 9th meeting. This is our regular monthly meeting; although, it happens to be the day before C4 starts. Anyone who is in town is more than welcome to attend. We will love to have you regardless if your a presenter or not. We still need to find presenters and a venue so spread the word. Some possible venues may be Google's Chicago Office or UIC. The topic for this meeting is Snakes On Apples. The planning page may be found on our wiki: . A meeting dedicated to Python on the Macintosh is a ChiPy first. Please ping this list, the ChiPy list , update the wiki page, or contact me off the list if your even slightly interested in presenting. Kind Regards, Brian Ray bray at sent.com http://kazavoo.com/blog From hengist.podd at virgin.net Tue Jul 10 16:53:30 2007 From: hengist.podd at virgin.net (has) Date: Tue, 10 Jul 2007 15:53:30 +0100 Subject: [Pythonmac-SIG] Mac oriented Python book (was: no subject) In-Reply-To: References: Message-ID: <575F3C9A-9130-4F30-85BC-EA2E4EDE7693@virgin.net> Victor Merritt wrote: > I am an Visual Effects artist in need of a good Mac oriented Python > book. > I have been reading the online materials, but I don't always have > the time > to sit in front of a computer, thus my need for a good Mac focused > Python Book. > Any suggestions would be very helpful. I don't think there are any specifically Mac-oriented Python books, but the language and core library is the same on all platforms so any good Python book will do for learning those. Other folks can probably recommend specific titles, though it'd help if you indicate if you're looking for beginner, intermediate or expert material. As far as Mac-specific extensions go, most of the stuff in standard library you should just ignore as being obsolete. Some of the Carbon extensions are still relevant if you need to do Carbon stuff, in which case refer to their docstrings and Apple's Carbon documentation to make sense of those. As for third-party packages, the main three are PyObjC, py2app and appscript, all of which include basic documentation and examples. If using PyObjC you should also refer to Apple's reference and API documentation. If you want a general book for learning Cocoa programming, Aaron Hillegass's 'Cocoa Programming for OS X' is well regarded. If using appscript you should also refer to individual applications' dictionaries and, if provided, supplementary documentation. If you want a general book on AppleScript, get Matt Neuburg's 'AppleScript: The Definitive Guide'. If you want more specific advice, tell us what sort of stuff it is you want to do and what programming skills you already have. HTH has -- http://appscript.sourceforge.net http://rb-appscript.rubyforge.org http://appscript.sourceforge.net/objc-appscript.html From bray at sent.com Tue Jul 10 17:12:48 2007 From: bray at sent.com (Brian Ray) Date: Tue, 10 Jul 2007 10:12:48 -0500 Subject: [Pythonmac-SIG] Can someone help me reverse engineer this installer? In-Reply-To: <18058.23288.747847.31115@montanaro.dyndns.org> References: <18058.23288.747847.31115@montanaro.dyndns.org> Message-ID: <773E2CF0-164C-454F-9C02-0B16C29246B4@sent.com> On Jul 3, 2007, at 9:19 AM, skip at pobox.com wrote: > A long time ago Sam Thorne created a Mac installer for SpamBayes. > It's > referenced here: > > http://entrian.com/sbwiki/MacOSXPackage > > and source is available here: > > http://www.s-j-t.co.uk/SpamBayes/SpamBayesPkg%200.5.zip This contains pmsp which should be upgraded to a pmproj. PackageMaker.app will do this for you. The package maker project is fairly self-explanatory. The "Contents Root" should probably be changed to a relative path. One thing to take in consideration is that there is a "postflight" and "postinstall" scripts that get ran at the appropriate time during the install. They will may be found in the "SpamBayesPkg 0.5/ SpamBayes/Package_resources" directory. Installer.app knows to run these because of how they are named. The install simply copies the files from what is found in "SpamBayes/ Package_contents/" to "/". So the three big items that get installed are: /Library/StartupItems/SpamBayes /Library/Python/2.3 /Library/SpamBayes/ The postinstall script adds SPAMBAYES=-YES- to the /etc/hostconfig The postflight script starts SpamBayes (simulating the way this will be done during boot using SystemStarter) and opens the url http:// localhost:8880, presumably where SpamBayes runs.. > > The binary package here: > > http://www.s-j-t.co.uk/SpamBayes/SpamBayesPackage.pkg.tgz > > won't untar for me. It complains about a "lone zero block at 678". I get the same error. Must be corrupt. Brian Ray bray at sent.com http://kazavoo.com/blog From daniellord at mac.com Tue Jul 10 17:35:36 2007 From: daniellord at mac.com (Daniel Lord) Date: Tue, 10 Jul 2007 08:35:36 -0700 Subject: [Pythonmac-SIG] Mac oriented Python book (was: no subject) In-Reply-To: <575F3C9A-9130-4F30-85BC-EA2E4EDE7693@virgin.net> References: <575F3C9A-9130-4F30-85BC-EA2E4EDE7693@virgin.net> Message-ID: I am guessing that Victor is either interested in scripting Blender or Modo since those are the only higher-end 3D graphics modeling and rendering packages I know of that support Python scripting. I am ruling out Poser and Shade. The issue with those packages is that they use an embedded interpreter so standalone aspects of Python (PyObjC, py2app, wxPython) are useless in that context as far I have been able to determine. I use Modo but have only tinkered with using Python with it. On Jul 10, 2007, at 7:53, has wrote: > Victor Merritt wrote: > >> I am an Visual Effects artist in need of a good Mac oriented Python >> book. >> I have been reading the online materials, but I don't always have >> the time >> to sit in front of a computer, thus my need for a good Mac focused >> Python Book. >> Any suggestions would be very helpful. > From vmerritt at verizon.net Wed Jul 11 06:01:43 2007 From: vmerritt at verizon.net (vmerritt at verizon.net) Date: Tue, 10 Jul 2007 23:01:43 -0500 (CDT) Subject: [Pythonmac-SIG] Mac oriented Python book (was: no subject) Message-ID: <24164246.4276161184126503568.JavaMail.root@vms229.mailsrvcs.net> Actually I am working in: Maya 8.5(http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=7635643) and Next Limits Real Flow 4(http://www.nextlimit.com/nlscript/) My interest is in accessing the Python scripting functionality within these and other applications. I am new to Python and programming. I need all the help I can get. Victor Merritt From: Daniel Lord Date: 2007/07/10 Tue AM 10:35:36 CDT To: has , Victor Merritt Cc: pythonmac-sig at python.org Subject: Re: [Pythonmac-SIG] Mac oriented Python book (was: no subject) I am guessing that Victor is either interested in scripting Blender or Modo since those are the only higher-end 3D graphics modeling and rendering packages I know of that support Python scripting. I am ruling out Poser and Shade. The issue with those packages is that they use an embedded interpreter so standalone aspects of Python (PyObjC, py2app, wxPython) are useless in that context as far I have been able to determine. I use Modo but have only tinkered with using Python with it. On Jul 10, 2007, at 7:53, has wrote: > Victor Merritt wrote: > >> I am an Visual Effects artist in need of a good Mac oriented Python >> book. >> I have been reading the online materials, but I don't always have >> the time >> to sit in front of a computer, thus my need for a good Mac focused >> Python Book. >> Any suggestions would be very helpful. > _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG at python.org http://mail.python.org/mailman/listinfo/pythonmac-sig From daniellord at mac.com Wed Jul 11 07:03:27 2007 From: daniellord at mac.com (Daniel Lord) Date: Tue, 10 Jul 2007 22:03:27 -0700 Subject: [Pythonmac-SIG] Mac oriented Python book (was: no subject) In-Reply-To: <24164246.4276161184126503568.JavaMail.root@vms229.mailsrvcs.net> References: <24164246.4276161184126503568.JavaMail.root@vms229.mailsrvcs.net> Message-ID: To quote Autodesk/Alias's site: "Python Python, a powerful and accessible scripting language, is now available within Maya. Not only has Python been integrated into the software at the same level as the Maya Embedded Language (MEL), its bindings to the OpenMaya API give you an alternative language for plug-in development. Plus, the Maya Python modules can be imported into an external standalone Python interpreter for batch processing. With its higher-level language constructs, Python supports developer productivity while providing easily maintainable code. The language is also highly extensible, with a broad collection of third-party tools and modules freely available" Wow. MEL has always been the way to script Maya from Day One. I am shocked and surprised they opened up to a standard scripting language. But I think it is great news. Granted I always wondered why these vendors ignored open standard languages in an egotistical rush to do their own, but at least Autodesk/Alias seems to be waking up. That is great news.If only Maya complete wasn't so expensive at $7000...I'd love to have those Navier-Stokes Fluid Dynamics models they showed off in the Perfect Storm. I have sea kayaked in rough Pacific seas a bit and had just a hint of the wrath of the ocean. Those models in that film made it seem real to me. Oh well. On Jul 10, 2007, at 9:01 PM, vmerritt at verizon.net wrote: > Actually I am working in: > Maya 8.5(http://usa.autodesk.com/adsk/servlet/index? > siteID=123112&id=7635643) > and Next Limits Real Flow 4(http://www.nextlimit.com/nlscript/) > My interest is in accessing the Python scripting functionality > within these > and > other applications. I am new to Python and programming. I need all > the help I > can get. > > Victor Merritt > > From: Daniel Lord > Date: 2007/07/10 Tue AM 10:35:36 CDT > To: has , Victor Merritt > > Cc: pythonmac-sig at python.org > Subject: Re: [Pythonmac-SIG] Mac oriented Python book (was: no > subject) > > I am guessing that Victor is either interested in scripting Blender > or Modo since those are the only higher-end 3D graphics modeling and > rendering packages I know of that support Python scripting. > I am ruling out Poser and Shade. > > The issue with those packages is that they use an embedded > interpreter so standalone aspects of Python (PyObjC, py2app, > wxPython) are useless in that context as far I have been able to > determine. > I use Modo but have only tinkered with using Python with it. > > On Jul 10, 2007, at 7:53, has wrote: > >> Victor Merritt wrote: >> >>> I am an Visual Effects artist in need of a good Mac oriented Python >>> book. >>> I have been reading the online materials, but I don't always have >>> the time >>> to sit in front of a computer, thus my need for a good Mac focused >>> Python Book. >>> Any suggestions would be very helpful. >> > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20070710/23c7ecd2/attachment.html From ronaldoussoren at mac.com Wed Jul 11 10:04:12 2007 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Wed, 11 Jul 2007 01:04:12 -0700 Subject: [Pythonmac-SIG] Mac oriented Python book (was: no subject) In-Reply-To: <24164246.4276161184126503568.JavaMail.root@vms229.mailsrvcs.net> References: <24164246.4276161184126503568.JavaMail.root@vms229.mailsrvcs.net> Message-ID: On Wednesday, July 11, 2007, at 06:03AM, wrote: >Actually I am working in: >Maya 8.5(http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=7635643) >and Next Limits Real Flow 4(http://www.nextlimit.com/nlscript/) >My interest is in accessing the Python scripting functionality within these >and >other applications. I am new to Python and programming. I need all the help I >can get. I don't know any Mac oriented Python books. My guess is that you don't really need anything mac specific, and there are tons of general Python programming books. Most O'Reilly books are pretty good, so maybe "Learning Python" could help you (http://www.oreillynet.com/catalog/lpython2/) DISCLAIMER: I haven't read this book, or any other introductionary python books. Ronald > >Victor Merritt > >From: Daniel Lord >Date: 2007/07/10 Tue AM 10:35:36 CDT >To: has , Victor Merritt >Cc: pythonmac-sig at python.org >Subject: Re: [Pythonmac-SIG] Mac oriented Python book (was: no subject) > >I am guessing that Victor is either interested in scripting Blender >or Modo since those are the only higher-end 3D graphics modeling and >rendering packages I know of that support Python scripting. >I am ruling out Poser and Shade. > >The issue with those packages is that they use an embedded >interpreter so standalone aspects of Python (PyObjC, py2app, >wxPython) are useless in that context as far I have been able to >determine. >I use Modo but have only tinkered with using Python with it. > >On Jul 10, 2007, at 7:53, has wrote: > >> Victor Merritt wrote: >> >>> I am an Visual Effects artist in need of a good Mac oriented Python >>> book. >>> I have been reading the online materials, but I don't always have >>> the time >>> to sit in front of a computer, thus my need for a good Mac focused >>> Python Book. >>> Any suggestions would be very helpful. >> >_______________________________________________ >Pythonmac-SIG maillist - Pythonmac-SIG at python.org >http://mail.python.org/mailman/listinfo/pythonmac-sig > >_______________________________________________ >Pythonmac-SIG maillist - Pythonmac-SIG at python.org >http://mail.python.org/mailman/listinfo/pythonmac-sig > > From cygnusx1 at mac.com Wed Jul 11 23:37:16 2007 From: cygnusx1 at mac.com (Tom Bridgman) Date: Wed, 11 Jul 2007 17:37:16 -0400 Subject: [Pythonmac-SIG] Mac oriented Python book (was: no subject) In-Reply-To: <24164246.4276161184126503568.JavaMail.root@vms229.mailsrvcs.net> References: <24164246.4276161184126503568.JavaMail.root@vms229.mailsrvcs.net> Message-ID: I occasionally work with Maya and Renderman in my day job. MEL was one of the reasons why I dropped Maya and started using cgkit (cgkit.sourceforge.net) to interface directly to Renderman. With what little MEL I've done lately, there should be very little 'Mac-specific' issues for using a python engine in Maya. I assume Maya has defined a set of classes for interfacing with their object and texture generation and for the most part, it will look like any other python module from inside the scripting window. I believe even GUI controls are done more through the Maya interface (which then calls the Mac interface). Don't they include any documentation for accessing Python in Maya? (Our site hasn't done the Maya upgrade as yet.) Tom On Jul 11, 2007, at 12:01 AM, vmerritt at verizon.net wrote: > Actually I am working in: > Maya 8.5(http://usa.autodesk.com/adsk/servlet/index? > siteID=123112&id=7635643) > and Next Limits Real Flow 4(http://www.nextlimit.com/nlscript/) > My interest is in accessing the Python scripting functionality > within these > and > other applications. I am new to Python and programming. I need all > the help I > can get. > > Victor Merritt > > From: Daniel Lord > Date: 2007/07/10 Tue AM 10:35:36 CDT > To: has , Victor Merritt > > Cc: pythonmac-sig at python.org > Subject: Re: [Pythonmac-SIG] Mac oriented Python book (was: no > subject) > > I am guessing that Victor is either interested in scripting Blender > or Modo since those are the only higher-end 3D graphics modeling and > rendering packages I know of that support Python scripting. > I am ruling out Poser and Shade. > > The issue with those packages is that they use an embedded > interpreter so standalone aspects of Python (PyObjC, py2app, > wxPython) are useless in that context as far I have been able to > determine. > I use Modo but have only tinkered with using Python with it. > > On Jul 10, 2007, at 7:53, has wrote: > >> Victor Merritt wrote: >> >>> I am an Visual Effects artist in need of a good Mac oriented Python >>> book. >>> I have been reading the online materials, but I don't always have >>> the time >>> to sit in front of a computer, thus my need for a good Mac focused >>> Python Book. >>> Any suggestions would be very helpful. >> > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From Chris.Barker at noaa.gov Fri Jul 13 23:55:55 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 13 Jul 2007 14:55:55 -0700 Subject: [Pythonmac-SIG] Accessing Resource forks Message-ID: <4697F4EB.203@noaa.gov> Hi all, Somehow over all these years, I've managed to use Python on Macs without having it deal with resource forks and all that -- but ironically, now that we're all OS-X all the time, I need to do it now. What I'm trying to do is simple check for the existence of a resource fork, and if it's there, the size. This is what I've tried: import Carbon.File as File files = ["junk.txt", "junk_rsc.txt"] for filename in files: f = File.FSRef(filename) print "file path is:", f.FSRefMakePath() i = f.FSGetCatalogInfo(0) print "logical size is:", i[0].rsrcLogicalSize print "Physical size is:", i[0].rsrcPhysicalSize In this case, junk.txt was created at the command line, so it shouldn't have a resource fork. junk_rsc.txt I opened up in resedit, which should have given it a small resource fork. Running this script, I get: file path is: /Users/cbarker/temp/AFP-SMB/junk.txt logical size is: 65543 Physical size is: 30457855 file path is: /Users/cbarker/temp/AFP-SMB/junk_rsc.txt logical size is: -593231776 Physical size is: -210763775 The paths are right, so it looks like I've got the FSRef right, but rsrcLogicalSize and rsrcPhysicalSize make no sense. How should I be doing this -- the docs are sparse, to say the least! By the way, I might as well tell you the real goal, maybe one of you will have a better idea. We have a Windows file server that is about to be retired. over the years, people of have put files on it using both the AFP and SMB protocols (the server is running MS services for macintosh). These are all mixed up. However, any file put up with one protocol loses it's resource fork (and type and creator) if brought down with the other protocol. Our goal is to clean up this mess automatically. The idea at hand is that a file brought down with AFP will either: Have a nice resource fork, in which case it was put up with AFP, and we're happy Have no resource fork, in which case it never had one, and we dont' care what protocol was used, or it was put up with SMB, and we can then bring it down that way instead. The other obvious option is to look for the ._* files, which is where the resource fork is stored with the SMB protocol. However, we're concerned that that may not be reliable -- if a file were put up with SMB, then replaced with AFP, there may be a ._* file, but it won't work right. This actually seems pretty likely as while we have this mixed system, there have been a lot of "that didn't work, please put the file back up with APF" iterations. Thanks for your thoughts. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From hamish at gmail.com Sat Jul 14 00:27:21 2007 From: hamish at gmail.com (Hamish Allan) Date: Fri, 13 Jul 2007 23:27:21 +0100 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <4697F4EB.203@noaa.gov> References: <4697F4EB.203@noaa.gov> Message-ID: <597e7edb0707131527g580876e0s859b43ca29839c26@mail.gmail.com> Hi Chris, Let me start by saying that I've never used MS services for Macintosh, so this is all guesswork. But the first thing I wondered was, if files uploaded over AFP aren't using ._* files, what are they using? Presumably the Windows machine isn't actually mounting an HFS or HFS+ filesystem, so they're being stored somewhere "non-standard", in which case all bets for using FSRef are off anyway. Proceeding with this assumption, could you perhaps compare the modification times of the ._* files with the files for which they store the resource fork, and if the latter has a more recent modification time the chances are that it has been overwritten using AFP? That is to say, there are three cases: 1) No ._* file is present: Either the resource fork is stored in non-standard place due to AFP or the file never had one -- download via AFP 2) ._* file is present and has same modification time as its counterpart -- download via SMB 3) ._* file is present and has later modification time than its counterpart -- download via AFP Hope this helps, Hamish On 7/13/07, Christopher Barker wrote: > Hi all, > > Somehow over all these years, I've managed to use Python on Macs > without having it deal with resource forks and all that -- but > ironically, now that we're all OS-X all the time, I need to do it now. > > What I'm trying to do is simple check for the existence of a resource > fork, and if it's there, the size. > > > This is what I've tried: > > import Carbon.File as File > files = ["junk.txt", "junk_rsc.txt"] > > for filename in files: > f = File.FSRef(filename) > print "file path is:", f.FSRefMakePath() > > i = f.FSGetCatalogInfo(0) > print "logical size is:", i[0].rsrcLogicalSize > print "Physical size is:", i[0].rsrcPhysicalSize > > In this case, junk.txt was created at the command line, so it > shouldn't have a resource fork. junk_rsc.txt I opened up in resedit, > which should have given it a small resource fork. Running this script, > I get: > > file path is: /Users/cbarker/temp/AFP-SMB/junk.txt > logical size is: 65543 > Physical size is: 30457855 > file path is: /Users/cbarker/temp/AFP-SMB/junk_rsc.txt > logical size is: -593231776 > Physical size is: -210763775 > > The paths are right, so it looks like I've got the FSRef right, but > rsrcLogicalSize and rsrcPhysicalSize make no sense. > > How should I be doing this -- the docs are sparse, to say the least! > > By the way, I might as well tell you the real goal, maybe one of you > will have a better idea. > > We have a Windows file server that is about to be retired. over the > years, people of have put files on it using both the AFP and SMB > protocols (the server is running MS services for macintosh). These are > all mixed up. However, any file put up with one protocol loses it's > resource fork (and type and creator) if brought down with the other > protocol. > > Our goal is to clean up this mess automatically. > > The idea at hand is that a file brought down with AFP will either: > > Have a nice resource fork, in which case it was put up with AFP, and > we're happy > Have no resource fork, in which case it never had one, and we dont' > care what protocol was used, or it was put up with SMB, and we can > then bring it down that way instead. > > The other obvious option is to look for the ._* files, which is where > the resource fork is stored with the SMB protocol. However, we're > concerned that that may not be reliable -- if a file were put up with > SMB, then replaced with AFP, there may be a ._* file, but it won't > work right. This actually seems pretty likely as while we have this > mixed system, there have been a lot of "that didn't work, please put > the file back up with APF" iterations. > > Thanks for your thoughts. > > -Chris > > -- > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R (206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > Chris.Barker at noaa.gov > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > From daniellord at mac.com Sat Jul 14 00:34:24 2007 From: daniellord at mac.com (Daniel Lord) Date: Fri, 13 Jul 2007 15:34:24 -0700 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <4697F4EB.203@noaa.gov> References: <4697F4EB.203@noaa.gov> Message-ID: On Jul 13, 2007, at 2:55 PM, Christopher Barker wrote: > > How should I be doing this -- the docs are sparse, to say the least! > > By the way, I might as well tell you the real goal, maybe one of you > will have a better idea. > RezDet command line utility perhaps? as in: [15:30:10] daniello at zeus ~/Pictures $RezDet f*.jpg "f3390b9f2ff8e50fb6772ab5bc7c3b2f.jpg": File "f3390b9f2ff8e50fb6772ab5bc7c3b2f.jpg"; ### RezDet - The resource fork is empty and uninitialized. Perhaos use 'commands.getstatusoutput' to run it and search result string? It is listed as an MPW tool, but its still there in Tiger--just checked. http://developer.apple.com/tools/mpw-tools/commandref/rezdet.html Daniel From Chris.Barker at noaa.gov Sat Jul 14 00:53:42 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 13 Jul 2007 15:53:42 -0700 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: References: <4697F4EB.203@noaa.gov> Message-ID: <46980276.3080601@noaa.gov> Daniel Lord wrote: > RezDet command line utility perhaps? Yup, that looks very useful -- it just may be the solution. I had no idea it was there, and it took a while to find it. Maybe it's time to add /Developer/Tools/ to my PATH. thanks, -Chris (still wondering how to do it inside Python... What if I wanted to do something with a resource fork?) -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From Chris.Barker at noaa.gov Sat Jul 14 00:56:16 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 13 Jul 2007 15:56:16 -0700 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <597e7edb0707131526yf8b2e02t783c4909e7e23e27@mail.gmail.com> References: <4697F4EB.203@noaa.gov> <597e7edb0707131526yf8b2e02t783c4909e7e23e27@mail.gmail.com> Message-ID: <46980310.1040509@noaa.gov> Hamish Allan wrote: > Let me start by saying that I've never used MS services for Macintosh, > so this is all guesswork. But the first thing I wondered was, if files > uploaded over AFP aren't using ._* files, what are they using? The server is storing the resource forks somewhere, but not anywhere we can see them - who knows? > Presumably the Windows machine isn't actually mounting an HFS or HFS+ > filesystem, so they're being stored somewhere "non-standard", in which > case all bets for using FSRef are off anyway. I'm only trying to use those after downloading the files via AFP. In my test code, I'm using files created on the Mac they're being tested on, so it should work, if I knew how. > Proceeding with this assumption, could you perhaps compare the > modification times of the ._* files with the files for which they > store the resource fork, and if the latter has a more recent > modification time the chances are that it has been overwritten using > AFP? Good idea, why didn't I think of that? > That is to say, there are three cases: > > 1) No ._* file is present: Either the resource fork is stored in > non-standard place due to AFP or the file never had one -- download > via AFP > 2) ._* file is present and has same modification time as its > counterpart -- download via SMB > 3) ._* file is present and has later modification time than its > counterpart -- download via AFP Yup, that looks like a good option. I'll give it a try. I'd still like to know how to get info in the Resource fork, however... Thanks, -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From njriley at uiuc.edu Sat Jul 14 00:57:53 2007 From: njriley at uiuc.edu (Nicholas Riley) Date: Fri, 13 Jul 2007 17:57:53 -0500 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <4697F4EB.203@noaa.gov> References: <4697F4EB.203@noaa.gov> Message-ID: <20070713225753.GA18160@uiuc.edu> On Fri, Jul 13, 2007 at 02:55:55PM -0700, Christopher Barker wrote: > The other obvious option is to look for the ._* files, which is where > the resource fork is stored with the SMB protocol. However, we're > concerned that that may not be reliable -- if a file were put up with > SMB, then replaced with AFP, there may be a ._* file, but it won't > work right. This actually seems pretty likely as while we have this > mixed system, there have been a lot of "that didn't work, please put > the file back up with APF" iterations. Yeah, SFM uses NTFS's "stream" support to store the resource fork and other Mac specific metadata elsewhere. You can check the resource fork size by looking at "/path/to/file/..namedfork/rsrc" but since the type and creator aren't stored in the resource fork, you'll have to get those in other ways if you want to preserve them. Note that forthcoming Mac OS X versions may no longer use ._ files to store resource forks on SMB mounted volumes (some third-party clients already don't), instead reading/writing to alternate streams just as SFM does. -- Nicholas Riley | From njriley at uiuc.edu Sat Jul 14 01:16:50 2007 From: njriley at uiuc.edu (Nicholas Riley) Date: Fri, 13 Jul 2007 18:16:50 -0500 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <46980310.1040509@noaa.gov> References: <4697F4EB.203@noaa.gov> <597e7edb0707131526yf8b2e02t783c4909e7e23e27@mail.gmail.com> <46980310.1040509@noaa.gov> Message-ID: <20070713231650.GB18160@uiuc.edu> On Fri, Jul 13, 2007 at 03:56:16PM -0700, Christopher Barker wrote: > Hamish Allan wrote: > > Let me start by saying that I've never used MS services for Macintosh, > > so this is all guesswork. But the first thing I wondered was, if files > > uploaded over AFP aren't using ._* files, what are they using? > > The server is storing the resource forks somewhere, but not anywhere we > can see them - who knows? The resource forks live in the "AFP_Resource" stream, and the other file info in the "AFP_AfpInfo" stream. There's also a "Comments" stream which used to be used for Finder comments, but I don't think OS X uses it any more. For those Windows apps (not all) that understand multiple streams, you refer to them as "filename:streamname", e.g. "c:\temp\foo:AFP_Resource". But that's only useful if you're looking at it on Windows; if you're viewing it from the Mac over AFP then just use the Mac native mechanisms. When doing a search I discovered the "Fork Server Helper" app which might be useful to you, as it's designed to convert between resource fork storage formats. -- Nicholas Riley | From noah.gift at gmail.com Sun Jul 15 05:31:09 2007 From: noah.gift at gmail.com (Noah Gift) Date: Sat, 14 Jul 2007 23:31:09 -0400 Subject: [Pythonmac-SIG] Python support for Leopard Message-ID: Just an FYI, the version of Python for Leopard, 2.5.1 should reflect that latest revision. It ships with a broken Python. For the novice this could be quite a problem. -- http://www.blog.noahgift.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20070714/c32e682d/attachment.htm From ronaldoussoren at mac.com Sun Jul 15 08:51:35 2007 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Sun, 15 Jul 2007 09:51:35 +0300 Subject: [Pythonmac-SIG] Python support for Leopard In-Reply-To: References: Message-ID: <30AE3873-A9FD-429B-BF6B-C72D3550E971@mac.com> On 15 Jul, 2007, at 6:31, Noah Gift wrote: > Just an FYI, the version of Python for Leopard, 2.5.1 should reflect > that latest revision. It ships with a broken Python. For the > novice this could be quite a problem. Have you told Apple about this (at bugreport.apple.com)? Complaining in a public forum doesn't help for that, especially one that is not hosted by Apple. ... and even more so when you don't even say what's wrong. Ronald P.S. Leopard is under NDA, you're not supposed to mention anything about it in public unless the information is already made publicly available by Apple. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3562 bytes Desc: not available Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070715/2ca5e6b0/attachment.bin From aparente at adobe.com Mon Jul 16 20:28:50 2007 From: aparente at adobe.com (Alexandre Parenteau) Date: Mon, 16 Jul 2007 11:28:50 -0700 Subject: [Pythonmac-SIG] Python support for Leopard In-Reply-To: <30AE3873-A9FD-429B-BF6B-C72D3550E971@mac.com> Message-ID: Hi, We have a requirement for our python based tools to work with Leopard, and we happen also to have technical contact with Apple. Could you please explain why and how it is broken? I was hoping we could help by reporting the bug as well. Thanks! alex On 7/14/07 11:51 PM, "Ronald Oussoren" wrote: > > On 15 Jul, 2007, at 6:31, Noah Gift wrote: > >> Just an FYI, the version of Python for Leopard, 2.5.1 should reflect >> that latest revision. It ships with a broken Python. For the >> novice this could be quite a problem. > > Have you told Apple about this (at bugreport.apple.com)? Complaining > in a public forum doesn't help for that, especially one that is not > hosted by Apple. > > ... and even more so when you don't even say what's wrong. > > Ronald > > P.S. Leopard is under NDA, you're not supposed to mention anything > about it in public unless the information is already made publicly > available by Apple. > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From vip at avatar.com.au Tue Jul 17 04:52:10 2007 From: vip at avatar.com.au (David Worrall) Date: Tue, 17 Jul 2007 12:52:10 +1000 Subject: [Pythonmac-SIG] persistence speeds compared Message-ID: <565D0491-C08B-496C-B735-CD2AE4D452BE@avatar.com.au> Hi all, Does anyone know of a study which compares access-time on of the various python persistence technIques? I'm working w. a dynamic dataset of some 3500 tables - each table grows sequentially. Total data ~= 5GB Don't mind if it's a bit awkward - but for a time-critical applic. so needs to be as fast as possible. I haven't been able to find even a simple comparative analysis. Can anyone point me in the right direction? thanks heaps, David _________________________________________________ experimental polymedia: www.avatar.com.au Sonic Communications Research Group, University of Canberra: creative.canberra.edu.au/scrg From Chris.Barker at noaa.gov Tue Jul 17 07:08:13 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 16 Jul 2007 22:08:13 -0700 Subject: [Pythonmac-SIG] persistence speeds compared In-Reply-To: <565D0491-C08B-496C-B735-CD2AE4D452BE@avatar.com.au> References: <565D0491-C08B-496C-B735-CD2AE4D452BE@avatar.com.au> Message-ID: <469C4EBD.8050305@noaa.gov> David Worrall wrote: > I'm working w. a dynamic dataset of some 3500 tables - each table > grows sequentially. Total data ~= 5GB Sorry I've no comparisons for you, but what kind of data is it? If it's a lot of numbers and short strings, PyTables+ numpy could be very fast. MySQL has a reputation for speed, but interestingly, we found we got better performance from Durus (A pure python object persistence system) for a read only dataset, though not as big as yours. Beware the pitfalls of benchmarking -- I think you're probably going to need to make a prototype that does the kinds of things you need to do, and test a few systems yourself. good luck, -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception From Chris.Barker at noaa.gov Tue Jul 17 07:10:59 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 16 Jul 2007 22:10:59 -0700 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <20070713231650.GB18160@uiuc.edu> References: <4697F4EB.203@noaa.gov> <597e7edb0707131526yf8b2e02t783c4909e7e23e27@mail.gmail.com> <46980310.1040509@noaa.gov> <20070713231650.GB18160@uiuc.edu> Message-ID: <469C4F63.4090107@noaa.gov> Nicholas Riley wrote: > For those Windows apps (not all) that understand multiple streams, you > refer to them as "filename:streamname", I never had any idea Windows has "streams" indeed neither did anyone here. You learn something new every day. > When doing a search I discovered the "Fork Server Helper" app which > might be useful to you, as it's designed to convert between resource > fork storage formats. > > Yes we'd found that. At first blush, we didn't think it would work for us, but now it looks like it can -- we're going to give it try. Less fun than a Python solution, but probably less work. Thanks for all the tips, -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception From matthews at fetchsoftworks.com Tue Jul 17 21:27:22 2007 From: matthews at fetchsoftworks.com (Jim Matthews) Date: Tue, 17 Jul 2007 15:27:22 -0400 Subject: [Pythonmac-SIG] NSKeyedArchiver and NSMutableArray Message-ID: I'm trying to learn PyObjC by translating the examples in Aaron Hillegass's "Cocoa Programming for Mac OS X" to Python. I've run into a problem with the archiving feature described in chapter 8. I have an NSMutableArray of Person objects, where Person is a subclass of NSObject. I can turn the array into an NSData object with NSKeyedArchiver.archvedDataWithRootObject_(), but when I call NSKeyedUnarchiver.unarchiveObjectWithData_() I get back an empty array. Any suggestions? Here's simplified code that demonstrates the problem: from Foundation import * class Person(NSObject): def init(self): self = super(Person, self).init() if self is None: return self self.setPersonName_(u"New Person") return self def initWithCoder_(self, inCoder): self = super(Person, self).init() if self is None: return self self.setPersonName_(inCoder.decodeObjectForKey_('personName')) print 'Person.initWithCoder_ personName =', self.personName() def encodeWithCoder_(self, inCoder): print 'Person.encodeWithCoder_ personName =', self.personName() inCoder.encodeObject_forKey_(self.personName(), 'personName') def description(self): return super(Person, self).description() + '(' + self.personName() + ')' def personName(self): return self._personName def setPersonName_(self, inPersonName): self._personName = inPersonName ma = NSMutableArray.alloc().init() p1 = Person.alloc().init() p1.setPersonName_('John Doe') ma.insertObject_atIndex_(p1, 0) print 'ma =', ma.description() madata = NSKeyedArchiver.archivedDataWithRootObject_(ma) decodedma = NSKeyedUnarchiver.unarchiveObjectWithData_(madata) print 'decodedma =', decodedma.description() -- Expected output: ma = ((John Doe)) Person.encodeWithCoder_ personName = John Doe Person.initWithCoder_ personName = John Doe decodedma = ((John Doe)) Seen: ma = ((John Doe)) Person.encodeWithCoder_ personName = John Doe Person.initWithCoder_ personName = John Doe decodedma = () Thanks for any suggestions, -- Jim Matthews Fetch Softworks http://fetchsoftworks.com From vivacarlie at gmail.com Tue Jul 17 21:53:59 2007 From: vivacarlie at gmail.com (Nehemiah Dacres) Date: Tue, 17 Jul 2007 14:53:59 -0500 Subject: [Pythonmac-SIG] NSKeyedArchiver and NSMutableArray In-Reply-To: References: Message-ID: <65fadfc30707171253j3aa7ff7bm20b934a4afde0bea@mail.gmail.com> if im not mistaken, coder is a parameter also. I don have my book with me, if it works in objective c post the equivilant code in objc and i can work from there. I remember most of this excersize. I thought coder is the datatype of the object you're coding fore (id). "lalalalala! it's not broken because I can use it" http://linux.slashdot.org/comments.pl?sid=194281&threshold=1&commentsort=0&mode=thread&cid=15927703 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20070717/8c42af3c/attachment.htm From matthews at fetchsoftworks.com Tue Jul 17 22:19:48 2007 From: matthews at fetchsoftworks.com (Jim Matthews) Date: Tue, 17 Jul 2007 16:19:48 -0400 Subject: [Pythonmac-SIG] NSKeyedArchiver and NSMutableArray In-Reply-To: References: Message-ID: To answer my own question, the problem was that my initWithCoder_ method was not returning self. Bugs definitely become more obvious *after* you post the code for the rest of the world to see :). Thanks, -- Jim Matthews Fetch Softworks http://fetchsoftworks.com From ivilata at carabos.com Fri Jul 20 20:43:26 2007 From: ivilata at carabos.com (Ivan Vilata i Balaguer) Date: Fri, 20 Jul 2007 20:43:26 +0200 Subject: [Pythonmac-SIG] Semi-standalone Qt py2app can't find qt.so Message-ID: <20070720184326.GA23820@tardis.terramar.selidor.net> Hi people, I'm attaching an utterly trivial project (the hello world example from the PyQt tutorial) which shows that py2app-generated *semi-standalone* apps using Qt fail to run, apparently because of the path to the Qt libs included in the appdir not being placed in ``sys.path``. To check this yourselves, simply place ``MyApp.py`` and ``setup.py`` in the same directory, run ``python setup.py py2app`` and try to open the resulting app bundle which is left in the ``dist`` directory with Finder. This is the error dialog that I get:: MyApp Error MyApp Error An unexpected error has occurred during execution of the main script ImportError: '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/lib-dynload/qt.so' not found And these are the console messages:: Traceback (most recent call last): File "/Users/ivan/MyApp/dist/MyApp.app/Contents/Resources/__boot__.py", line 31, in _run('MyApp.py') File "/Users/ivan/MyApp/dist/MyApp.app/Contents/Resources/__boot__.py", line 28, in _run execfile(path, globals(), globals()) File "/Users/ivan/MyApp/dist/MyApp.app/Contents/Resources/MyApp.py", line 6, in import qt File "qt.pyc", line 18, in File "qt.pyc", line 15, in __load ImportError: '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/lib-dynload/qt.so' not found 2007-07-20 20:11:48.233 MyApp[286] MyApp Error 2007-07-20 20:11:48.235 MyApp[286] MyApp Error An unexpected error has occurred during execution of the main script ImportError: '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/lib-dynload/qt.so' not found Please note how the app is trying to load ``qt.so`` *from the system* instead of from the appdir. Running ``python MyApp.py`` works fine. I'm using Universal MacPython 2.5, PyQt 3.17 and py2app 0.3.6. :: Ivan Vilata i Balaguer >qo< http://www.carabos.com/ C?rabos Coop. V. V V Enjoy Data "" -------------- next part -------------- A non-text attachment was scrubbed... Name: MyApp.py Type: text/x-python Size: 223 bytes Desc: not available Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070720/26f2e8d4/attachment.py -------------- next part -------------- A non-text attachment was scrubbed... Name: setup.py Type: text/x-python Size: 151 bytes Desc: not available Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070720/26f2e8d4/attachment-0001.py -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: Digital signature Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070720/26f2e8d4/attachment.pgp From doug at vitamindinc.com Fri Jul 20 21:05:31 2007 From: doug at vitamindinc.com (Doug Anderson) Date: Fri, 20 Jul 2007 12:05:31 -0700 Subject: [Pythonmac-SIG] Semi-standalone Qt py2app can't find qt.so In-Reply-To: <20070720184326.GA23820@tardis.terramar.selidor.net> References: <20070720184326.GA23820@tardis.terramar.selidor.net> Message-ID: I'm not sure if it'll help, but I managed to set semi-standalone working by doing something like this (I've trimmed my actual usage, but I think this is all the important stuff): PLIST = {\ 'PyResourcePackages': [ 'lib/python2.4', 'lib/python2.4/lib-dynload', 'lib/python2.4/site-packages.zip', ], } OPTIONS = { 'argv_emulation': True, 'plist': PLIST, 'semi_standalone': True, 'use_pythonpath': True, } ...this got it to automatically include wxPython (which I wanted), but not to include python itself. It was a long time ago when I did this (so I only vaguely remember), but I believe that the "PyResourcePackages" was absolutely critical. Good luck! -Doug --- On Jul 20, 2007, at 11:43 AM, Ivan Vilata i Balaguer wrote: > Hi people, > > I'm attaching an utterly trivial project (the hello world example from > the PyQt tutorial) which shows that py2app-generated *semi-standalone* > apps using Qt fail to run, apparently because of the path to the Qt > libs > included in the appdir not being placed in ``sys.path``. > > To check this yourselves, simply place ``MyApp.py`` and > ``setup.py`` in > the same directory, run ``python setup.py py2app`` and try to open the > resulting app bundle which is left in the ``dist`` directory with > Finder. > > > This is the error dialog that I get:: > > MyApp Error > > MyApp Error > An unexpected error has occurred during execution of the main > script > > ImportError: '/Library/Frameworks/Python.framework/Versions/2.5/ > lib/ > python2.5/lib-dynload/qt.so' not found > > And these are the console messages:: > > Traceback (most recent call last): > File "/Users/ivan/MyApp/dist/MyApp.app/Contents/Resources/ > __boot__.py", > line 31, in > _run('MyApp.py') > File "/Users/ivan/MyApp/dist/MyApp.app/Contents/Resources/ > __boot__.py", > line 28, in _run > execfile(path, globals(), globals()) > File "/Users/ivan/MyApp/dist/MyApp.app/Contents/Resources/ > MyApp.py", > line 6, in > import qt > File "qt.pyc", line 18, in > File "qt.pyc", line 15, in __load > ImportError: '/Library/Frameworks/Python.framework/Versions/2.5/ > lib/ > python2.5/lib-dynload/qt.so' not found > 2007-07-20 20:11:48.233 MyApp[286] MyApp Error > 2007-07-20 20:11:48.235 MyApp[286] MyApp Error > An unexpected error has occurred during execution of the main > script > > ImportError: '/Library/Frameworks/Python.framework/Versions/2.5/ > lib/ > python2.5/lib-dynload/qt.so' not found > > > Please note how the app is trying to load ``qt.so`` *from the system* > instead of from the appdir. Running ``python MyApp.py`` works fine. > > I'm using Universal MacPython 2.5, PyQt 3.17 and py2app 0.3.6. > > :: > > Ivan Vilata i Balaguer >qo< http://www.carabos.com/ > C?rabos Coop. V. V V Enjoy Data > "" > > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From ivilata at carabos.com Sat Jul 21 13:19:08 2007 From: ivilata at carabos.com (Ivan Vilata i Balaguer) Date: Sat, 21 Jul 2007 13:19:08 +0200 Subject: [Pythonmac-SIG] Semi-standalone Qt py2app can't find qt.so In-Reply-To: References: <20070720184326.GA23820@tardis.terramar.selidor.net> Message-ID: <20070721111908.GA6320@tardis.terramar.selidor.net> Doug Anderson (el 2007-07-20 a les 12:05:31 -0700) va dir:: > I'm not sure if it'll help, but I managed to set semi-standalone > working by doing something like this (I've trimmed my actual usage, > but I think this is all the important stuff): > > PLIST = {\ > 'PyResourcePackages': [ > 'lib/python2.4', > 'lib/python2.4/lib-dynload', > 'lib/python2.4/site-packages.zip', > ], > } > > OPTIONS = { > 'argv_emulation': True, > 'plist': PLIST, > 'semi_standalone': True, > 'use_pythonpath': True, > } > [...] Really nice! I didn't find proper docs about ``PyResourcePackages``, but it seems to do the trick. My list only contains the ``lib-dynload`` path, which seems to be sufficient. However, running the app still failed in the same way, but complaining about not finding the ``sip`` module. Since the ``qt`` module depends on it and I'm not using the site packages, shouldn't py2app detect this and automatically include it into the app dir? Looks to me like some kind of shortcoming in the dependency detection process in py2app. Fortunately, this is quite easy to circumvent using the ``includes`` option... Thanks a lot Doug for the help! :: Ivan Vilata i Balaguer >qo< http://www.carabos.com/ C?rabos Coop. V. V V Enjoy Data "" -------------- next part -------------- A non-text attachment was scrubbed... Name: setup.py Type: text/x-python Size: 256 bytes Desc: not available Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070721/c3267b51/attachment.py -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: Digital signature Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070721/c3267b51/attachment.pgp From ronaldoussoren at mac.com Sun Jul 22 10:00:08 2007 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Sun, 22 Jul 2007 10:00:08 +0200 Subject: [Pythonmac-SIG] Semi-standalone Qt py2app can't find qt.so In-Reply-To: <20070721111908.GA6320@tardis.terramar.selidor.net> References: <20070720184326.GA23820@tardis.terramar.selidor.net> <20070721111908.GA6320@tardis.terramar.selidor.net> Message-ID: On 21 Jul, 2007, at 13:19, Ivan Vilata i Balaguer wrote: > Doug Anderson (el 2007-07-20 a les 12:05:31 -0700) va dir:: > >> I'm not sure if it'll help, but I managed to set semi-standalone >> working by doing something like this (I've trimmed my actual usage, >> but I think this is all the important stuff): >> >> PLIST = {\ >> 'PyResourcePackages': [ >> 'lib/python2.4', >> 'lib/python2.4/lib-dynload', >> 'lib/python2.4/site-packages.zip', >> ], >> } >> >> OPTIONS = { >> 'argv_emulation': True, >> 'plist': PLIST, >> 'semi_standalone': True, >> 'use_pythonpath': True, >> } >> [...] > > Really nice! I didn't find proper docs about ``PyResourcePackages``, > but it seems to do the trick. My list only contains the ``lib- > dynload`` > path, which seems to be sufficient. > > However, running the app still failed in the same way, but complaining > about not finding the ``sip`` module. Since the ``qt`` module depends > on it and I'm not using the site packages, shouldn't py2app detect > this > and automatically include it into the app dir? Looks to me like some > kind of shortcoming in the dependency detection process in py2app. > > Fortunately, this is quite easy to circumvent using the ``includes`` > option... py2app has a mechanism to do these adjustments automaticly, through "recipes". I don't use PyQt myself, but would appreciate a patch that adds a recipe for PyQt. That way py2app will do the right thing automaticly and your setup.py stays clean. Recipes are modules in the 'py2app.recipes' package, there are a number of them in the py2app source distribution. Ronald > > > Thanks a lot Doug for the help! > > :: > > Ivan Vilata i Balaguer >qo< http://www.carabos.com/ > C?rabos Coop. V. V V Enjoy Data > "" > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3562 bytes Desc: not available Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070722/2c702fa6/attachment.bin From riteshn at gmail.com Tue Jul 24 06:22:43 2007 From: riteshn at gmail.com (Ritesh Nadhani) Date: Mon, 23 Jul 2007 23:22:43 -0500 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X Message-ID: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> Hello So I want to install Python Imaging Library on my Mac OS X. I followed the tutorial steps by step. When I executed: IOError: decoder jpeg not available I got the error. Further Googling pointed me to the website: http://www.kyngchaos.com/macosx/install/libjpeg I downloaded the libtool updated linked there and unzipped it. It says that: Then, you need to update the libtool file in the source. Though I have no clue what does that mean. Unzipping it gave me two file ltconfig and ltconfig.sh. Running the sh file gave me libtool version mismatch error. Doing a search of system I found that there is another ltconfig in /usr/share/libtool. Assuming that this file needs to be updated with the one provided in the zip, I copied the original ltconfig.sh to ltconfig.sh.bak and copied the new one to the folder. The I followed the same steps as mentioned up there and the compilation and installation seems to have gone correctly. But again when I do selftest.py, I get: Exception raised: Traceback (most recent call last): File "./doctest.py", line 499, in _run_examples_inner exec compile(source, "", "single") in globs File "", line 1, in File "./selftest.py", line 22, in _info im.load() File "PIL/ImageFile.py", line 180, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "PIL/Image.py", line 375, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. Moreover, sudo python setup.py build_ext -i, give me: -------------------------------------------------------------------- PIL 1.1.6 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.6 platform darwin 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] -------------------------------------------------------------------- --- TKINTER support ok --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok -------------------------------------------------------------------- To check the build, run the selftest.py script. So it seems that the libraries were correctly found. -- Ritesh http://www.riteshn.com From daniellord at mac.com Tue Jul 24 06:35:02 2007 From: daniellord at mac.com (Daniel Lord) Date: Mon, 23 Jul 2007 21:35:02 -0700 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X In-Reply-To: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> References: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> Message-ID: <40304765-6279-4D2C-9627-2A7C3C5D5F5D@mac.com> It's been some time since I worked through this for 2.4, but IIRC, one has to modify the PIL make to ensure it finds libjpeg after you have installed it. How I did that I cannot recall just now off the cuff, so when I have time at some point I can try to dig it up. But in the mean time, if you are industrious and read the build notes for PIL, those pesky details might still be in there somewhere and clue you in to set it up properly so libjpeg is found by PIL on the build. If even I was able to solve it, I have no doubt that, with application, you will also and in a shorter time than I. Daniel On Jul 23, 2007, at 9:22 PM, Ritesh Nadhani wrote: > Hello > > So I want to install Python Imaging Library on my Mac OS X. I followed > the tutorial steps by step. When I executed: > > IOError: decoder jpeg not available > > I got the error. Further Googling pointed me to the website: > http://www.kyngchaos.com/macosx/install/libjpeg > > I downloaded the libtool updated linked there and unzipped it. It says > that: Then, you need to update the libtool file in the source. > > Though I have no clue what does that mean. Unzipping it gave me two > file ltconfig and ltconfig.sh. Running the sh file gave me libtool > version mismatch error. Doing a search of system I found that there is > another ltconfig in /usr/share/libtool. Assuming that this file needs > to be updated with the one provided in the zip, I copied the original > ltconfig.sh to ltconfig.sh.bak and copied the new one to the folder. > > The I followed the same steps as mentioned up there and the > compilation and installation seems to have gone correctly. > > But again when I do selftest.py, I get: > > Exception raised: > Traceback (most recent call last): > File "./doctest.py", line 499, in _run_examples_inner > exec compile(source, "", "single") in globs > File "", line 1, in > File "./selftest.py", line 22, in _info > im.load() > File "PIL/ImageFile.py", line 180, in load > d = Image._getdecoder(self.mode, d, a, self.decoderconfig) > File "PIL/Image.py", line 375, in _getdecoder > raise IOError("decoder %s not available" % decoder_name) > IOError: decoder jpeg not available > 1 items had failures: > 1 of 57 in selftest.testimage > ***Test Failed*** 1 failures. > *** 1 tests of 57 failed. > > Moreover, sudo python setup.py build_ext -i, give me: > > -------------------------------------------------------------------- > PIL 1.1.6 BUILD SUMMARY > -------------------------------------------------------------------- > version 1.1.6 > platform darwin 2.5 (r25:51918, Sep 19 2006, 08:49:13) > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] > -------------------------------------------------------------------- > --- TKINTER support ok > --- JPEG support ok > --- ZLIB (PNG/ZIP) support ok > --- FREETYPE2 support ok > -------------------------------------------------------------------- > To check the build, run the selftest.py script. > > So it seems that the libraries were correctly found. > > -- > Ritesh > http://www.riteshn.com > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From riteshn at gmail.com Tue Jul 24 06:39:47 2007 From: riteshn at gmail.com (Ritesh Nadhani) Date: Mon, 23 Jul 2007 23:39:47 -0500 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X In-Reply-To: <40304765-6279-4D2C-9627-2A7C3C5D5F5D@mac.com> References: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> <40304765-6279-4D2C-9627-2A7C3C5D5F5D@mac.com> Message-ID: <3ce825820707232139w656a4b5jf554f8eaed662d48@mail.gmail.com> Thanks for the pointer. I will work on it and hopefully somebody else can point me to the right direction if I dont find it myself :) On 7/23/07, Daniel Lord wrote: > It's been some time since I worked through this for 2.4, but IIRC, > one has to modify the PIL make to ensure it finds libjpeg after you > have installed it. > > How I did that I cannot recall just now off the cuff, so when I have > time at some point I can try to dig it up. > But in the mean time, if you are industrious and read the build notes > for PIL, > those pesky details might still be in there somewhere and clue you in > to set it up properly so libjpeg is found by PIL on the build. > If even I was able to solve it, I have no doubt that, with > application, you will also and in a shorter time than I. > > Daniel > > On Jul 23, 2007, at 9:22 PM, Ritesh Nadhani wrote: > > > Hello > > > > So I want to install Python Imaging Library on my Mac OS X. I followed > > the tutorial steps by step. When I executed: > > > > IOError: decoder jpeg not available > > > > I got the error. Further Googling pointed me to the website: > > http://www.kyngchaos.com/macosx/install/libjpeg > > > > I downloaded the libtool updated linked there and unzipped it. It says > > that: Then, you need to update the libtool file in the source. > > > > Though I have no clue what does that mean. Unzipping it gave me two > > file ltconfig and ltconfig.sh. Running the sh file gave me libtool > > version mismatch error. Doing a search of system I found that there is > > another ltconfig in /usr/share/libtool. Assuming that this file needs > > to be updated with the one provided in the zip, I copied the original > > ltconfig.sh to ltconfig.sh.bak and copied the new one to the folder. > > > > The I followed the same steps as mentioned up there and the > > compilation and installation seems to have gone correctly. > > > > But again when I do selftest.py, I get: > > > > Exception raised: > > Traceback (most recent call last): > > File "./doctest.py", line 499, in _run_examples_inner > > exec compile(source, "", "single") in globs > > File "", line 1, in > > File "./selftest.py", line 22, in _info > > im.load() > > File "PIL/ImageFile.py", line 180, in load > > d = Image._getdecoder(self.mode, d, a, self.decoderconfig) > > File "PIL/Image.py", line 375, in _getdecoder > > raise IOError("decoder %s not available" % decoder_name) > > IOError: decoder jpeg not available > > 1 items had failures: > > 1 of 57 in selftest.testimage > > ***Test Failed*** 1 failures. > > *** 1 tests of 57 failed. > > > > Moreover, sudo python setup.py build_ext -i, give me: > > > > -------------------------------------------------------------------- > > PIL 1.1.6 BUILD SUMMARY > > -------------------------------------------------------------------- > > version 1.1.6 > > platform darwin 2.5 (r25:51918, Sep 19 2006, 08:49:13) > > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] > > -------------------------------------------------------------------- > > --- TKINTER support ok > > --- JPEG support ok > > --- ZLIB (PNG/ZIP) support ok > > --- FREETYPE2 support ok > > -------------------------------------------------------------------- > > To check the build, run the selftest.py script. > > > > So it seems that the libraries were correctly found. > > > > -- > > Ritesh > > http://www.riteshn.com > > _______________________________________________ > > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > > http://mail.python.org/mailman/listinfo/pythonmac-sig > > -- Ritesh http://www.riteshn.com From riteshn at gmail.com Tue Jul 24 08:05:14 2007 From: riteshn at gmail.com (Ritesh Nadhani) Date: Tue, 24 Jul 2007 01:05:14 -0500 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X In-Reply-To: <6a36e7290707232250j2e4b7aedre995110e9a090e6e@mail.gmail.com> References: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> <6a36e7290707232250j2e4b7aedre995110e9a090e6e@mail.gmail.com> Message-ID: <3ce825820707232305r440113bfr21c2413c35faf3f5@mail.gmail.com> Yes. I even installed the PIL library for Mac OS X 2.5 and installed it. It installed correctly but when I run the selftest.py, it gives the same error Or Am I testing the wrong file? On 7/24/07, Bob Ippolito wrote: > On 7/23/07, Ritesh Nadhani wrote: > > Hello > > > > So I want to install Python Imaging Library on my Mac OS X. I followed > > the tutorial steps by step. When I executed: > > Have you looked at the packages here: > http://pythonmac.org/packages/ > > It may not be the absolute latest version, but installing should be dead simple. > > -bob > -- Ritesh http://www.riteshn.com From bob at redivi.com Tue Jul 24 07:50:41 2007 From: bob at redivi.com (Bob Ippolito) Date: Mon, 23 Jul 2007 22:50:41 -0700 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X In-Reply-To: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> References: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> Message-ID: <6a36e7290707232250j2e4b7aedre995110e9a090e6e@mail.gmail.com> On 7/23/07, Ritesh Nadhani wrote: > Hello > > So I want to install Python Imaging Library on my Mac OS X. I followed > the tutorial steps by step. When I executed: Have you looked at the packages here: http://pythonmac.org/packages/ It may not be the absolute latest version, but installing should be dead simple. -bob From riteshn at gmail.com Tue Jul 24 08:24:38 2007 From: riteshn at gmail.com (Ritesh Nadhani) Date: Tue, 24 Jul 2007 01:24:38 -0500 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X In-Reply-To: <3ce825820707232305r440113bfr21c2413c35faf3f5@mail.gmail.com> References: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> <6a36e7290707232250j2e4b7aedre995110e9a090e6e@mail.gmail.com> <3ce825820707232305r440113bfr21c2413c35faf3f5@mail.gmail.com> Message-ID: <3ce825820707232324n3dc01263s63c03756b72879ae@mail.gmail.com> Now this gets interesting, Believing that selftest.py is doing something wrong, I did: >>> import Image >>> im = Image.open("Images/lena.jpg") >>> print im.format, im.mode, im.size JPEG RGB (128, 128) but selftest.py fails with: Failure in example: _info(Image.open("Images/lena.jpg")) from line #24 of selftest.testimage Exception raised: Traceback (most recent call last): File "./doctest.py", line 499, in _run_examples_inner exec compile(source, "", "single") in globs File "", line 1, in File "./selftest.py", line 22, in _info im.load() File "PIL/ImageFile.py", line 180, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "PIL/Image.py", line 375, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. So now I am not sure. Basically I want PIL for this app: http://code.google.com/p/django-captcha/source I will have to run that app and see if it installed OK or not. Hmmm.... On 7/24/07, Ritesh Nadhani wrote: > Yes. > > I even installed the PIL library for Mac OS X 2.5 and installed it. It > installed correctly but when I run the selftest.py, it gives the same > error > > Or > > Am I testing the wrong file? > > On 7/24/07, Bob Ippolito wrote: > > On 7/23/07, Ritesh Nadhani wrote: > > > Hello > > > > > > So I want to install Python Imaging Library on my Mac OS X. I followed > > > the tutorial steps by step. When I executed: > > > > Have you looked at the packages here: > > http://pythonmac.org/packages/ > > > > It may not be the absolute latest version, but installing should be dead simple. > > > > -bob > > > > > -- > Ritesh > http://www.riteshn.com > -- Ritesh http://www.riteshn.com From bob at redivi.com Tue Jul 24 09:21:53 2007 From: bob at redivi.com (Bob Ippolito) Date: Tue, 24 Jul 2007 00:21:53 -0700 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X In-Reply-To: <3ce825820707232324n3dc01263s63c03756b72879ae@mail.gmail.com> References: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> <6a36e7290707232250j2e4b7aedre995110e9a090e6e@mail.gmail.com> <3ce825820707232305r440113bfr21c2413c35faf3f5@mail.gmail.com> <3ce825820707232324n3dc01263s63c03756b72879ae@mail.gmail.com> Message-ID: <6a36e7290707240021w627ba4dfnd14dcdfedca5f1ad@mail.gmail.com> On 7/23/07, Ritesh Nadhani wrote: > Now this gets interesting, Believing that selftest.py is doing > something wrong, I did: > > >>> import Image > >>> im = Image.open("Images/lena.jpg") > >>> print im.format, im.mode, im.size > JPEG RGB (128, 128) > > but selftest.py fails with: Running selftest.py tries to load the PIL package in-place, not the copy you have installed. Unless you have a correctly built it in that source directory you should expect it to fail. If you move PIL and PIL.pth out of the way then it will use the version you have installed and will probably pass all of the tests. -bob From riteshn at gmail.com Tue Jul 24 09:48:55 2007 From: riteshn at gmail.com (Ritesh Nadhani) Date: Tue, 24 Jul 2007 02:48:55 -0500 Subject: [Pythonmac-SIG] Trouble installing Python Imaging Library on Mac OS X In-Reply-To: <6a36e7290707240021w627ba4dfnd14dcdfedca5f1ad@mail.gmail.com> References: <3ce825820707232122y2cd7616evab5a432fc5553845@mail.gmail.com> <6a36e7290707232250j2e4b7aedre995110e9a090e6e@mail.gmail.com> <3ce825820707232305r440113bfr21c2413c35faf3f5@mail.gmail.com> <3ce825820707232324n3dc01263s63c03756b72879ae@mail.gmail.com> <6a36e7290707240021w627ba4dfnd14dcdfedca5f1ad@mail.gmail.com> Message-ID: <3ce825820707240048y13950f45he59e07319267fa9@mail.gmail.com> Indeed that was the case. Change the two files and now they work. Thanks. Maybe I had got it working in the first step itself but due to my ignorance about PIL and PIL.pth thought that it was not installed correctly. Thanks for helping me out. On 7/24/07, Bob Ippolito wrote: > On 7/23/07, Ritesh Nadhani wrote: > > Now this gets interesting, Believing that selftest.py is doing > > something wrong, I did: > > > > >>> import Image > > >>> im = Image.open("Images/lena.jpg") > > >>> print im.format, im.mode, im.size > > JPEG RGB (128, 128) > > > > but selftest.py fails with: > > Running selftest.py tries to load the PIL package in-place, not the > copy you have installed. Unless you have a correctly built it in that > source directory you should expect it to fail. If you move PIL and > PIL.pth out of the way then it will use the version you have installed > and will probably pass all of the tests. > > -bob > -- Ritesh http://www.riteshn.com From ivilata at carabos.com Wed Jul 25 18:46:29 2007 From: ivilata at carabos.com (Ivan Vilata i Balaguer) Date: Wed, 25 Jul 2007 18:46:29 +0200 Subject: [Pythonmac-SIG] Easy way to avoid Fatal Python error: Interpreter not initialized (version mismatch?) Message-ID: <20070725164629.GA7777@tardis.terramar.selidor.net> I've been looking for some hours for a more-or-less easy solution or workaround to the Fatal Python error: Interpreter not initialized (version mismatch?) Abort trap error that didn't imply uninstalling additional Pythons and the like, so I'm posting this here so at least people can find it when googling for it. ;) Quite surely not the best solution, but it looks quite simple. The problem comes from an extension being linked against the *default* Python (i.e. the one which pops up when running ``python``) instead of the requested one. When using GCC with ``-framework Python``, it accesses the Python framework in ``/Library/Frameworks/Python.framework``, and it uses some components right under it which happen to be links to paths under ``Versions/Current``, which is linked to the default version. In fact, when you inspect the extension which fails to load with ``otool -L EXTENSION.so`` you can see it's linked with the wrong Python library. The workaround for this is kludgy as I warned but at least is quite simple. It consists in *changing the default Python version* before building the failing extension:: $ cd /Library/Frameworks/Python.framework/Versions $ sudo rm Current && sudo ln -s 2.4 Current $ cd your_project_path $ python2.4 setup.py build_or_whatever Of course, change "2.4" to whatever Python version you need -- as long as it is installed. ;) If you want to recover your default version, simply run the first two lines with the proper version number. Just my 2 euro cents, :: Ivan Vilata i Balaguer >qo< http://www.carabos.com/ C?rabos Coop. V. V V Enjoy Data "" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: Digital signature Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070725/18cadb9f/attachment.pgp From ronaldoussoren at mac.com Wed Jul 25 21:33:28 2007 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Wed, 25 Jul 2007 21:33:28 +0200 Subject: [Pythonmac-SIG] Easy way to avoid Fatal Python error: Interpreter not initialized (version mismatch?) In-Reply-To: <20070725164629.GA7777@tardis.terramar.selidor.net> References: <20070725164629.GA7777@tardis.terramar.selidor.net> Message-ID: <329990CD-4473-42CB-9587-006914D7AAD8@mac.com> On 25 Jul, 2007, at 18:46, Ivan Vilata i Balaguer wrote: > I've been looking for some hours for a more-or-less easy solution or > workaround to the > > Fatal Python error: Interpreter not initialized (version mismatch?) > Abort trap > > error that didn't imply uninstalling additional Pythons and the > like, so > I'm posting this here so at least people can find it when googling for > it. ;) Quite surely not the best solution, but it looks quite simple. > > The problem comes from an extension being linked against the *default* > Python (i.e. the one which pops up when running ``python``) instead of > the requested one. When using GCC with ``-framework Python``, it > accesses the Python framework in ``/Library/Frameworks/ > Python.framework``, > and it uses some components right under it which happen to be links to > paths under ``Versions/Current``, which is linked to the default > version. In fact, when you inspect the extension which fails to load > with ``otool -L EXTENSION.so`` you can see it's linked with the wrong > Python library. Your instructions are technically valid, but... The right way (TM) to fix this is to change the project that uses '- framework Python' to link extensions because that is not the recommended way to link extensions on OSX. The best way to build extensions is using distutils, but that isn't always convenient in a large project that already has a different build infrastructure. In that case I'd copy the link flags used by distutils into the existing build infrastructure. Note that there are several reasons why linking with the python framework is a bad idea: 1) "-framework" doesn't actually work correctly when you want to link with a version other than the "Current" one 2) When you link with a framework (or other dynamic library) the full path to that library is embedded in the extensions. This means you cannot reuse the extension between python installations in different locations (e.g. /System/Library/Python, /Library/Python and /opt/ python, assuming all are using the same major release of python). You might not want to do this yourself, but that is something to keep in mind when distributing binary eggs. BTW. You're instructions aren't quite clear on this, but it is always a bad idea to use extensions compiled for one major release of python (2.X) with some other major release (2.Y). Using an extension of 2.X with 2.X+1 tends to work, but there is no guarantee for binary compatibility between major releases of Python. Ronald -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3562 bytes Desc: not available Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070725/119c6a44/attachment.bin From dav at alum.mit.edu Thu Jul 26 06:16:54 2007 From: dav at alum.mit.edu (Dav Clark) Date: Thu, 26 Jul 2007 00:16:54 -0400 Subject: [Pythonmac-SIG] PIL (1.1.6) working with py2app on intel macs? Message-ID: <1185423414.28213.1202102271@webmail.messagingengine.com> Hi there, I have a properly working copy of PIL 1.1.6 - I used this generic recipe: http://wiki.python.org/moin/MacPython/UniversalLibrariesAndExtensions I can load jpegs and see them in preview with im.show(). I installed py2app via easy_install, and also by downloading the tarball and installing... I see old posts about rebuilding the bootstrap, but no idea if this is still current, and if so what the bootstrap even _is_, let alone how to build it. But when I run an 'app', I still get the ol': ImportError: The _imaging C module is not installed Under Contents/Resources/lib/python2.3/lib-dynload/, I see both a _imaging.so AND a PIL/_imaging.so (among other things). I am using the system python2.3. Is anyone successful with this configuration? Any help would be appreciated! Dav Clark From dav at alum.mit.edu Thu Jul 26 06:26:03 2007 From: dav at alum.mit.edu (Dav Clark) Date: Thu, 26 Jul 2007 00:26:03 -0400 Subject: [Pythonmac-SIG] PIL (1.1.6) working with py2app on intel macs? In-Reply-To: <1185423414.28213.1202102271@webmail.messagingengine.com> References: <1185423414.28213.1202102271@webmail.messagingengine.com> Message-ID: <1185423963.29849.1202103851@webmail.messagingengine.com> I'll add to the below - on the Intel version, I have _only_ _imaging.so and _imagingtk.so. On my (working) PPC version, there are heaps of .so libs in the lib-dynload dir. Thanks, DC On Thu, 26 Jul 2007 00:16:54 -0400, "Dav Clark" said: > Hi there, > > I have a properly working copy of PIL 1.1.6 - I used this generic > recipe: > > http://wiki.python.org/moin/MacPython/UniversalLibrariesAndExtensions > > I can load jpegs and see them in preview with im.show(). > > I installed py2app via easy_install, and also by downloading the tarball > and installing... I see old posts about rebuilding the bootstrap, but no > idea if this is still current, and if so what the bootstrap even _is_, > let alone how to build it. > > But when I run an 'app', I still get the ol': > > ImportError: The _imaging C module is not installed > > Under Contents/Resources/lib/python2.3/lib-dynload/, I see both a > _imaging.so AND a PIL/_imaging.so (among other things). > > I am using the system python2.3. > > Is anyone successful with this configuration? Any help would be > appreciated! > > Dav Clark -- Dav Clark www.eCult.org 917-544-8408 From dav at alum.mit.edu Thu Jul 26 06:42:13 2007 From: dav at alum.mit.edu (Dav Clark) Date: Thu, 26 Jul 2007 00:42:13 -0400 Subject: [Pythonmac-SIG] PIL (1.1.6) working with py2app on intel macs? In-Reply-To: <1185423963.29849.1202103851@webmail.messagingengine.com> References: <1185423414.28213.1202102271@webmail.messagingengine.com> <1185423963.29849.1202103851@webmail.messagingengine.com> Message-ID: <1185424933.32116.1202105087@webmail.messagingengine.com> OK - last thing... I figured out that the missing .so files were (at least largely) from the standard python lib-dynload directory. I tried copying the files from /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/* to Contents/Resources/lib/python2.3/lib-dynload/ This also did not work. Cheers, Dav On Thu, 26 Jul 2007 00:26:03 -0400, "Dav Clark" said: > I'll add to the below - on the Intel version, I have _only_ _imaging.so > and _imagingtk.so. On my (working) PPC version, there are heaps of .so > libs in the lib-dynload dir. > > Thanks, > DC > > On Thu, 26 Jul 2007 00:16:54 -0400, "Dav Clark" said: > > Hi there, > > > > I have a properly working copy of PIL 1.1.6 - I used this generic > > recipe: > > > > http://wiki.python.org/moin/MacPython/UniversalLibrariesAndExtensions > > > > I can load jpegs and see them in preview with im.show(). > > > > I installed py2app via easy_install, and also by downloading the tarball > > and installing... I see old posts about rebuilding the bootstrap, but no > > idea if this is still current, and if so what the bootstrap even _is_, > > let alone how to build it. > > > > But when I run an 'app', I still get the ol': > > > > ImportError: The _imaging C module is not installed > > > > Under Contents/Resources/lib/python2.3/lib-dynload/, I see both a > > _imaging.so AND a PIL/_imaging.so (among other things). > > > > I am using the system python2.3. > > > > Is anyone successful with this configuration? Any help would be > > appreciated! > > > > Dav Clark > -- > Dav Clark > www.eCult.org > 917-544-8408 > -- Dav Clark www.eCult.org 917-544-8408 From ronaldoussoren at mac.com Thu Jul 26 07:58:48 2007 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Thu, 26 Jul 2007 07:58:48 +0200 Subject: [Pythonmac-SIG] PIL (1.1.6) working with py2app on intel macs? In-Reply-To: <1185424933.32116.1202105087@webmail.messagingengine.com> References: <1185423414.28213.1202102271@webmail.messagingengine.com> <1185423963.29849.1202103851@webmail.messagingengine.com> <1185424933.32116.1202105087@webmail.messagingengine.com> Message-ID: <310FE712-6ACF-47D9-A769-39974652A967@mac.com> On 26 Jul, 2007, at 6:42, Dav Clark wrote: > OK - last thing... > > I figured out that the missing .so files were (at least largely) from > the standard python lib-dynload directory. I tried copying the files > from > > /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/lib-dynload/* > > to > > Contents/Resources/lib/python2.3/lib-dynload/ > > This also did not work. That was to be expected. py2app won't copy the Python interpreter or stdlibrary from /System/Library/Python but will store a reference to those. That's because /System/Library/Python is part of the system install and hence present on all macs. Furthermore copying parts of the system into your application bundle is not quite permitted by the OSX license. I haven't had time to look at your problem yet. Does the problem occur in a small application that just uses PIL to load a JPG image or only in larger programs? If the latter, could you supply a project that reproduces this problem? Ronald > > > Cheers, > Dav > > On Thu, 26 Jul 2007 00:26:03 -0400, "Dav Clark" > said: >> I'll add to the below - on the Intel version, I have _only_ >> _imaging.so >> and _imagingtk.so. On my (working) PPC version, there are heaps >> of .so >> libs in the lib-dynload dir. >> >> Thanks, >> DC >> >> On Thu, 26 Jul 2007 00:16:54 -0400, "Dav Clark" >> said: >>> Hi there, >>> >>> I have a properly working copy of PIL 1.1.6 - I used this generic >>> recipe: >>> >>> http://wiki.python.org/moin/MacPython/ >>> UniversalLibrariesAndExtensions >>> >>> I can load jpegs and see them in preview with im.show(). >>> >>> I installed py2app via easy_install, and also by downloading the >>> tarball >>> and installing... I see old posts about rebuilding the bootstrap, >>> but no >>> idea if this is still current, and if so what the bootstrap even >>> _is_, >>> let alone how to build it. >>> >>> But when I run an 'app', I still get the ol': >>> >>> ImportError: The _imaging C module is not installed >>> >>> Under Contents/Resources/lib/python2.3/lib-dynload/, I see both a >>> _imaging.so AND a PIL/_imaging.so (among other things). >>> >>> I am using the system python2.3. >>> >>> Is anyone successful with this configuration? Any help would be >>> appreciated! >>> >>> Dav Clark >> -- >> Dav Clark >> www.eCult.org >> 917-544-8408 >> > -- > Dav Clark > www.eCult.org > 917-544-8408 > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3562 bytes Desc: not available Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070726/4ca1ffe3/attachment-0001.bin From dav at alum.mit.edu Thu Jul 26 08:22:45 2007 From: dav at alum.mit.edu (Dav Clark) Date: Thu, 26 Jul 2007 02:22:45 -0400 Subject: [Pythonmac-SIG] PIL (1.1.6) working with py2app on intel macs? In-Reply-To: <310FE712-6ACF-47D9-A769-39974652A967@mac.com> References: <1185423414.28213.1202102271@webmail.messagingengine.com> <1185423963.29849.1202103851@webmail.messagingengine.com> <1185424933.32116.1202105087@webmail.messagingengine.com> <310FE712-6ACF-47D9-A769-39974652A967@mac.com> Message-ID: <528B2DCC-8643-40E6-A0C6-61FD110A1822@alum.mit.edu> It is a very minimal, one-script program. All it does is use PIL to load a jpeg, rescale it and save it as a pgm. One thing I didn't mention (but that I checked the PIL recipe regarding) was that I have the libs for libjpeg and libfreetype installed in non-standard places - namely in ~/lib. This directory is listed in my LIBRARY_PATH. Cheers, Dav Clark 917-544-8408 On Jul 26, 2007, at 1:58 AM, Ronald Oussoren wrote: > I haven't had time to look at your problem yet. Does the problem > occur in a small application that just uses PIL to load a JPG image > or only in larger programs? If the latter, could you supply a > project that reproduces this problem? > > Ronald From ivilata at carabos.com Thu Jul 26 08:48:57 2007 From: ivilata at carabos.com (Ivan Vilata i Balaguer) Date: Thu, 26 Jul 2007 08:48:57 +0200 Subject: [Pythonmac-SIG] Easy way to avoid Fatal Python error: Interpreter not initialized (version mismatch?) In-Reply-To: <329990CD-4473-42CB-9587-006914D7AAD8@mac.com> References: <20070725164629.GA7777@tardis.terramar.selidor.net> <329990CD-4473-42CB-9587-006914D7AAD8@mac.com> Message-ID: <20070726064857.GA31517@tardis.terramar.selidor.net> Ronald Oussoren (el 2007-07-25 a les 21:33:28 +0200) va dir:: > Your instructions are technically valid, but... > > The right way (TM) to fix this is to change the project that uses '- > framework Python' to link extensions because that is not the > recommended way to link extensions on OSX. The best way to build > extensions is using distutils, but that isn't always convenient in a > large project that already has a different build infrastructure. In > that case I'd copy the link flags used by distutils into the existing > build infrastructure. > [...] Very interesting. In fact I encountered this problem when building SIP_, which uses a set of automatically generated makefiles instead of distutils for building and installing. But I also noticed that some people using PyQt, PyKDE and others have experienced similar problems. .. _sip: http://www.riverbankcomputing.co.uk/sip/index.php Mine was just a quick & dirty fix for casual users trying to build a package, let's hope that developers come across your explanation! :) I may get in contact with the author of SIP as well... :: Ivan Vilata i Balaguer >qo< http://www.carabos.com/ C?rabos Coop. V. V V Enjoy Data "" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: Digital signature Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070726/3cad5be7/attachment.pgp From dav at alum.mit.edu Fri Jul 27 05:27:53 2007 From: dav at alum.mit.edu (Dav Clark) Date: Thu, 26 Jul 2007 23:27:53 -0400 Subject: [Pythonmac-SIG] PIL (1.1.6) working with py2app on intel macs? In-Reply-To: <310FE712-6ACF-47D9-A769-39974652A967@mac.com> References: <1185423414.28213.1202102271@webmail.messagingengine.com> <1185423963.29849.1202103851@webmail.messagingengine.com> <1185424933.32116.1202105087@webmail.messagingengine.com> <310FE712-6ACF-47D9-A769-39974652A967@mac.com> Message-ID: <280F7944-0F35-4FAB-950F-21838C47E04B@alum.mit.edu> For what it's worth, I tried with the same script using the new 2.4.4 universal python and 1.1.5 pythonmac version of PIL. And that works. So, I'm not going to fuss with it anymore for my own sake, but would be happy to try to track down the bug if some maintainer type is interested. It would be nice to have a smaller app size... Dav Clark 917-544-8408 On Jul 26, 2007, at 1:58 AM, Ronald Oussoren wrote: > > On 26 Jul, 2007, at 6:42, Dav Clark wrote: > >> OK - last thing... >> >> I figured out that the missing .so files were (at least largely) from >> the standard python lib-dynload directory. I tried copying the files >> from >> >> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ >> python2.3/lib-dynload/* >> >> to >> >> Contents/Resources/lib/python2.3/lib-dynload/ >> >> This also did not work. > > That was to be expected. py2app won't copy the Python interpreter > or stdlibrary from /System/Library/Python but will store a > reference to those. That's because /System/Library/Python is part > of the system install and hence present on all macs. Furthermore > copying parts of the system into your application bundle is not > quite permitted by the OSX license. > > I haven't had time to look at your problem yet. Does the problem > occur in a small application that just uses PIL to load a JPG image > or only in larger programs? If the latter, could you supply a > project that reproduces this problem? > > Ronald > >> >> >> Cheers, >> Dav >> >> On Thu, 26 Jul 2007 00:26:03 -0400, "Dav Clark" >> said: >>> I'll add to the below - on the Intel version, I have _only_ >>> _imaging.so >>> and _imagingtk.so. On my (working) PPC version, there are heaps >>> of .so >>> libs in the lib-dynload dir. >>> >>> Thanks, >>> DC >>> >>> On Thu, 26 Jul 2007 00:16:54 -0400, "Dav Clark" >>> said: >>>> Hi there, >>>> >>>> I have a properly working copy of PIL 1.1.6 - I used this generic >>>> recipe: >>>> >>>> http://wiki.python.org/moin/MacPython/ >>>> UniversalLibrariesAndExtensions >>>> >>>> I can load jpegs and see them in preview with im.show(). >>>> >>>> I installed py2app via easy_install, and also by downloading the >>>> tarball >>>> and installing... I see old posts about rebuilding the >>>> bootstrap, but no >>>> idea if this is still current, and if so what the bootstrap even >>>> _is_, >>>> let alone how to build it. >>>> >>>> But when I run an 'app', I still get the ol': >>>> >>>> ImportError: The _imaging C module is not installed >>>> >>>> Under Contents/Resources/lib/python2.3/lib-dynload/, I see both a >>>> _imaging.so AND a PIL/_imaging.so (among other things). >>>> >>>> I am using the system python2.3. >>>> >>>> Is anyone successful with this configuration? Any help would be >>>> appreciated! >>>> >>>> Dav Clark >>> -- >>> Dav Clark >>> www.eCult.org >>> 917-544-8408 >>> >> -- >> Dav Clark >> www.eCult.org >> 917-544-8408 >> >> _______________________________________________ >> Pythonmac-SIG maillist - Pythonmac-SIG at python.org >> http://mail.python.org/mailman/listinfo/pythonmac-sig > From stvsmth at gmail.com Fri Jul 27 05:36:07 2007 From: stvsmth at gmail.com (stv) Date: Thu, 26 Jul 2007 21:36:07 -0600 Subject: [Pythonmac-SIG] Compiling cx_Oracle Message-ID: <9493d0340707262036m34bf8bbas49bd9a157ae1279@mail.gmail.com> I am trying to compile cx_Oracle for my Intel Mac 10.4.9 / Python 2.4.4 installation, but when I import the compile .so file I get ImportError: Failure linking new module (Detail below). I have the Oracle instant client installed, including the SDK package for the header files. In order to pacify the compiler warnings, I created symbolic links for the two dylibs that ended in 10.1 /Applications/instantclient/libclntsh.dylib@ -> libclntsh.dylib.10.1 /Applications/instantclient/libocci.dylib@ -> libocci.dylib.10.1 The following builds the cx_Oracle.so and installs it into site-packages, but the import fails as follows: $ sudo python setup.py install running install running build running build_ext running install_lib $ python Python 2.4.4 (#1, May 21 2007, 11:26:22) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import cx_Oracle Traceback (most recent call last): File "", line 1, in ? ImportError: Failure linking new module: /opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/cx_Oracle.so: Symbol not found: _OCINumberFromInt Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/cx_Oracle.so Expected in: dynamic lookup >>> I've stepped out of my aging compiler expertis.... er, memories. Dynamically linked libraries, statically linked libraries, it's all a blur now. Tis what I love about Python : ) Any tips are appreciated. I found only one page Googling about (which gave me symbolic link tip) http://pedro.emanuel.familiasalgado.org/?p=103 --stv From woklist at kyngchaos.com Fri Jul 27 06:01:12 2007 From: woklist at kyngchaos.com (William Kyngesburye) Date: Thu, 26 Jul 2007 23:01:12 -0500 Subject: [Pythonmac-SIG] Compiling cx_Oracle In-Reply-To: <9493d0340707262036m34bf8bbas49bd9a157ae1279@mail.gmail.com> References: <9493d0340707262036m34bf8bbas49bd9a157ae1279@mail.gmail.com> Message-ID: <08BD4AE9-7401-4F45-9DEB-A411945DE3ED@kyngchaos.com> Ah, Oracle. Last I checked, the OCI libraries are PPC-only. You will not be able link Intel OSX software to them. Unfortunately, there seems to be little chance that Oracle will update any of their software for Intel OSX any time soon, if at all. On Jul 26, 2007, at 10:36 PM, stv wrote: > I am trying to compile cx_Oracle for my Intel Mac 10.4.9 / Python > 2.4.4 installation, but when I import the compile .so file I get > ImportError: Failure linking new module (Detail below). > > I have the Oracle instant client installed, including the SDK package > for the header files. In order to pacify the compiler warnings, I > created symbolic links for the two dylibs that ended in 10.1 > ----- William Kyngesburye http://www.kyngchaos.com/ "History is an illusion caused by the passage of time, and time is an illusion caused by the passage of history." - Hitchhiker's Guide to the Galaxy From vivacarlie at gmail.com Fri Jul 27 16:07:23 2007 From: vivacarlie at gmail.com (Nehemiah Dacres) Date: Fri, 27 Jul 2007 09:07:23 -0500 Subject: [Pythonmac-SIG] Compiling cx_Oracle In-Reply-To: <08BD4AE9-7401-4F45-9DEB-A411945DE3ED@kyngchaos.com> References: <9493d0340707262036m34bf8bbas49bd9a157ae1279@mail.gmail.com> <08BD4AE9-7401-4F45-9DEB-A411945DE3ED@kyngchaos.com> Message-ID: <65fadfc30707270707yda7511fid27996213c832251@mail.gmail.com> make sure orical sin't more than you need. the reason sql light is the standard python database is the same reason Tk is the standard gui toolkit. they are light weight, ultra portable, and do most of what u need -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20070727/b7b1206d/attachment.htm From barkmann at gmail.com Fri Jul 13 02:16:45 2007 From: barkmann at gmail.com (Donna and Chris Barker) Date: Fri, 13 Jul 2007 00:16:45 -0000 Subject: [Pythonmac-SIG] Accessing Resource forks Message-ID: <5ec4bffd0707121716t217d0d9chedb01cfc24c0023@mail.gmail.com> HI all, Somehow over all these years, I've managed to use Python on MAcs without having it deal with resource forks and sll that -- but ironically, not that we're all OS-X all the time, I need to do ti now. What I'm trying to do is simple check for the existance of a resource fork, and if it's there, the size. This is what I've tried: import Carbon.File as File files = ["junk.txt", "junk_rsc.txt"] for filename in files: f = File.FSRef(filename) print "file path is:", f.FSRefMakePath() i = f.FSGetCatalogInfo(0) print "logical size is:", i[0].rsrcLogicalSize print "Physical size is:", i[0].rsrcPhysicalSize In this case, junk.txt was created at the command line, so it shouldn't have a resource fork. junk_rsc.txt I opened up in resedit, which should have given it a small resource fork. Runnign this script, I get: file path is: /Users/cbarker/temp/AFP-SMB/junk.txt logical size is: 65543 Physical size is: 30457855 file path is: /Users/cbarker/temp/AFP-SMB/junk_rsc.txt logical size is: -593231776 Physical size is: -210763775 The paths are right, so it looks like I've got the FSRef right, but rsrcLogicalSize and rsrcPhysicalSize make no sense. How should I be doing this -- the docs are sparse, to say the least! By the way, I might as well tell you the real goal, maybe one of you will have a better idea. We have a Windows file server that is about to be retired. over the years, people of have put files on it using both the AFP and SMB protocols (the server is running MS services for macintosh). These are all mixed up. However, any file put up with one protocol loses it's resource fork (and type and creator) if brought down with the other protocol. Our goal is to clean up this mess automatically. The idea at hand is that a file brought down with AFP will either: Have a nice resource fork, in which case it was put up with AFP, and we're happy Have no resource fork, in which case it never had one, and we dont' care what protocol was used, or it was put up with SMB, and we can then bring it down that way instead. The other obvious option is to look for the ._* files, which is where the resource fork is stored with the SMB protocol. However, we're concerned that that may not be reliable -- if a file were put up with SMB, then replaced with AFP, there may be a ._* file, but it won't work right. This actually seems pretty likely as while we have this mixed system, there have been a lot of "that didn't work, please put the file back up with APF" interations. Thanks for your thoughts. -Chris From daniellord at mac.com Mon Jul 30 12:04:42 2007 From: daniellord at mac.com (Daniel Lord) Date: Mon, 30 Jul 2007 03:04:42 -0700 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <5ec4bffd0707121716t217d0d9chedb01cfc24c0023@mail.gmail.com> References: <5ec4bffd0707121716t217d0d9chedb01cfc24c0023@mail.gmail.com> Message-ID: <8C6874B1-5FA8-4A14-855E-8CAA96052089@mac.com> Chris, I know you already asked this and got answers, so I did not at first understand why you asked again. Then I saw the date of the message. I think that in you search for a solution to handling antiquated resource forks, you might have discovered time travel as a side effect. Patent what ever you did and quickly ;-) Strange. Daniel On Jul 12, 2007, at 5:16 PM, Donna and Chris Barker wrote: > HI all, > > Somehow over all these years, I've managed to use Python on MAcs > without having it deal with resource forks and sll that -- but > ironically, not that we're all OS-X all the time, I need to do ti now. > > What I'm trying to do is simple check for the existance of a resource > fork, and if it's there, the size. > > > This is what I've tried: > > import Carbon.File as File > files = ["junk.txt", "junk_rsc.txt"] > > for filename in files: > f = File.FSRef(filename) > print "file path is:", f.FSRefMakePath() > > i = f.FSGetCatalogInfo(0) > print "logical size is:", i[0].rsrcLogicalSize > print "Physical size is:", i[0].rsrcPhysicalSize > > In this case, junk.txt was created at the command line, so it > shouldn't have a resource fork. junk_rsc.txt I opened up in resedit, > which should have given it a small resource fork. Runnign this script, > I get: > > file path is: /Users/cbarker/temp/AFP-SMB/junk.txt > logical size is: 65543 > Physical size is: 30457855 > file path is: /Users/cbarker/temp/AFP-SMB/junk_rsc.txt > logical size is: -593231776 > Physical size is: -210763775 > > The paths are right, so it looks like I've got the FSRef right, but > rsrcLogicalSize and rsrcPhysicalSize make no sense. > > How should I be doing this -- the docs are sparse, to say the least! > > By the way, I might as well tell you the real goal, maybe one of you > will have a better idea. > > We have a Windows file server that is about to be retired. over the > years, people of have put files on it using both the AFP and SMB > protocols (the server is running MS services for macintosh). These are > all mixed up. However, any file put up with one protocol loses it's > resource fork (and type and creator) if brought down with the other > protocol. > > Our goal is to clean up this mess automatically. > > The idea at hand is that a file brought down with AFP will either: > > Have a nice resource fork, in which case it was put up with AFP, > and we're happy > Have no resource fork, in which case it never had one, and we dont' > care what protocol was used, or it was put up with SMB, and we can > then bring it down that way instead. > > The other obvious option is to look for the ._* files, which is where > the resource fork is stored with the SMB protocol. However, we're > concerned that that may not be reliable -- if a file were put up with > SMB, then replaced with AFP, there may be a ._* file, but it won't > work right. This actually seems pretty likely as while we have this > mixed system, there have been a lot of "that didn't work, please put > the file back up with APF" interations. > > Thanks for your thoughts. > > -Chris > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From Chris.Barker at noaa.gov Mon Jul 30 20:52:01 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 30 Jul 2007 11:52:01 -0700 Subject: [Pythonmac-SIG] Accessing Resource forks In-Reply-To: <8C6874B1-5FA8-4A14-855E-8CAA96052089@mac.com> References: <5ec4bffd0707121716t217d0d9chedb01cfc24c0023@mail.gmail.com> <8C6874B1-5FA8-4A14-855E-8CAA96052089@mac.com> Message-ID: <46AE3351.5050008@noaa.gov> Daniel Lord wrote: > you might have > discovered time travel as a side effect. > Patent what ever you did and quickly ;-) If you note, that is a gmail address -- I guess it's Google that has mastered time travel. That's what you get for hiring all those brilliant people and giving them freedom to experiment with some fraction of their time! -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov