From davbrow at gmail.com Thu Dec 1 01:40:22 2005 From: davbrow at gmail.com (Dave) Date: Wed, 30 Nov 2005 16:40:22 -0800 Subject: [Pythonmac-SIG] readline support in ActivePython 2.4.2? In-Reply-To: <438DE727.6070804@noaa.gov> References: <588f52020511292301k3725f797p7949a9f3f5ec9dd2@mail.gmail.com> <438DE727.6070804@noaa.gov> Message-ID: <588f52020511301640u883c320gcc9e9cc39ca6a25d@mail.gmail.com> On 11/30/05, Chris Barker wrote: > > > > Dave wrote: > > > I'm not done with installs. I tried to install matplotlib from source > > to get a current version. That went equally as well (i.e., bad), > > possibly for similar reasons, but that's another story. > > Did you follow the process I used for the older MPL package at > pythonmac.org? The instructions should be in the package. If so, what > happened? > > I'm sorry I don't have the need for it right now, so it's hard to make > the time. > > By the way, if you get it working, please do contribute it back to > pythonmac.org. > > -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 > > Chris.Barker at noaa.gov Chris, I did try to use those notes and another document from a web site. I posted a question with the error report on matplotlib-users so I'll just summarize here: [I said] > > I compiled/installed versions of freetype and libpng but I'm not really > sure if or how to get matplotlib to find them. Anyway, I didn't > notice errors when matplotlib installed but when running ipython and > typing import pylab I get the exception below. > > > /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag= > es/matplotlib/font_manager.py > 37 import matplotlib > 38 from matplotlib import afm > ---> 39 from matplotlib import ft2font > 40 from matplotlib import rcParams, get_data_path, get_home, > get_confi= > gdir > 41 > > ImportError: Failure linking new module: > > /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag= > es/matplotlib/ft2font.so: > Symbol not found: _vsprintf$LDBLStub > Referenced from: > > /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag= > es/matplotlib/ft2font.so > Expected in: dynamic lookup > It was late night when I originally posted this but now I can guess what it might mean. Is ft2font.so the actual name of the binary freetype library file? And let me guess, I need to drag a file with that name into site-packages/matplotlib? I don't have acces to the machine right now but I'll try tonight. Originally I thought that the error was coming from an existing module called ft2font.so but perhaps that's not the case? In general will unix apps that need libraries find them if they are found on your $PATH or are they hard-coded to look somewhere specific. I keep running into library and path issues again and again on unix systems. -- Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051130/c61ea211/attachment.htm From Chris.Barker at noaa.gov Thu Dec 1 01:59:56 2005 From: Chris.Barker at noaa.gov (Chris Barker) Date: Wed, 30 Nov 2005 16:59:56 -0800 Subject: [Pythonmac-SIG] readline support in ActivePython 2.4.2? In-Reply-To: <588f52020511301640u883c320gcc9e9cc39ca6a25d@mail.gmail.com> References: <588f52020511292301k3725f797p7949a9f3f5ec9dd2@mail.gmail.com> <438DE727.6070804@noaa.gov> <588f52020511301640u883c320gcc9e9cc39ca6a25d@mail.gmail.com> Message-ID: <438E4B0C.8010506@noaa.gov> Dave wrote: > Chris, > I did try to use those notes Those notes specifically addressed how to statically link the extra libs, so you probably missed something, which is probably because I didn't write them very clearly. > I posted > a question with the error report on matplotlib-users I saw that, but had no time to help right then. >>I compiled/installed versions of freetype and libpng but I'm not really >>sure if or how to get matplotlib to find them. >>/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag= >>es/matplotlib/ft2font.so: >>Symbol not found: _vsprintf$LDBLStub >> Referenced from: >> >>/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag= >>es/matplotlib/ft2font.so > It was late night when I originally posted this but now I can guess what it > might mean. Is ft2font.so the actual name of the binary freetype library > file? That's an MPL compiled module that should have been created during the build, and it looks like it was. > And let me guess, I need to drag a file with that name into > site-packages/matplotlib? It should be there already. If not, something went wrong with the install. > In general will unix apps that need libraries find them if they are found on > your $PATH or are they hard-coded to look somewhere specific. no, they look for them in the dynamic library path. On Linux, this is defined in /etc/ld.conf. I'm not sure about OS-X. In this case, I think you're right, it's looking for the freetype libs, and not finding them. I'm not sure where they should be, or how to add to the path OS-X looks for them in. > I keep > running into library and path issues again and again on unix systems. I've and fewer of them than on Windows!. My solution was to build MPL against the static libs. It shouldn't be necessary for your own system, but it makes it a lot easier to distribute, and does get rid of the Path issues one you've got it built. I'll spend a few minutes messing with it now, but I don't' actually need it right now, so I won't put in much time. -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 Chris.Barker at noaa.gov From lanceboyle at bluebottle.com Thu Dec 1 04:09:35 2005 From: lanceboyle at bluebottle.com (lanceboyle@bluebottle.com) Date: Wed, 30 Nov 2005 20:09:35 -0700 Subject: [Pythonmac-SIG] Selecting in BBEdit & Python Indenting style(spaces) In-Reply-To: <438DC13E.2040407@anvil.nrl.navy.mil> References: <438CCE05.4080905@anvil.nrl.navy.mil> <438DC13E.2040407@anvil.nrl.navy.mil> Message-ID: On Nov 30, 2005, at 8:11 AM, Louis Pecora wrote: >> I run into this all the time in C with those I develop with. We try >> to keep it to spaces but some people forget that their editor puts in >> a tab automatically for 8 spaces and then spaces after that to column >> 12 for example. Then my editor which sets tabs to 4 spaces has >> indentation all messed up. >> >> >> > > But in C it doesn't matter for the code to compile and run. The question in non-Python languages relates to readability of the code. Since C is unreadable anyway, having consistent indenting is irrelevant. 8^) Jerry From lanceboyle at bluebottle.com Thu Dec 1 04:09:51 2005 From: lanceboyle at bluebottle.com (lanceboyle@bluebottle.com) Date: Wed, 30 Nov 2005 20:09:51 -0700 Subject: [Pythonmac-SIG] Fwd: Preferred IDE In-Reply-To: <438C8C95.3080208@noaa.gov> References: <0F2BBC0D-0DD4-4773-9036-A0E0196640B4@strozllc.com> <438C8C95.3080208@noaa.gov> Message-ID: <3BD2A19B-4A97-4186-B744-4D731B6B4F82@bluebottle.com> On Nov 29, 2005, at 10:15 AM, Chris Barker wrote: > I'm still looking for a nice modern, platform independent, general > purpose, fully customizable (preferably in Python) text editor. SPE is > heading that way, and Pepper (http://digitalwandering.com/) still has > promise. > > I thought that Pepper is no longer being developed. I could be wrong. Jerry From lanceboyle at bluebottle.com Thu Dec 1 04:09:59 2005 From: lanceboyle at bluebottle.com (lanceboyle@bluebottle.com) Date: Wed, 30 Nov 2005 20:09:59 -0700 Subject: [Pythonmac-SIG] Fwd: Preferred IDE In-Reply-To: References: <0F2BBC0D-0DD4-4773-9036-A0E0196640B4@strozllc.com> <438C8C95.3080208@noaa.gov> Message-ID: <196B3DE4-C416-408E-84AB-F51FCFB2A2DC@bluebottle.com> On Nov 29, 2005, at 1:03 PM, David M. Cooke wrote: > > I've submitted a patch for Smultron that does this when "indent with > spaces" is turned on: > http://sourceforge.net/tracker/index.php? > func=detail&aid=1356887&group_id=110857&atid=657594 > Smultron looks quite nice, but I don't see a way to submit files for execution, or to get console output back. Does it require switching to Terminal or the like, or am I missing something? Jerry From altern2 at gmail.com Thu Dec 1 14:20:35 2005 From: altern2 at gmail.com (altern) Date: Thu, 01 Dec 2005 14:20:35 +0100 Subject: [Pythonmac-SIG] Fwd: Preferred IDE In-Reply-To: <196B3DE4-C416-408E-84AB-F51FCFB2A2DC@bluebottle.com> References: <0F2BBC0D-0DD4-4773-9036-A0E0196640B4@strozllc.com> <438C8C95.3080208@noaa.gov> <196B3DE4-C416-408E-84AB-F51FCFB2A2DC@bluebottle.com> Message-ID: <438EF8A3.6090905@gmail.com> lanceboyle at bluebottle.com(e)k dio: > On Nov 29, 2005, at 1:03 PM, David M. Cooke wrote: > > > >>I've submitted a patch for Smultron that does this when "indent with >>spaces" is turned on: >>http://sourceforge.net/tracker/index.php? >>func=detail&aid=1356887&group_id=110857&atid=657594 >> > > > Smultron looks quite nice, but I don't see a way to submit files for > execution, or to get console output back. Does it require switching > to Terminal or the like, or am I missing something? as far as i know there is no way to do that in Smultron, but i might be wron. This is a pitty but i guess smultron it is a general editor. Thats actually the only thing that keeps me away from using it with python. In pyoxide you can open a console with python from within the editor and this is very handy to try things out. > Jerry From spe.stani.be at gmail.com Thu Dec 1 17:07:43 2005 From: spe.stani.be at gmail.com (SPE Stani's Python Editor) Date: Thu, 1 Dec 2005 17:07:43 +0100 Subject: [Pythonmac-SIG] ANN: SPE 0.8.0.b Python IDE (Mac support, doc viewer and workspaces) Message-ID: <2078a7ad0512010807p54740c1dx1b27bf9232dc36a9@mail.gmail.com> :**What's new?**: SPE 'Kay release' 0.8.0.b This release is a major step forward for all platforms, especially for MacOS X. It offers you basic project management through workspaces (thanks to Thurston Stone), an improved sidebar and pydoc viewer. This is the first release which is also developed and tested on the Mac. If SPE is stable enough, I'll try to build SPE as an application for the Mac. This version aims stability, so please help to report and fix all bugs! You can get involved on the SPE dev mailing list: https://developer.berlios.de/mail/?group_id=4161 The advertisements on SPE's websites generate a moderate, but necesssary income. From now on if you donate, you can ask me by email an ad-free, nice pdf version of the manual. :**About SPE**: SPE is a python IDE with auto-indentation, auto completion, call tips, syntax coloring, uml viewer, syntax highlighting, class explorer, source index, auto todo list, sticky notes, integrated pycrust shell, python file browser, recent file browser, drag&drop, context help, ... Special is its blender support with a blender 3d object browser and its ability to run interactively inside blender. Spe ships with wxGlade (gui designer), PyChecker (source code doctor) and Kiki (regular expression console). :**New features**: - stability - workspaces to manage your projects - documentation viewer (pydoc) - smart indentation: dedent after break, return, etc... - realtime updating of sidebar: explore, todo & index - check source realtime for syntax errors (optional) - backup files (.py.bak) are now optional :**Improved features**: - find in files :**Bug fixes**: - Workspace bugs (closing files) - Installer (Windows) - all these mac bugs are fixed: + Find dialog focus + Sticky notes + Find in files tab + Toolbar keyboard shortcut display + Kiki: regex console + SPE crashes on close + preferences dialog: combobox bug + debug dialog: combobox bug + wxGlade won't launch + winPdb won't launch + 2x window menu bug + context menu bug + open & run in terminal emulator + pythonw debug message + spe script bug + exception when closing file + PyChecker :**Installation**: See http://pythonide.stani.be/manual/html/manual2.html There is now an update section for MacOS X! :**Websites**: - homepage: http://pythonide.stani.be - manual: http://pythonide.stani.be/manual/html/manual.html - news blog: http://pythonide.stani.be/blog :**Contributors**: - Thurston Stone (workspaces) - Glenn Washburn (patches) - Henning Hraban Ramm (Mac support) - Kay Fricke (Mac support) - Stefan Csomor (wxMac support) - and many more... :**Donations**: Special thanks to Richard Brown of Dartware for starting the fund raising campaign of the mini-mac for SPE. A lot of the donations below are done specifically for this purpose. Impressive that the smallest user base of SPE generated generously the largest donations ever. Many thanks. Maybe it's time now for Window and Linux users to catch up! - Dartware (250 euro) - Rick Thomas (161 euro) - Brian Myers (100 euro) - Advanced Concepts AG (50 euro) - Ernesto Costa (50 euro) - Henning Hraban Ramm (50 euro) - Peter Koppatz (50 euro) - Kevin Murphy (50 euro) - Stefano Morandi (50 euro) - Kenneth McDonald (40 euro) - Barrett Smith (25 euro) - Irakli Nadareishvili (20 euro) - Jonathan Roadley-Battin (20 euro) - Brendan Simons (15 euro) - Edwin Ellis (15 euro) - Ian Ozsvald (15 euro) - Michael Smith (15 euro) - Eduardo Gonzalez (10 euro) - Phil Hargett (10 euro) - David Diskin (5 euro) Thanks for this generous support! Stani From gabor at nekomancer.net Fri Dec 2 00:02:53 2005 From: gabor at nekomancer.net (=?UTF-8?B?R8OhYm9yIEZhcmthcw==?=) Date: Fri, 02 Dec 2005 00:02:53 +0100 Subject: [Pythonmac-SIG] iphoto, slow Message-ID: <438F811D.6030708@nekomancer.net> hi, i am trying to print out all my photo's names, together with their keywords. import appscript app = appscript.app('iphoto') def parsePhoto(photo): tags = [keyword.name() for keyword in photo.keywords()] return (photo.name(),tags) for photo in app.photos(): print parsePhoto(photo) this code works, but it's TERRIBLY slow :) the problem is the parsePhoto function... those keyword.name(), photo.name(), photo.keywords() calls take nearly a second to complete... when printing out info about 3000photos, this will take some time :) is there a better way to do this? perharps get the data about multiple photos at the same time? i just cannot believe iPhoto itself is so slow to provide the required data... thanks, gabor From hengist.podd at virgin.net Fri Dec 2 01:00:27 2005 From: hengist.podd at virgin.net (has) Date: Fri, 2 Dec 2005 00:00:27 +0000 Subject: [Pythonmac-SIG] iphoto, slow Message-ID: G?bor Farkas wrote: >i am trying to print out all my photo's names, together with their keywords. >[...] >this code works, but it's TERRIBLY slow :) > >the problem is the parsePhoto function... >those keyword.name(), photo.name(), photo.keywords() calls take nearly a >second to complete... That sounds really awful, though I don't have a scriptable copy of iPhoto to confirm it myself. (Smoked my copy of iPhoto 2.0 in the last reinstall and am too cheap to buy iLife, so am back on v1 now.) Quite possible though - I seem to recall reading complaints in the past about its GUI bogging down on large numbers of images, so may be more of the same problem. >is there a better way to do this? >perharps get the data about multiple photos at the same time? Always a good idea to do that if you can. At the moment you're sending about the most commands you can. You could certainly reduce that a bit; perhaps right down to just two with a bit of luck: one to get all the photo names, and one to get all the keyword names for every photo. Not sure how well iPhoto can resolve more complex queries, but here's the code to try: p = app('iPhoto') print zip(p.photos.name(), p.photos.keywords.name()) If that doesn't work, let me know and I'll suggest ways to unroll it a bit. BTW, the next release of appscript (whenever that is) will include a chapter on optimising code for efficiency; I just haven't gotten around to finishing it yet. FWIW, I've temporarily posted some of the notes here: http://freespace.virgin.net/hamish.sanderson/appscript_efficiency_example.txt HTH has -- http://freespace.virgin.net/hamish.sanderson/ From lanceboyle at bluebottle.com Fri Dec 2 10:12:11 2005 From: lanceboyle at bluebottle.com (lanceboyle@bluebottle.com) Date: Fri, 2 Dec 2005 02:12:11 -0700 Subject: [Pythonmac-SIG] Fwd: Preferred IDE In-Reply-To: <438EF8A3.6090905@gmail.com> References: <0F2BBC0D-0DD4-4773-9036-A0E0196640B4@strozllc.com> <438C8C95.3080208@noaa.gov> <196B3DE4-C416-408E-84AB-F51FCFB2A2DC@bluebottle.com> <438EF8A3.6090905@gmail.com> Message-ID: <57E4CE6C-F87B-4A00-90AC-FB7778A1CFD8@bluebottle.com> On Dec 1, 2005, at 6:20 AM, altern wrote: > pyoxide you can open a console with python from within the editor > and this is very handy to try things out > Yes, indeed. But isn't PyOxide still really crashy? I have 0.7.1 and haven't used it in quite a while. Jerry From Andrew.J.Kennedy at ge.com Thu Dec 1 21:45:10 2005 From: Andrew.J.Kennedy at ge.com (Kennedy, Andrew (GE Healthcare)) Date: Thu, 1 Dec 2005 14:45:10 -0600 Subject: [Pythonmac-SIG] problem trying to use aemreceive with Tkinter app Message-ID: Hi folks, I'm trying to use aemreceive to process AppleEvents in a Tkinter-GUI'd Python app. I have been able to use argvemulator.py from plat-mac to handle double clicking on a file and having it open in the application automatically. I'm now trying to catch 'ocon' and 'odoc' AppleEvents within the application to handle dragging files onto the icon and double clicking on files while the application is running. I can add the event handler per the code below: if sys.platform == 'darwin': import aemreceive aemreceive.installeventhandler(AEOpenFile, 'aevtodoc', ('----','AliasList', aemreceive.ArgListOf(aemreceive.kAE.typeAlias))) What am I missing? Do I need to modify my main loop to handle the events? I never seem to get into the event handler code this way, so there must be something else at work here. Is my event handler at the wrong level of the stack? The crash log is included after my signature. Any assistance anyone can offer would be greatly appreciated. Thanks in advance, Andrew Andrew Kennedy Applications Developer Preclinical Imaging GE Healthcare P +1 519 474 5190 F +1 519 472 9492 E Andrew.Kennedy at med.ge.com http://www.gehealthcare.com/ Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000008 Thread 0 Crashed: 0 org.python.python 0x10022408 PyFrame_New + 0x20 (frameobject.c:540) 1 org.python.python 0x100734a8 PyEval_EvalCodeEx + 0x88 (ceval.c:2456) 2 org.python.python 0x10024e74 function_call + 0x158 (funcobject.c:504) 3 org.python.python 0x1000c134 PyObject_Call + 0x30 (abstract.c:1756) 4 org.python.python 0x10074ca4 PyEval_CallObjectWithKeywords + 0x100 (ceval.c:3347) 5 _AE.so 0x0f2e9a30 GenericEventHandler + 0x154 (_AEmodule.c:1587) 6 com.apple.AE 0x98fa8a10 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 0xd0 7 com.apple.AE 0x98fab858 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 0x2c 8 com.apple.AE 0x98fa8c50 aeProcessAppleEvent + 0x11c 9 com.apple.HIToolbox 0x92975224 AEProcessAppleEvent + 0x3c 10 com.tcltk.tklibrary 0x0b07dcac TkMacOSXDoHLEvent + 0x10 11 com.tcltk.tklibrary 0x0b07bb3c TkMacOSXProcessAppleEvent + 0x3c 12 com.tcltk.tklibrary 0x0b07bc80 TkMacOSXProcessEvent + 0xb0 13 com.tcltk.tklibrary 0x0b07bd14 ReceiveAndProcessEvent + 0x74 14 com.tcltk.tklibrary 0x0b07bad8 TkMacOSXCountAndProcessMacEvents + 0x30 15 com.tcltk.tklibrary 0x0b0870c0 TkMacOSXWaitForEvent + 0x250 16 com.tcltk.tcllibrary 0x0a078370 Tcl_WaitForEvent + 0x64 17 com.tcltk.tcllibrary 0x0a0565f8 Tcl_DoOneEvent + 0x128 18 _tkinter.so 0x002872c0 Tkapp_MainLoop + 0x150 (_tkinter.c:2530) 19 org.python.python 0x10074e18 call_function + 0x130 (ceval.c:3440) 20 org.python.python 0x10072a54 eval_frame + 0x2568 (ceval.c:2116) 21 org.python.python 0x10073d04 PyEval_EvalCodeEx + 0x8e4 (ceval.c:2663) 22 org.python.python 0x100750f8 fast_function + 0x164 (ceval.c:3533) 23 org.python.python 0x10074ef0 call_function + 0x208 (ceval.c:3458) 24 org.python.python 0x10072a54 eval_frame + 0x2568 (ceval.c:2116) 25 org.python.python 0x10075068 fast_function + 0xd4 (ceval.c:3520) 26 org.python.python 0x10074ef0 call_function + 0x208 (ceval.c:3458) 27 org.python.python 0x10072a54 eval_frame + 0x2568 (ceval.c:2116) 28 org.python.python 0x10073d04 PyEval_EvalCodeEx + 0x8e4 (ceval.c:2663) 29 org.python.python 0x10076b64 PyEval_EvalCode + 0x30 (ceval.c:537) 30 org.python.python 0x100a8258 run_node + 0x4c (pythonrun.c:1265) 31 org.python.python 0x100a7a2c PyRun_SimpleFileExFlags + 0x250 (pythonrun.c:865) 32 org.python.python 0x100b41e0 Py_Main + 0x858 (main.c:415) 33 MicroView 0x00001b10 0x1000 + 0xb10 34 dyld 0x8fe1a278 _dyld_start + 0x64 Thread 1: 0 libSystem.B.dylib 0x9494746c select + 0xc 1 com.tcltk.tklibrary 0x0b087290 NotifierThreadProc + 0x1b0 2 libSystem.B.dylib 0x94960990 _pthread_body + 0x28 PPC Thread State: srr0: 0x10022408 srr1: 0x0200f030 vrsave: 0x00000000 cr: 0x42822228 xer: 0x20000004 lr: 0x100734a8 ctr: 0x100223e8 r0: 0x100734a8 r1: 0xbfffe770 r2: 0x10024e74 r3: 0x00000000 r4: 0x0f4b90a0 r5: 0x0f4ae4b0 r6: 0x00000000 r7: 0x00000002 r8: 0x42822228 r9: 0x100734a8 r10: 0x00000000 r11: 0x1010eda0 r12: 0x100223e8 r13: 0x00000000 r14: 0x00000000 r15: 0x0f302ec4 r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x0028717c r20: 0x00000000 r21: 0x00000000 r22: 0x00000002 r23: 0x00000000 r24: 0x00000000 r25: 0x0f4b90a0 r26: 0x00000000 r27: 0x00000000 r28: 0x11aeb62c r29: 0x0f4b90a0 r30: 0x00000000 r31: 0x10073428 From altern2 at gmail.com Fri Dec 2 10:35:01 2005 From: altern2 at gmail.com (altern) Date: Fri, 02 Dec 2005 10:35:01 +0100 Subject: [Pythonmac-SIG] Fwd: Preferred IDE In-Reply-To: <57E4CE6C-F87B-4A00-90AC-FB7778A1CFD8@bluebottle.com> References: <0F2BBC0D-0DD4-4773-9036-A0E0196640B4@strozllc.com> <438C8C95.3080208@noaa.gov> <196B3DE4-C416-408E-84AB-F51FCFB2A2DC@bluebottle.com> <438EF8A3.6090905@gmail.com> <57E4CE6C-F87B-4A00-90AC-FB7778A1CFD8@bluebottle.com> Message-ID: <43901545.6030509@gmail.com> lanceboyle at bluebottle.com(e)k dio: > On Dec 1, 2005, at 6:20 AM, altern wrote: > > > >>pyoxide you can open a console with python from within the editor >>and this is very handy to try things out >> > > > Yes, indeed. But isn't PyOxide still really crashy? I have 0.7.1 and > haven't used it in quite a while. > Jerry it works ok for me. The only problem is that if you double click a python file pyOxide launches and closes down in a couple of secs, you can see the icon opning and closing in the dock, but you just open pyOxide and later once is opened you can double click on the python files and they get opened in pyoxide without it crashing. Or this is the way i go about it at least, there might be some other solution. From Laurent.Pierron at loria.fr Fri Dec 2 12:07:33 2005 From: Laurent.Pierron at loria.fr (Laurent Pierron) Date: Fri, 2 Dec 2005 12:07:33 +0100 Subject: [Pythonmac-SIG] Fwd: Preferred IDE In-Reply-To: <196B3DE4-C416-408E-84AB-F51FCFB2A2DC@bluebottle.com> References: <0F2BBC0D-0DD4-4773-9036-A0E0196640B4@strozllc.com> <438C8C95.3080208@noaa.gov> <196B3DE4-C416-408E-84AB-F51FCFB2A2DC@bluebottle.com> Message-ID: <88637b9a572153fb06d45ac6b41d5488@loria.fr> Le 1 d?c. 05, ? 04:09, lanceboyle at bluebottle.com a ?crit : > Smultron looks quite nice, but I don't see a way to submit files for > execution, or to get console output back. Does it require switching > to Terminal or the like, or am I missing something? > Smultron is Apple Scriptable, so you can use an AppleScript to call Python from Smultron get back the ouptut and send it back to Smultron. You can put your special scripts for Smultron in ~/Library/Scripts/Applications/Smultron For more information see : http://www.apple.com/applescript/scriptmenu/ -- Laurent PIERRON From Benjamin.Schollnick at xerox.com Fri Dec 2 16:10:42 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Fri, 2 Dec 2005 10:10:42 -0500 Subject: [Pythonmac-SIG] Database (SQL prefered) access on MacPython Message-ID: <266589E1B9392B4C9195CC25A07C73B90183D1B1@usa0300ms04.na.xerox.net> Folks, On the PC side, I use an ODBC connection.... But I'm considering writing an Database application on the Macintosh via Python... I asked earlier and ODBC seems to be mostly out on the MacPython front. What methods do you folks use for accessing an database (SQL based database prefered) via macpython? - Benjamin From Henning.Ramm at mediapro-gmbh.de Fri Dec 2 16:18:06 2005 From: Henning.Ramm at mediapro-gmbh.de (Henning.Ramm@mediapro-gmbh.de) Date: Fri, 2 Dec 2005 16:18:06 +0100 Subject: [Pythonmac-SIG] Database (SQL prefered) access on MacPython Message-ID: >I asked earlier and ODBC seems to be mostly out on the MacPython >front. What methods do you folks use for accessing an database >(SQL based database prefered) via macpython? Python's Db API, of course. http://www.python.org/peps/pep-0249.html There are a lot of databases out there, and there's a Python driver for most of them. http://www.python.org/topics/database/ I guess you'll find most help for MySQL, even if PostgreSQL or something is better. If you don't need a db server, perhaps try SQLite. Greetlings, HR From skip at pobox.com Fri Dec 2 18:16:54 2005 From: skip at pobox.com (skip@pobox.com) Date: Fri, 2 Dec 2005 11:16:54 -0600 Subject: [Pythonmac-SIG] Database (SQL prefered) access on MacPython In-Reply-To: <266589E1B9392B4C9195CC25A07C73B90183D1B1@usa0300ms04.na.xerox.net> References: <266589E1B9392B4C9195CC25A07C73B90183D1B1@usa0300ms04.na.xerox.net> Message-ID: <17296.33158.87785.216449@montanaro.dyndns.org> Benjamin> I asked earlier and ODBC seems to be mostly out on the Benjamin> MacPython front. What methods do you folks use for accessing Benjamin> an database (SQL based database prefered) via macpython? I've used both PostgreSQL and MySQL from Python on Mac OSX with no problems. Another guy here at work has used Sybase on his Mac (built the Object Craft module against the FreeTDS stuff). Pick your poison. -- Skip Montanaro Katrina Benefit Concerts: http://www.musi-cal.com/katrina skip at pobox.com From Benjamin.Schollnick at xerox.com Fri Dec 2 18:43:08 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Fri, 2 Dec 2005 12:43:08 -0500 Subject: [Pythonmac-SIG] Database (SQL prefered) access on MacPython Message-ID: <266589E1B9392B4C9195CC25A07C73B90183D1B7@usa0300ms04.na.xerox.net> > Python's Db API, of course. http://www.python.org/peps/pep-0249.html > > There are a lot of databases out there, and there's a Python > driver for most of them. http://www.python.org/topics/database/ > I guess you'll find most help for MySQL, even if PostgreSQL > or something is better. If you don't need a db server, > perhaps try SQLite. When the heck did that come out? It's a nice step forward to standarding the Database modules that exist... I'll have to explore that more further... - Ben From bob at redivi.com Fri Dec 2 19:27:53 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 2 Dec 2005 10:27:53 -0800 Subject: [Pythonmac-SIG] Database (SQL prefered) access on MacPython In-Reply-To: <266589E1B9392B4C9195CC25A07C73B90183D1B7@usa0300ms04.na.xerox.net> References: <266589E1B9392B4C9195CC25A07C73B90183D1B7@usa0300ms04.na.xerox.net> Message-ID: <933D15B0-8A6C-4FAD-BD3E-25A04CCEA2CE@redivi.com> On Dec 2, 2005, at 9:43 AM, Schollnick, Benjamin wrote: >> Python's Db API, of course. http://www.python.org/peps/pep-0249.html >> >> There are a lot of databases out there, and there's a Python >> driver for most of them. http://www.python.org/topics/database/ >> I guess you'll find most help for MySQL, even if PostgreSQL >> or something is better. If you don't need a db server, >> perhaps try SQLite. > > When the heck did that come out? > > It's a nice step forward to standarding the Database modules that > exist... DB API 2.0 has been around for over 6 years (Apr 1999) and its predecessor is from 1996... Every Python SQL database extension I've ever used has implemented it, except for the one or two that were explicitly designed not to implement it (e.g. to go way into db-specific land, or to implement asynchronous queries). mxODBC is a DB-API 2.0 compliant extension for ODBC databases that works on OS X, but it requires a license for commercial use. I'd also consider using something like SQLObject to abstract things a bit if I wasn't doing something that needed lots of performance tuning or DB specific enhancements. -bob From njriley at uiuc.edu Fri Dec 2 19:34:24 2005 From: njriley at uiuc.edu (Nicholas Riley) Date: Fri, 2 Dec 2005 12:34:24 -0600 Subject: [Pythonmac-SIG] problem trying to use aemreceive with Tkinter app In-Reply-To: References: Message-ID: <20051202183424.GA99405@uiuc.edu> On Thu, Dec 01, 2005 at 02:45:10PM -0600, Kennedy, Andrew (GE Healthcare) wrote: > I'm trying to use aemreceive to process AppleEvents in a > Tkinter-GUI'd Python app. I have been able to use argvemulator.py > from plat-mac to handle double clicking on a file and having it open > in the application automatically. I'm now trying to catch 'ocon' > and 'odoc' AppleEvents within the application to handle dragging > files onto the icon and double clicking on files while the > application is running. > > I can add the event handler per the code below: > > if sys.platform == 'darwin': > import aemreceive > aemreceive.installeventhandler(AEOpenFile, 'aevtodoc', > ('----','AliasList', aemreceive.ArgListOf(aemreceive.kAE.typeAlias))) > > What am I missing? Do I need to modify my main loop to handle the > events? I never seem to get into the event handler code this way, > so there must be something else at work here. Is my event handler > at the wrong level of the stack? > > The crash log is included after my signature. Any assistance anyone > can offer would be greatly appreciated. It's trying to execute your event handler; it looks like the Python thread state (PyThreadState) passed to PyFrame_New is null. I imagine this happens because the Python code is being dispatched when it doesn't expect to be running Python code at all. There might be a way to wrap your event handler but I'm not familiar enough with the internals of aemreceive to say how. The only Python AE receive stuff I've done has been using aemreceive.sfba. I was able to use aemreceive.sfba.starteventloop() for that. It seems from the stack trace that Tk still removes and dispatches an event at a time, so it doesn't play well with other event consumers. Maybe you can run your own event loop and dispatch events to Tk yourself? Or you could try using Tk's event handler instead. You can try evaluating a definition of ::tk::mac::OpenDocument, which according to the TkAqua FAQ should be called on an aevt/odoc event. -- Nicholas Riley | From piet at cs.uu.nl Sat Dec 3 14:23:23 2005 From: piet at cs.uu.nl (Piet van Oostrum) Date: Sat, 03 Dec 2005 14:23:23 +0100 Subject: [Pythonmac-SIG] Database (SQL prefered) access on MacPython In-Reply-To: <17296.33158.87785.216449@montanaro.dyndns.org> References: <266589E1B9392B4C9195CC25A07C73B90183D1B1@usa0300ms04.na.xerox.net> <17296.33158.87785.216449@montanaro.dyndns.org> Message-ID: >>>>> skip at pobox.com (SM) wrote: >Benjamin> I asked earlier and ODBC seems to be mostly out on the >Benjamin> MacPython front. What methods do you folks use for accessing >Benjamin> an database (SQL based database prefered) via macpython? >SM> I've used both PostgreSQL and MySQL from Python on Mac OSX with no >SM> problems. Another guy here at work has used Sybase on his Mac (built >SM> the Object Craft module against the FreeTDS stuff). Pick your poison. Firebird also works with Python. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: piet at vanoostrum.org From srmoon at andrew.cmu.edu Fri Dec 2 20:42:53 2005 From: srmoon at andrew.cmu.edu (Shaun Richard Moon) Date: Fri, 2 Dec 2005 14:42:53 -0500 (EST) Subject: [Pythonmac-SIG] Python QT module, etc. Message-ID: <49700.128.237.247.136.1133552573.squirrel@128.237.247.136> Hey all, i saw that there was some chatter here about caputring an image from a webcam back in April did anybody have any luck? I'm very new and basically I've seen a couple of different possibilities in Cocoa.Qt, Jack Jansen's QuickTime module (don't know how to get that one) and PyQTSequence (so far *import PyQTSequence" or "PyQT" doesn't work). For all I can tell, these seem potentially workable but I don't know how. Any suggestions? Any help would be very highly appreciated. shaun From Louis.Wicker at noaa.gov Tue Dec 6 04:51:10 2005 From: Louis.Wicker at noaa.gov (Louis Wicker) Date: Mon, 5 Dec 2005 21:51:10 -0600 Subject: [Pythonmac-SIG] F2PY, F90, and Mac os x Tiger: linking problem Message-ID: <5D930238-2984-425A-BDB2-EC105E6CE63C@noaa.gov> All: Back in April I upgraded to Tiger, and I should have known better. I cannot get any f90/5 programs to link with f2py (except that I have not tried the g95/gfortran compilers). This problem started when I "upgraded" to Tiger from 10.3.9. I thought I would ask over to here to see if anyone has any ideas. I get the same linking problem using the XLF, Absoft 9.2, and even the NAG compiler. I can get g77 programs to compile and link correctly. Here is the linking problem...it occurs at the end of the f2py process (see full output below). /usr/bin/ld: /usr/lib/crt1.o has external relocation entries in non- writable section (__TEXT,__text) for symbols: __mh_execute_header This external relocation problem exists for all of the above named compilers. I am using gcc 3.3. My online research and my simple brain has figured out this is something to do with the gcc libs, and the fact that something changed with 10.4. The NAG README hints that something is weird with Tiger and that they are temporarily supporting a "-unshared" flag - which I think allows me to link statically somehow to a dynamic library. I can successfully link using that flag, but the fortran module is dead when I import it into python (it imports, but nothing happens when I try to access it). This occurs with Python 2.3.5 and 2.4.1. I cannot find anything anywhere on how to deal with this. I have tried tricky other things, like compiling with f90 and linking with g77 or gcc, but I get other types of errors. Any thoughts would be appreciated, as this is irritating the hell out of me (for the third time this year). Lou ======= Full output ==== f2py --fcompiler=ibm -c -m hello hello.f numpy_info: FOUND: define_macros = [('NUMERIC_VERSION', '"\\"24.0b2\\""')] include_dirs = ['/System/Library/Frameworks/Python.framework/ Versions/2.3/include/python2.3'] running build running config_fc running build_src building extension "hello" sources f2py:> /tmp/tmpEAl_LK/src/hellomodule.c creating /tmp/tmpEAl_LK creating /tmp/tmpEAl_LK/src Reading fortran codes... Reading file 'hello.f' Post-processing... Block: hello Block: foo Post-processing (stage 2)... Building modules... Building module "hello"... Constructing wrapper function "foo"... foo(a) Wrote C/API module "hello" to file "/tmp/tmpEAl_LK/src/ hellomodule.c" adding '/tmp/tmpEAl_LK/src/fortranobject.c' to sources. adding '/tmp/tmpEAl_LK/src' to include_dirs. copying /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ python2.3/site-packages/f2py2e/src/fortranobject.c -> /tmp/tmpEAl_LK/src copying /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ python2.3/site-packages/f2py2e/src/fortranobject.h -> /tmp/tmpEAl_LK/src running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext customize IbmFCompiler customize IbmFCompiler using build_ext building 'hello' extension compiling C sources gcc options: '-fno-strict-aliasing -Wno-long-double -no-cpp-precomp - mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict- prototypes' creating /tmp/tmpEAl_LK/tmp creating /tmp/tmpEAl_LK/tmp/tmpEAl_LK creating /tmp/tmpEAl_LK/tmp/tmpEAl_LK/src compile options: '-I/System/Library/Frameworks/Python.framework/ Versions/2.3/include/python2.3 -I/tmp/tmpEAl_LK/src -I/System/Library/ Frameworks/Python.framework/Versions/2.3/include/python2.3 -c' gcc: /tmp/tmpEAl_LK/src/fortranobject.c /tmp/tmpEAl_LK/src/fortranobject.c: In function `fortran_doc': /tmp/tmpEAl_LK/src/fortranobject.c:123: warning: int format, long unsigned int arg (arg 3) gcc: /tmp/tmpEAl_LK/src/hellomodule.c compiling Fortran sources xlf(f77) options: '-qextname -O5' xlf90(f90) options: '-qextname -O5' xlf90(fix) options: '-qfixed -qextname -O5' compile options: '-I/System/Library/Frameworks/Python.framework/ Versions/2.3/include/python2.3 -I/tmp/tmpEAl_LK/src -I/System/Library/ Frameworks/Python.framework/Versions/2.3/include/python2.3 -c' xlf:f77: hello.f ** foo === End of Compilation 1 === 1501-510 Compilation successful for file hello.f. xlf95 -Wl,-bundle,-flat_namespace,-undefined,suppress /tmp/tmpEAl_LK/ tmp/tmpEAl_LK/src/hellomodule.o /tmp/tmpEAl_LK/tmp/tmpEAl_LK/src/ fortranobject.o /tmp/tmpEAl_LK/hello.o -o ./hello.so /usr/bin/ld: /usr/lib/gcrt1.o has external relocation entries in non- writable section (__TEXT,__text) for symbols: __mh_execute_header /usr/bin/ld: /usr/lib/gcrt1.o has external relocation entries in non- writable section (__TEXT,__text) for symbols: __mh_execute_header error: Command "xlf95 -Wl,-bundle,-flat_namespace,- undefined,suppress /tmp/tmpEAl_LK/tmp/tmpEAl_LK/src/hellomodule.o / tmp/tmpEAl_LK/tmp/tmpEAl_LK/src/fortranobject.o /tmp/tmpEAl_LK/ hello.o -o ./hello.so" failed with exit status 1 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051205/2bf2c67d/attachment.html From bob at redivi.com Tue Dec 6 11:46:09 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 6 Dec 2005 02:46:09 -0800 Subject: [Pythonmac-SIG] F2PY, F90, and Mac os x Tiger: linking problem In-Reply-To: <5D930238-2984-425A-BDB2-EC105E6CE63C@noaa.gov> References: <5D930238-2984-425A-BDB2-EC105E6CE63C@noaa.gov> Message-ID: <820EBC76-AE5D-40D2-9A84-DBE200C5FD95@redivi.com> On Dec 5, 2005, at 7:51 PM, Louis Wicker wrote: > Back in April I upgraded to Tiger, and I should have known better. > > I cannot get any f90/5 programs to link with f2py (except that I > have not tried the g95/gfortran compilers). > > This problem started when I "upgraded" to Tiger from 10.3.9. I didn't thoroughly read through your post, but the most likely scenario is that you didn't also upgrade to the latest Xcode. -bob From pecora at anvil.nrl.navy.mil Tue Dec 6 18:07:26 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 12:07:26 -0500 Subject: [Pythonmac-SIG] Speed up Python on the Mac? Message-ID: <4395C54E.10902@anvil.nrl.navy.mil> I am seeking opinions on the best approaches to speed up Python on my Mac (OS X 10.3.9). I know about the profiling and find the bottlenecks approach, but then the choices of what to do are not clear. I have in the past written a few C modules and turned them into importable Python modules, but that was really time consuming and frustrating. I see there are many other approaches (SWIG, Pyrex, Psyco -- some may not be available on the Mac), so I thought I would start here to ask what people in this email list use and recommend. I am looking for something that is an all-in-one package (if possible), easy to use (if possible), and reliable (a must). Does such exist for OS X? I do number crunching/scientific programming using BBEdit and the Apple supplied Python. I do not need to squeeze every last CPU cycle out of my Mac, just get a good speedup ratio (roughly 5X or better). Thanks for any advice. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From bray at sent.com Tue Dec 6 18:23:54 2005 From: bray at sent.com (Brian Ray) Date: Tue, 6 Dec 2005 11:23:54 -0600 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395C54E.10902@anvil.nrl.navy.mil> References: <4395C54E.10902@anvil.nrl.navy.mil> Message-ID: <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> On Dec 6, 2005, at 11:07 AM, Louis Pecora wrote: > I see there are many other approaches (SWIG, Pyrex, Psyco -- some may > not be available on the Mac), so I thought I would start here to ask > what people in this email list use and recommend. Rewriting as "C" extensions is a good approach. But as you already said, it may be time consuming. Maybe break the program in small chunks to see where the bottle neck really exists. If your looking for the culprit, I would recommend taking a look at hotshot . Although it's part of the standard modules, some people do not realize it exists. I found this and other performance tips on Skip's site . Regardless, sounds like you already know the culprit. Although this will not help you know, I have been told, Pycho will run on the Intel Chip. hth, Brian Ray http://brianray.chipy.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051206/1cab5208/attachment.htm From pecora at anvil.nrl.navy.mil Tue Dec 6 18:39:10 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 12:39:10 -0500 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> Message-ID: <4395CCBE.8090500@anvil.nrl.navy.mil> Brian Ray wrote: > Rewriting as "C" extensions is a good approach. But as you already > said, it may be time consuming. Maybe break the program in small > chunks to see where the bottle neck really exists. If your looking for > the culprit, I would recommend taking a look at hotshot > . > > Although it's part of the standard modules, some people do not realize > it exists. I found this and other performance tips on Skip's site > >. > > Regardless, sounds like you already know the culprit. > > Although this will not help you know, I have been told, Pycho > will run on the Intel Chip. > > hth, Brian Ray > http://brianray.chipy.org Thanks for the tips, Brian. Wish I had that Intel Chip Mac Powerbook now. :-) -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From bray at sent.com Tue Dec 6 18:59:35 2005 From: bray at sent.com (Brian Ray) Date: Tue, 6 Dec 2005 11:59:35 -0600 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395CCBE.8090500@anvil.nrl.navy.mil> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> <4395CCBE.8090500@anvil.nrl.navy.mil> Message-ID: <95D38C43-BAF9-4533-BECF-F6247969598C@sent.com> On Dec 6, 2005, at 11:39 AM, Louis Pecora wrote: > > Thanks for the tips, Brian. Wish I had that Intel Chip Mac Powerbook > now. :-) BTW, I think you get a loner from Apple if your a transition developer. I have seen one although, I do not know the details. http://brianray.chipy.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051206/4808cd9f/attachment.htm From dangoor at gmail.com Tue Dec 6 19:01:40 2005 From: dangoor at gmail.com (Kevin Dangoor) Date: Tue, 6 Dec 2005 13:01:40 -0500 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> Message-ID: <3f085ecd0512061001g13e17cacp2de5d9cc6edef7e8@mail.gmail.com> > On Dec 6, 2005, at 11:07 AM, Louis Pecora wrote: > > > I see there are many other approaches (SWIG, Pyrex, Psyco -- some may > > not be available on the Mac), so I thought I would start here to ask > > what people in this email list use and recommend. Earlier in the year, Phillip Eby was optimizing his RuleDispatch package. There were many tweaks he was able to do *completely in Python* that resulted in a decent speedup. Here's one of his posting on the topic: http://dirtsimple.org/2005/02/optimization-surprises.html Pyrex works on the Mac: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ Kevin From pecora at anvil.nrl.navy.mil Tue Dec 6 19:03:48 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 13:03:48 -0500 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <3f085ecd0512061001g13e17cacp2de5d9cc6edef7e8@mail.gmail.com> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> <3f085ecd0512061001g13e17cacp2de5d9cc6edef7e8@mail.gmail.com> Message-ID: <4395D284.8090001@anvil.nrl.navy.mil> Kevin Dangoor wrote: > Earlier in the year, Phillip Eby was optimizing his RuleDispatch > >package. There were many tweaks he was able to do *completely in >Python* that resulted in a decent speedup. Here's one of his posting >on the topic: > >http://dirtsimple.org/2005/02/optimization-surprises.html > >Pyrex works on the Mac: >http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ > >Kevin > Thanks, Kevin. Any experience with Pyrex or any other speedup approach? -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From Chris.Barker at noaa.gov Tue Dec 6 19:08:26 2005 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Tue, 06 Dec 2005 10:08:26 -0800 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395CCBE.8090500@anvil.nrl.navy.mil> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> <4395CCBE.8090500@anvil.nrl.navy.mil> Message-ID: <4395D39A.9020400@noaa.gov> Louis Pecora wrote: >>Although this will not help you know, I have been told, Pycho >> will run on the Intel Chip. > Thanks for the tips, Brian. Wish I had that Intel Chip Mac Powerbook > now. :-) Even so, Psyco doesn't understand NumPy arrays, which I hope you're already using. Essentially, you are right that you need to write some of your code in C, and that it's quite tedious to do it be hand. There are a number of tools that make it easier however. Here's my assessment, but I haven't actually used all of these: SWIG -- Automatically creates wrapper for existing C/C++ code. A good choice if you are working with a n existing library, particularly if that library is under development (i.e. wxPython) f2py -- similar to SWIG, but for Fortran code. Understands NumPy arrays. A good option if you have Fortran code you want to use, or like writing Fortran SIP: similar to SWIG, used for PyQT, that's all I know. Boost::Python -- C++ wrappers for the basic Python data types, handles reference counting etc. for you. I think there are some wrappers for NumPy arrays as well. A good choice if you want to write custom extension code in C++ Pyrex -- A python-like language for writing C extensions. It makes it very easy to write what is essentially a mixture of Python and C, with Python syntax. Easy to call C functions. Probably the easiest way to write custom extensions. Can work with NumPy arrays, but only at the C level -- working with a pointer to the data. Psyco -- automatically translates pieces of your runtime code into machine language. Understands standard python data types, including the array.array type. Does not know about NumPy arrays (darn!). Can make major speed improvements for numeric code, but only if you use array.array or regular old lists and tuples. It's extremely easy to use, so why not try it on your code? Only available for x86 processors. Weave.Blitz -- From the SciPy project. Automatically, and on the fly, translates and compiles individual NumPy expressions into C++ using the Blitz++ library. Probably the easiest way to speed up small sections of code. Cxx -- kind of like Boost::Python. Is it still being maintained? Have I got them all? I hope this helps. Make sure to check out the SciPy docs, there is discussion of optimizing numerical code in various places there. -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 Chris.Barker at noaa.gov From njriley at uiuc.edu Tue Dec 6 19:14:43 2005 From: njriley at uiuc.edu (Nicholas Riley) Date: Tue, 6 Dec 2005 12:14:43 -0600 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395C54E.10902@anvil.nrl.navy.mil> References: <4395C54E.10902@anvil.nrl.navy.mil> Message-ID: <20051206181443.GA84479@uiuc.edu> On Tue, Dec 06, 2005 at 12:07:26PM -0500, Louis Pecora wrote: > I am seeking opinions on the best approaches to speed up Python on my > Mac (OS X 10.3.9). > > I know about the profiling and find the bottlenecks approach, but then > the choices of what to do are not clear. I have in the past written a > few C modules and turned them into importable Python modules, but that > was really time consuming and frustrating. Perhaps you can describe some of the bottlenecks you're experiencing, or post some code fragments? The lsprof profiler has worked for me: > I see there are many other approaches (SWIG, Pyrex, Psyco -- some may > not be available on the Mac), so I thought I would start here to ask > what people in this email list use and recommend. Psyco for the most part does not work on non-Intel processors. PyPy static translation does work if you write in RPython, but debugging translation failures is time-consuming and not particularly easy. If you have any free x86 boxes, you might do what I do - write on the Mac and run somewhere else faster, perhaps with Psyco. That also has the benefit of keeping your Mac free for interactive use. -- Nicholas Riley | From pecora at anvil.nrl.navy.mil Tue Dec 6 19:29:34 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 13:29:34 -0500 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <20051206181443.GA84479@uiuc.edu> References: <4395C54E.10902@anvil.nrl.navy.mil> <20051206181443.GA84479@uiuc.edu> Message-ID: <4395D88E.1060105@anvil.nrl.navy.mil> Nicholas Riley wrote: > Perhaps you can describe some of the bottlenecks you're experiencing, > >or post some code fragments? The lsprof profiler has worked for me: > > > > Thanks for the pointer, Nick. I have no particular example right now. I have been using Python for a few years to knock off quicky, what-if calculations. RAD number crunching. Most of my bigger programs are in C++, but I think I would do better spending my time in Python with only "special programming" for my heavy CPU code portions. Many of my programs are menu driven (not GUI, but just simple I/O on what to do next as the app is running). That's slow in C++ (even though I have a style down for it). Much faster in Python. Most scientific code is never done. You're always trying what-if stuff. Python is perfect for that. I just need to get the speed when the crunching comes up. If I could find that latter solution, I would switch my programming style over to Python in a hurry. >Psyco for the most part does not work on non-Intel processors. PyPy >static translation does work if you write in RPython, but debugging >translation failures is time-consuming and not particularly easy. > >If you have any free x86 boxes, you might do what I do - write on the >Mac and run somewhere else faster, perhaps with Psyco. That also has >the benefit of keeping your Mac free for interactive use. > > > Thanks. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From pecora at anvil.nrl.navy.mil Tue Dec 6 20:14:25 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 14:14:25 -0500 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395DF62.8050308@noaa.gov> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> <4395CCBE.8090500@anvil.nrl.navy.mil> <4395D39A.9020400@noaa.gov> <4395D6F4.1090208@anvil.nrl.navy.mil> <4395DF62.8050308@noaa.gov> Message-ID: <4395E311.2010900@anvil.nrl.navy.mil> Christopher Barker wrote: > Louis Pecora wrote: > >> Christopher Barker wrote: > > >> Yeow, Chris, you really have a lot to say about what I'm interested >> in. Thanks very much! > > > That's because I'm in the same boat. I keep bouncing back and forth > between the approaches, because it's hard to find one that does > everything well. At the moment, I think I'm going with SWIG. I found > some typemaps (what SWIG uses to translate for Python types to C > types) for Numeric arrays that I want to use. I use Numeric a lot. Where are those typemaps? Por favor. :-) > > I'm going with SWIG because I want to wrap a couple existing > libraries, and one that is under development now, and we need to use > from both C++ and Python. If it were just me, I'd dump C++ for primary > app development (like you're working on), and just write Python for > anything not computationally intensive. But it's not up to me, and > folks here are distrustful of anything "new". At NOAA? Isn't that a research place? Sheeze. You think they'd want you looking for new stuff. > > If I didn't need to use the same libs from C++ and Python, and was > more comfortable with C++ I'd probably give Boost::python a try. Or > Pyrex. It depends on whether you see yourself writing just the inner > loops in C, where pyrex would be an excellent choice, or writing a > full lib with classes and all that, where Boost::Python would probably > be a better option. I tried installing the Boost libraries and got hung up. That was for another project where I wanted to use someone elses code for n-ary search tress, but it required boost. Never did get it to work. > > I'd like to hear how things go for you. Particularly if you use SWIG, > we could probably help each other out. > Ya got a deal. I'm going to look hard at SWIG right now. Thanks. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From delza at livingcode.org Tue Dec 6 20:18:35 2005 From: delza at livingcode.org (Dethe Elza) Date: Tue, 6 Dec 2005 11:18:35 -0800 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395D39A.9020400@noaa.gov> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> <4395CCBE.8090500@anvil.nrl.navy.mil> <4395D39A.9020400@noaa.gov> Message-ID: On Tue 2005-12-06, at Tue 2005-12-06T10:08 AM, Christopher Barker wrote: [Great list snipped] > Have I got them all? I hope this helps. Ctypes allows you to call C code from Python without an extension, but is fairly hairy to write. One Mac-specific way is to expose the C code via Objective-C as a framework. Importing Objective-C frameworks is trivial using the PyObjC library. It would be great to have a real-world example to see what could be done purely from python (plus libraries) using some fo the speedup guidance mentioned (both Eby's and SciPy's). Maybe we should capture this on the wiki? --Dethe From konrad.hinsen at laposte.net Tue Dec 6 20:47:30 2005 From: konrad.hinsen at laposte.net (konrad.hinsen@laposte.net) Date: Tue, 6 Dec 2005 20:47:30 +0100 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395C54E.10902@anvil.nrl.navy.mil> References: <4395C54E.10902@anvil.nrl.navy.mil> Message-ID: On 06.12.2005, at 18:07, Louis Pecora wrote: > I know about the profiling and find the bottlenecks approach, but then > the choices of what to do are not clear. I have in the past written a > few C modules and turned them into importable Python modules, but that > was really time consuming and frustrating. > > I see there are many other approaches (SWIG, Pyrex, Psyco -- some may > not be available on the Mac), so I thought I would start here to ask > what people in this email list use and recommend. Pyrex will make the experience of moving from Python to C modules much more pleasant. You can start with a pure Python version and then migrate line by line to C written in near-Python syntax. It also takes care of all the boring bookkeeping, and it is portable - it works on the Mac and elsewhere. SWIG is of practical use only if you already have a C library that does the job you want to accelerate. And even then, it may be easier to write the interface in Pyrex. Psyco is for Intel architectures only. > I do number crunching/scientific programming using BBEdit and the > Apple > supplied Python. I do not need to squeeze every last CPU cycle out of > my Mac, just get a good speedup ratio (roughly 5X or better). I do number crunching as well, and found Pyrex the most useful tool once the possibilities of optimizing the Python code seemed exhausted. Konrad. From rowen at cesmail.net Tue Dec 6 20:42:25 2005 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 06 Dec 2005 11:42:25 -0800 Subject: [Pythonmac-SIG] Fwd: Preferred IDE References: <0F2BBC0D-0DD4-4773-9036-A0E0196640B4@strozllc.com> <438C8C95.3080208@noaa.gov> Message-ID: In article <438C8C95.3080208 at noaa.gov>, "Chris Barker" wrote: > Jeffrey E. Forcier wrote: > >> I also seem to remember BBEdit not having that > >>issue for some reason, but it wasn't worth the price tag for that > >>one tweak. > > >> TextWrangler/BBEdit is an *excellent* editor, so be sure to try it out > >> yourself > > Yes, it is, but it really doesn't do python indenting quite right. These > days, all python code really should be indented with 4 spaces, and while > you can set BBedit to put in 4 spaces when you hit the tab key, it > doesn't recognize those four spaces as a single level of indentation > when you want to delete them, requiring four hits of the backspace key. I personally use tabs (of width 4 spaces), but I guess they're not allowed in the python library. My main objection to TextWrangler/BBEdit is it's clumsy find/replace. There are too many mutually incompatible checkboxes for setting the mode (such as wrap or in selection), and those make it much too easy to get into a state where "replace all" only replaces from the cursor down (corrupting your file). And it's modal. Horrible. But otherwise they're pretty nice editors and TextWrangler is especially amazing considering it's free. My favorite python IDE is WingIDE. Nice editor (that I think does the "lets fake tabs with spaces" indentation that I so despise). It includes a nice debugger, is very robust and has some of the best support you'll ever see. Free for noncommercial use and quite affordable for other use. The editor has an emacs mode for emacs lovers. It's not perfect (I'd like nicer find/replace, better project management and svn integration), but it's very good and keeps getting better. > I'm still looking for a nice modern, platform independent, general > purpose, fully customizable (preferably in Python) text editor. SPE is > heading that way, and Pepper (http://digitalwandering.com/) still has > promise. Sounds useful. Good luck. Pepper is by my main text editor; unfortunately, development died on it years ago. Getting back to Mac editors, TextWrangler the other one I keep around. TextMate showed promise a year or two ago, but it had some really rough edges and I don't think it's coming along very quickly. -- Russell From pecora at anvil.nrl.navy.mil Tue Dec 6 20:57:53 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 14:57:53 -0500 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: References: <4395C54E.10902@anvil.nrl.navy.mil> Message-ID: <4395ED41.1020008@anvil.nrl.navy.mil> konrad.hinsen at laposte.net wrote: > Pyrex will make the experience of moving from Python to C modules > much more pleasant. You can start with a pure Python version and then > migrate line by line to C written in near-Python syntax. It also > takes care of all the boring bookkeeping, and it is portable - it > works on the Mac and elsewhere. > > SWIG is of practical use only if you already have a C library that > does the job you want to accelerate. And even then, it may be easier > to write the interface in Pyrex. I will want to do both. Use my current C++ libraries and write new C/C++ code. Interesting that Pyrex can do the interface. Thanks. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From pecora at anvil.nrl.navy.mil Tue Dec 6 22:21:15 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 16:21:15 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. Message-ID: <439600CB.8080008@anvil.nrl.navy.mil> I'm trying to install the SWIG The README says to treat Mac OS X like a Unix (makes sense) and do the following, % ./configure % make % make install ./configure seemed to run ok. No errors that I could see in the long print out. When I try the first make I get, louispec% make make all-am depbase=`echo CParse/cscanner.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \ if g++ -DHAVE_CONFIG_H -I../Source/Include -I../Source/CParse -I../Source/Include -I../Source/DOH -I../Source/CParse -I../Source/Preprocessor -I../Source/Swig -I../Source/Modules -g -O2 -Wall -W -ansi -pedantic -MT CParse/cscanner.o -MD -MP -MF "$depbase.Tpo" -c -o CParse/cscanner.o CParse/cscanner.c; \ then mv -f "$depbase.Tpo" "$depbase.Po"; else rm -f "$depbase.Tpo"; exit 1; fi In file included from CParse/cscanner.c:18: parser.y:1252: error: parse error before `throw' parser.y:1266: error: parse error before `throw' make[2]: *** [CParse/cscanner.o] Error 1 make[1]: *** [all] Error 2 make: *** [source] Error 2 Exit 2 This leaves me baffled. Anyone know what's wrong? I checked and the Mac uses the GNU make as required. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From bray at sent.com Tue Dec 6 23:05:57 2005 From: bray at sent.com (Brian Ray) Date: Tue, 6 Dec 2005 16:05:57 -0600 Subject: [Pythonmac-SIG] Converting to AppleEvents Message-ID: Hi All: I have an AppleScript I am calling with os.system(): with timeout of 3600 seconds tell application "MyApp" reload startup end tell end timeout I am interested in various methods to convert this to AppleEvents. Any sample codes of something similar? There seems to be more than one approach. Also, I do not mind keeping as an AppleScript in a triple quoted string, but I am onsure how this is done. I am trying to learn how to handle all my communication between Mach- O applications and Python2.3 with AppleEvents, although I do not know where to get started. Are there any tutorials on this topic? I do not want to use any helper modules because I also must stick with just Python2.3. Thanks in Advance. Brian Ray http://brianray.chipy.org From jforcier at strozllc.com Tue Dec 6 23:15:14 2005 From: jforcier at strozllc.com (Jeffrey E. Forcier) Date: Tue, 6 Dec 2005 17:15:14 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: <439600CB.8080008@anvil.nrl.navy.mil> References: <439600CB.8080008@anvil.nrl.navy.mil> Message-ID: <728743D8-12F7-4317-B204-627E7CBB258B@strozllc.com> Not having SWIG installed myself, I know that there's often issues with different versions of GCC on OS X...you might want to verify in the SWIG install docs (if they exist) and make sure your version of GCC doesn't have some odd incompatibility with the SWIG source. Only a guess, but still :) -Jeff On Dec 6, 2005, at 4:21 PM, Louis Pecora wrote: > I'm trying to install the SWIG > > The README says to treat Mac OS X like a Unix (makes sense) and do the > following, > > % ./configure > % make > % make install > > ./configure seemed to run ok. No errors that I could see in the long > print out. > > When I try the first make I get, > > louispec% make > make all-am > depbase=`echo CParse/cscanner.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \ > if g++ -DHAVE_CONFIG_H -I../Source/Include -I../Source/CParse > -I../Source/Include -I../Source/DOH -I../Source/CParse > -I../Source/Preprocessor -I../Source/Swig -I../Source/Modules -g -O2 > -Wall -W -ansi -pedantic -MT CParse/cscanner.o -MD -MP -MF > "$depbase.Tpo" -c -o CParse/cscanner.o CParse/cscanner.c; \ > then mv -f "$depbase.Tpo" "$depbase.Po"; else rm -f "$depbase.Tpo"; > exit > 1; fi > In file included from CParse/cscanner.c:18: > parser.y:1252: error: parse error before `throw' > parser.y:1266: error: parse error before `throw' > make[2]: *** [CParse/cscanner.o] Error 1 > make[1]: *** [all] Error 2 > make: *** [source] Error 2 > Exit 2 > > This leaves me baffled. Anyone know what's wrong? I checked and the > Mac uses the GNU make as required. > > -- > Cheers, > > Lou Pecora > > Code 6362 > Naval Research Lab > Washington, DC 20375 > USA > Ph: +202-767-6002 > email: pecora at anvil.nrl.navy.mil > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig -- Jeffrey E. Forcier Junior Developer, Research and Development Stroz Friedberg, LLC 15 Maiden Lane, 12th Floor New York, NY 10038 [main]212-981-6540 [direct]212-981-6546 http://www.strozllc.com This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail or by telephone at 212.981.6540, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. From pecora at anvil.nrl.navy.mil Tue Dec 6 23:40:00 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 17:40:00 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: References: <439600CB.8080008@anvil.nrl.navy.mil> Message-ID: <43961340.20504@anvil.nrl.navy.mil> Rob Managan wrote: > [cut] > > [mangrove:~/Documents/My_Downloads/swig-1.3.27] managan% make > make all-am > depbase=`echo CParse/cscanner.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \ > if gcc -DHAVE_CONFIG_H -I../Source/Include -I../Source/CParse > -I../Source/Include -I../Source/DOH -I../Source/CParse > -I../Source/Preprocessor -I../Source/Swig -I../Source/Modules -g -O2 > -Wall -W -ansi -pedantic -MT CParse/cscanner.o -MD -MP -MF > "$depbase.Tpo" -c -o CParse/cscanner.o CParse/cscanner.c; \ > then mv -f "$depbase.Tpo" "$depbase.Po"; else rm -f "$depbase.Tpo"; > exit 1; fi > depbase=`echo CParse/parser.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \ > if gcc -DHAVE_CONFIG_H -I../Source/Include -I../Source/CParse > -I../Source/Include -I../Source/DOH -I../Source/CParse > -I../Source/Preprocessor -I../Source/Swig -I../Source/Modules -g -O2 > -Wall -W -ansi -pedantic -MT CParse/parser.o -MD -MP -MF > "$depbase.Tpo" -c -o CParse/parser.o CParse/parser.c; \ > then mv -f "$depbase.Tpo" "$depbase.Po"; else rm -f "$depbase.Tpo"; > exit 1; fi > depbase=`echo CParse/templ.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \ > ... > > I notice that yours has "if g++ -D... " while mine uses gcc there. > Check configure output against mine and see if there are differences. > > I am running OSX 10.3.9 (Panther) so it may be a gcc 3.3 versus 3.4 > problem. > I am running 10.3.9, too. Thanks for giving me something (successful) to compare to. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From pecora at anvil.nrl.navy.mil Tue Dec 6 23:41:21 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 06 Dec 2005 17:41:21 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: References: <439600CB.8080008@anvil.nrl.navy.mil> Message-ID: <43961391.5070209@anvil.nrl.navy.mil> Rob Managan wrote: > PS the command to switch to gcc 3.3 seems to be > > 'sudo gcc_select 3.3' > > Not sure if you had to do this with scipy or not. Hmmmm... I don't know about this one. What has this to do with Scipy? -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From cookedm at physics.mcmaster.ca Wed Dec 7 05:59:15 2005 From: cookedm at physics.mcmaster.ca (David M. Cooke) Date: Tue, 6 Dec 2005 23:59:15 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: <43961391.5070209@anvil.nrl.navy.mil> References: <439600CB.8080008@anvil.nrl.navy.mil> <43961391.5070209@anvil.nrl.navy.mil> Message-ID: <20051207045915.GA17058@arbutus.physics.mcmaster.ca> On Tue, Dec 06, 2005 at 05:41:21PM -0500, Louis Pecora wrote: > Rob Managan wrote: > > > PS the command to switch to gcc 3.3 seems to be > > > > 'sudo gcc_select 3.3' > > > > Not sure if you had to do this with scipy or not. > > Hmmmm... I don't know about this one. What has this to do with Scipy? Experience has shown that compiling Scipy with gcc 4.0 on a Mac doesn't work (various really annoying problems with how Fortran libraries end up being linked and so on). So it's suggested that you use 3.3. -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |cookedm at physics.mcmaster.ca From ryanwilcox at mac.com Wed Dec 7 07:18:49 2005 From: ryanwilcox at mac.com (Ryan Wilcox) Date: Wed, 07 Dec 2005 06:18:49 +0000 Subject: [Pythonmac-SIG] pythonw stay open In-Reply-To: (from pythonmac-sig-request@python.org on Tue Dec 6 17:39:58 2005) Message-ID: <1133936329l.19972l.0l@kochab> Hello all, I have a bunch of CGIs that make use of pythonw (+cgiwrap) to allow me to send AppleEvents (via appscript) to applications on the web server machine. Everytime I hit one of these CGIs, pythonw launches a Python application (which makes sense). While this machine is under heavy-ish load (CPU hogging applications), it feels like launching pythonw takes "too long" (read: a second or two, which is too long in CGI time.) Is it possible to leave pythonw open all of the time, and avoid paying the "launch costs", or is the price for launching pythonw too minimal to notice ("time... says...")? (Meaning that I should try to optimize my system some other way, like moving the CPU hogging process off that machine...) Thanks for your advice on the situation, _Ryan Wilcox From njriley at uiuc.edu Wed Dec 7 08:01:28 2005 From: njriley at uiuc.edu (Nicholas Riley) Date: Wed, 7 Dec 2005 01:01:28 -0600 Subject: [Pythonmac-SIG] pythonw stay open In-Reply-To: <1133936329l.19972l.0l@kochab> References: <1133936329l.19972l.0l@kochab> Message-ID: <20051207070128.GE85155@uiuc.edu> On Wed, Dec 07, 2005 at 06:18:49AM +0000, Ryan Wilcox wrote: > Hello all, > > I have a bunch of CGIs that make use of pythonw (+cgiwrap) to allow me > to send AppleEvents (via appscript) to applications on the web server > machine. > > Everytime I hit one of these CGIs, pythonw launches a Python > application (which makes sense). While this machine is under heavy-ish > load (CPU hogging applications), it feels like launching pythonw takes > "too long" (read: a second or two, which is too long in CGI time.) > > Is it possible to leave pythonw open all of the time, and avoid paying > the "launch costs", or is the price for launching pythonw too minimal > to notice ("time... says...")? (Meaning that I should try to optimize > my system some other way, like moving the CPU hogging process off that > machine...) Use FastCGI, SCGI, or similar? -- Nicholas Riley | From mjb at uma.pt Wed Dec 7 10:29:47 2005 From: mjb at uma.pt (Michael J. Barber) Date: Wed, 7 Dec 2005 09:29:47 +0000 Subject: [Pythonmac-SIG] Speed up Python on the Mac? In-Reply-To: <4395D39A.9020400@noaa.gov> References: <4395C54E.10902@anvil.nrl.navy.mil> <9C47E8ED-8094-4600-8ACD-05310E94B47D@sent.com> <4395CCBE.8090500@anvil.nrl.navy.mil> <4395D39A.9020400@noaa.gov> Message-ID: <92968059cb8ea4a73ad7fcf1127af536@uma.pt> On Dec 6, 2005, at 6:08 PM, Christopher Barker wrote: > Have I got them all? I hope this helps. > A fairly esoteric one: pycaml. Note that I have not yet tried pycaml. It is claimed to allow Ocaml libraries to be used from Python, and vice versa. Anyone have any recent experience with it? Much like several other respondents, I use Python for scientific programming. The approach I generally take is the same as Nicholas Riley's: write programs on my Mac (older laptop), and run it somewhere else faster, generally using Psyco. It's not entirely satisfactory, but works so far. -- Michael From pecora at anvil.nrl.navy.mil Wed Dec 7 12:51:13 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Wed, 07 Dec 2005 06:51:13 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: <20051207045915.GA17058@arbutus.physics.mcmaster.ca> References: <439600CB.8080008@anvil.nrl.navy.mil> <43961391.5070209@anvil.nrl.navy.mil> <20051207045915.GA17058@arbutus.physics.mcmaster.ca> Message-ID: <4396CCB1.50800@anvil.nrl.navy.mil> David M. Cooke wrote: >On Tue, Dec 06, 2005 at 05:41:21PM -0500, Louis Pecora wrote: > > >>Rob Managan wrote: >> >> >> >>>PS the command to switch to gcc 3.3 seems to be >>> >>>'sudo gcc_select 3.3' >>> >>>Not sure if you had to do this with scipy or not. >>> >>> >>Hmmmm... I don't know about this one. What has this to do with Scipy? >> >> > >Experience has shown that compiling Scipy with gcc 4.0 on a Mac doesn't >work (various really annoying problems with how Fortran libraries end up >being linked and so on). So it's suggested that you use 3.3. > > > Sorry, I'm a little slow here. I was trying to compile SWIG, not SciPy. What am I missing? -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From hengist.podd at virgin.net Wed Dec 7 12:57:47 2005 From: hengist.podd at virgin.net (has) Date: Wed, 7 Dec 2005 11:57:47 +0000 Subject: [Pythonmac-SIG] Converting to AppleEvents Message-ID: Brian Ray wrote: >I have an AppleScript I am calling with os.system(): > > with timeout of 3600 seconds > tell application "MyApp" > reload startup > end tell > end timeout > >I am interested in various methods to convert this to AppleEvents. >Any sample codes of something similar? There seems to be more than >one approach. > >I am trying to learn how to handle all my communication between Mach- >O applications and Python2.3 with AppleEvents, although I do not >know where to get started. Are there any tutorials on this topic? I >do not want to use any helper modules because I also must stick with >just Python2.3. Any particular reason for that? e.g. If it's distribution worries, use py2app to build an application bundle with all dependencies included. Standard options: 1. Execute AppleScript code via os.system() and osascript: os.system(''' osascript -e 'with timeout of 3600 seconds tell application "TextEdit" get name end tell end timeout' ''') Slow, inefficient, and lowest-common-denominator approach, but if speed isn't an issue and you don't need to do anything complex then it'll do the job. 2. Use the low-level Carbon.AE extension, which provides a minimal wrapper around the Apple Event Manager API. See Apple's site for AEM documentation. Expect to write lots and lots of code this way; not much fun at all. 3. Attempt to use Python's aetools/aetypes modules (I think you can forget about gensuitemodule: I've tried it under 10.4 with no success and assume it is now completely senile): #!/usr/bin/env pythonw from aetools import * from aetypes import * te = TalkTo(signature='ttxt', start=1) print te.send('core', 'getd', {'----':ObjectSpecifier('prop', 'prop', 'pnam')})[1] Not much fun either. Documentation is minimal, and figuring out how it works will require background knowledge of Apple events and the Apple Event Manager. You'll probably need to spend time troubleshooting bugs and omissions as well (these modules predate OS X and haven't been maintained in years) and the code is less than pleasant. I really would recommend against trying #2 or #3 as they will only make you miserable. Use #1 for basic tasks, but for anything complex you should consider biting the bullet and using appscript or aem (see my site). The latest version of appscript includes an introduction to application scripting and a tutorial, and it's miles ahead of all of the above. Even if you do have to rig up your own solution in the end, you'll learn a lot more by taking aem apart and studying it than trying to figure this stuff out any other way. HTH has http://freespace.virgin.net/hamish.sanderson/ From hengist.podd at virgin.net Wed Dec 7 11:50:18 2005 From: hengist.podd at virgin.net (has) Date: Wed, 7 Dec 2005 10:50:18 +0000 Subject: [Pythonmac-SIG] pythonw stay open Message-ID: Ryan Wilcox wrote: >I have a bunch of CGIs that make use of pythonw (+cgiwrap) to allow me >to send AppleEvents (via appscript) to applications on the web server >machine. CGI's always going to be expensive as it starts a new process for each request. And yeah, if it's a GUI process then the overheads will bite even more. I imagine there's various options open to you, e.g. ditch CGI for something a bit more advanced, or put the AE stuff into a faceless GUI process that runs in the background and have your CGI scripts communicate with that via some other form of IPC. Not my area of expertise, so can't advise further, but you should look into it. Another possibility might be to do AEs over mach: I got sent some proof-of-concept code for this a while back and stuck it in the CarbonX.AE extension; assuming you've the latest versions installed it's a one-line tweak in aem.send.send to use it. Usual caveats apply: unofficial, undocumented, untested; subject to bugs, changes, removal; etc, etc. Also, if you're using appscript then make sure you run the terminology server to reduce the time it takes each process to obtain terminology data, or switch to using aem (tip: appscript.aemcodegen makes translating existing appscript code to aem code fairly easy). HTH has -- http://freespace.virgin.net/hamish.sanderson/ From bray at sent.com Wed Dec 7 16:52:21 2005 From: bray at sent.com (Brian Ray) Date: Wed, 7 Dec 2005 09:52:21 -0600 Subject: [Pythonmac-SIG] Converting to AppleEvents In-Reply-To: References: Message-ID: Thanks for your guidance. I will play with all three and see where it gets me. Also, with: On Dec 7, 2005, at 5:57 AM, has wrote: > 1. Execute AppleScript code via os.system() and osascript: > > os.system(''' > osascript -e 'with timeout of 3600 seconds > tell application "TextEdit" > get name > end tell > end timeout' > ''') This seems to work well for now. However, is there a way to have os.system() wait till it's finished? In other words how to I get the osascript tool to not return until the script has actually finished. Brian http://brianray.chipy.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051207/7f9fb874/attachment.htm From delza at livingcode.org Wed Dec 7 17:35:11 2005 From: delza at livingcode.org (Dethe Elza) Date: Wed, 7 Dec 2005 08:35:11 -0800 Subject: [Pythonmac-SIG] Converting to AppleEvents In-Reply-To: References: Message-ID: On Wed 2005-12-07, at Wed 2005-12-07T07:52 AM, Brian Ray wrote: [snipped] > This seems to work well for now. However, is there a way to have > os.system() wait till it's finished? In other words how to I get > the osascript tool to not return until the script has actually > finished. You probably want to use subprocess, not os.system(). It's a more advanced module and should allow you to wait for your script to complete (or to interact with it while it's running if you like). http://docs.python.org/lib/module-subprocess.html --Dethe "Computers are beyond dumb, they're mind-numbingly stupid. They're hostile, rigid, capricious, and unforgiving. They're impossibly demanding and they never learn anything." -- John R. Levine From Chris.Barker at noaa.gov Wed Dec 7 18:34:18 2005 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 07 Dec 2005 09:34:18 -0800 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: <20051207045915.GA17058@arbutus.physics.mcmaster.ca> References: <439600CB.8080008@anvil.nrl.navy.mil> <43961391.5070209@anvil.nrl.navy.mil> <20051207045915.GA17058@arbutus.physics.mcmaster.ca> Message-ID: <43971D1A.7010100@noaa.gov> David M. Cooke wrote: > Experience has shown that compiling Scipy with gcc 4.0 on a Mac doesn't > work (various really annoying problems with how Fortran libraries end up > being linked and so on). So it's suggested that you use 3.3. There is the same problem with Fedora Core4, also using gcc 4.*, but SWIG compiles fine there. After all, SWIG has nothing to do with Fortran. Lou, Have you tried the SWIG lists? -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 Chris.Barker at noaa.gov From pecora at anvil.nrl.navy.mil Wed Dec 7 20:00:19 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Wed, 07 Dec 2005 14:00:19 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. configure output. In-Reply-To: References: <439600CB.8080008@anvil.nrl.navy.mil> Message-ID: <43973143.5080404@anvil.nrl.navy.mil> Rob, Here is the output of my ./configure command for SWIG Install. There are some differences from your successful ouput. Not sure you want to see all this, but if you have the time here are where the differences in our configure output are. Lines marked with "+" are in addition to lines you have and they occur at the beginning where, apparently I'm missing some script file of some sort. Lines marked with "*" are lines that have differences from yours. It is pretty easy to see that the only differences are that I have g++ where you have gcc and I have 2.3 where you have 2.4 for Python versions. louispec% ./configure checking build system type... powerpc-apple-darwin7.9.0 checking host system type... powerpc-apple-darwin7.9.0 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes +/Users/louispecora/Documents/Computer: /Users/louispecora/Documents/Computer: No such file or directory +configure: WARNING: `missing' script is too old or missing checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes *checking for gcc... g++ checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes *checking whether g++ accepts -g... yes *checking for g++ option to accept ANSI C... none needed checking for style of include used by make... GNU *checking dependency style of g++... gcc3 checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking for bison... bison -y checking for ranlib... ranlib *checking whether g++ and cc understand -c and -o together... yes checking for ar... ar checking maximum warning verbosity option... -Wall -W -ansi -pedantic for C++ -Wall -W -ansi -pedantic for C *checking how to run the C preprocessor... g++ -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for bool... yes checking SO... .bundle checking LDSHARED... cc -bundle -undefined suppress -flat_namespace checking CXXSHARED... cc -bundle -undefined suppress -flat_namespace checking TRYLINKINGWITHCXX... CXXSHARED= g++ -bundle -undefined suppress -flat_namespace checking CCSHARED... checking RPATH... checking LINKFORSHARED... Checking for installed packages. Note : None of the following packages are required to compile SWIG checking for dlopen in -ldl... yes checking for shl_load in -ldld... no checking for swill_init in -lswill... no checking for main in -lieee... no checking for crypt in -lcrypt... no checking for X... libraries /usr/X11R6/lib, headers /usr/X11R6/include checking for Tcl configuration... found /usr/lib/tclConfig.sh checking for Tcl header files... -isystem /usr/include checking for Tcl library... -framework Tcl checking for python... python *checking for Python prefix... /System/Library/Frameworks/Python.framework/Versions/2.3 *checking for Python exec-prefix... /System/Library/Frameworks/Python.framework/Versions/2.3 *checking for Python version... python2.3 checking for Python lib dir... lib *checking for Python header files... -I/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3 -I/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config *checking for Python library... /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config checking for perl... perl checking for Perl5 header files... /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE checking for Perl5 library... perl.dylib checking for Perl5 compiler options... -g -pipe -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -isystem /usr/local/include checking for java... java checking for javac... javac checking for java include file jni.h... /System/Library/Frameworks/JavaVM.framework/Headers checking for java include file jni_md.h... /System/Library/Frameworks/JavaVM.framework/Headers checking for guile-config... no checking for Guile header files... not found checking for Guile library... not found checking whether Guile's gh_ API works... no checking whether Guile's SCM_ API works... no checking for mzscheme... no checking for mzc... no checking for ruby... ruby checking for Ruby header files... /usr/lib/ruby/1.6/powerpc-darwin7.0 checking for Ruby library... not found... using /usr/lib/ruby/1.6/powerpc-darwin7.0 checking for php... php checking for PHP4 header files... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend checking for Ocaml DL load generator... checking for ocamldlgen... no checking for Ocaml package tool... checking for ocamlfind... no checking for Ocaml compiler... checking for ocamlc... no checking for Ocaml interpreter... checking for ocaml... no checking for Ocaml toplevel creator... checking for ocamlmktop... no checking for Ocaml header files... not found checking for pike... no checking for pike7.6... no checking for pike7.4... no checking for pike7.2... no checking for Pike header files... not found checking for chicken... no checking for csc... no checking for csi... no checking for chicken-config... no checking for mcs... no checking for cscc... no checking for lua... no checking for Lua header files... not found checking for Lua library... not found configure: creating ./config.status config.status: creating Makefile config.status: creating swig.spec config.status: creating Source/Makefile config.status: creating Examples/Makefile config.status: creating Examples/guile/Makefile config.status: creating Examples/GIFPlot/Makefile config.status: creating Examples/GIFPlot/Lib/Makefile config.status: creating Examples/test-suite/chicken/Makefile config.status: creating Examples/test-suite/csharp/Makefile config.status: creating Examples/test-suite/guile/Makefile config.status: creating Examples/test-suite/guilescm/Makefile config.status: creating Examples/test-suite/java/Makefile config.status: creating Examples/test-suite/mzscheme/Makefile config.status: creating Examples/test-suite/ocaml/Makefile config.status: creating Examples/test-suite/perl5/Makefile config.status: creating Examples/test-suite/php4/Makefile config.status: creating Examples/test-suite/pike/Makefile config.status: creating Examples/test-suite/python/Makefile config.status: creating Examples/test-suite/ruby/Makefile config.status: creating Examples/test-suite/tcl/Makefile config.status: creating Examples/test-suite/lua/Makefile config.status: creating preinst-swig config.status: creating Source/Include/swigconfig.h config.status: Source/Include/swigconfig.h is unchanged config.status: executing depfiles commands -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From pecora at anvil.nrl.navy.mil Wed Dec 7 20:04:06 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Wed, 07 Dec 2005 14:04:06 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: References: <439600CB.8080008@anvil.nrl.navy.mil> Message-ID: <43973226.1080105@anvil.nrl.navy.mil> Rob, Here is the output of the 'make' command after my ./configure command. Again the only difference from your successful output in the beginning is my output shows g++ being used in place of gcc for you. But then in line 5 (I think I counted right) an error of some type occurs. What the heck is going on? Sigh. Thanks for taking the time to help. I'm stumped. louispec% make make all-am depbase=`echo CParse/cscanner.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \ if g++ -DHAVE_CONFIG_H -I../Source/Include -I../Source/CParse -I../Source/Include -I../Source/DOH -I../Source/CParse -I../Source/Preprocessor -I../Source/Swig -I../Source/Modules -g -O2 -Wall -W -ansi -pedantic -MT CParse/cscanner.o -MD -MP -MF "$depbase.Tpo" -c -o CParse/cscanner.o CParse/cscanner.c; \ then mv -f "$depbase.Tpo" "$depbase.Po"; else rm -f "$depbase.Tpo"; exit 1; fi In file included from CParse/cscanner.c:18: parser.y:1252: error: parse error before `throw' parser.y:1266: error: parse error before `throw' make[2]: *** [CParse/cscanner.o] Error 1 make[1]: *** [all] Error 2 make: *** [source] Error 2 Exit 2 -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From pecora at anvil.nrl.navy.mil Wed Dec 7 20:05:23 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Wed, 07 Dec 2005 14:05:23 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: <43971D1A.7010100@noaa.gov> References: <439600CB.8080008@anvil.nrl.navy.mil> <43961391.5070209@anvil.nrl.navy.mil> <20051207045915.GA17058@arbutus.physics.mcmaster.ca> <43971D1A.7010100@noaa.gov> Message-ID: <43973273.8080404@anvil.nrl.navy.mil> Christopher Barker wrote: >David M. Cooke wrote: > > >>Experience has shown that compiling Scipy with gcc 4.0 on a Mac doesn't >>work (various really annoying problems with how Fortran libraries end up >>being linked and so on). So it's suggested that you use 3.3. >> >> > >There is the same problem with Fedora Core4, also using gcc 4.*, but >SWIG compiles fine there. After all, SWIG has nothing to do with Fortran. > >Lou, > >Have you tried the SWIG lists? > >-Chris > > That's a good idea. I will go there next. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From hengist.podd at virgin.net Wed Dec 7 20:44:52 2005 From: hengist.podd at virgin.net (has) Date: Wed, 7 Dec 2005 19:44:52 +0000 Subject: [Pythonmac-SIG] pythonw stay open In-Reply-To: <43972CA6.1010205@noaa.gov> References: <43972CA6.1010205@noaa.gov> Message-ID: Christopher Barker wrote: >has wrote: >>CGI's always going to be expensive as it starts a new process for each request. And yeah, if it's a GUI process then the overheads will bite even more. > >Yes, but it sounded like the OP was getting over a second start-up time. This is very long, so I wonder if something else is going on. Oh, absolutely. OMM (not the fastest, admittedly) it probably takes a quarter of a second to import appscript (Python hauls in a big chunk of Carbon at that point). There's another quarter-second overhead in creating your first app instance (can't remember why offhand, but a profiler will tell you). If ASTS is running then it's clear sailing the rest of the way thanks to ASTS's terminology caching. If ASTS isn't running then there's a further quarter-second penalty on connecting to the first app as OSAGetAppTerminology() has to instantiate an AppleScript component before it can retrieve aete resources (stupid, I know; blame Apple's API). Plus there's the time it takes to retrieve the terminology (some Cocoa apps generate it on the fly from Cocoa Scripting data, making this even slower) and parse it (appscript is pretty fast at this, but it's still only Python) for each application the script uses; some heavyweights may well take over a second. Though you can avoid these particular overheads by only using aem, since it doesn't use terminology; aem code just takes a little more work to write. >Have you looked at your memory use under that load? > >Otherwise, there are many web frameworks for Python, most of which provide some way to keep the python process persistent. I don't see why you couldn't use any of those. > >We're using Quixote successfully on OS-X, you also might want to look into wsgi and paste. I'd be interested to know myself if anyone has used appscript/aem in a web framework context. (I'm not a web-head, so haven't explored this area myself.) Shoving the application scripting stuff into a persistent GUI process and using a light[er]weight IPC system to bridge between this and the CGI script is always an option. But having it in the main web app would be simpler and more efficient, assuming the web app uses a suitable Python distribution, of course (you won't get far without the Carbon extensions, obviously). Cheers, has -- http://freespace.virgin.net/hamish.sanderson/ From pecora at anvil.nrl.navy.mil Wed Dec 7 22:57:12 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Wed, 07 Dec 2005 16:57:12 -0500 Subject: [Pythonmac-SIG] SWIG Install problem. In-Reply-To: References: <439600CB.8080008@anvil.nrl.navy.mil> <43961391.5070209@anvil.nrl.navy.mil> <20051207045915.GA17058@arbutus.physics.mcmaster.ca> <43971D1A.7010100@noaa.gov> <43973273.8080404@anvil.nrl.navy.mil> Message-ID: <43975AB8.3080506@anvil.nrl.navy.mil> Rob Managan wrote: > Since crazy things happen I will ask. I assume that you can run gcc > from the command line? Yes. Just tried it. > Next question. What shell are you running? Mine is set to tcsh but > newer Macs tend to run bash. I typed "shell" and it came back: tcsh: shell: Command not found. My terminal prefs also show tsch. > The first lines that were different in the configure output seems to > refer to the script in Tools/config/missing. Try running it as > > Tools/config/.missing --help Did that (without the . in front of missing) and got: louispec% Tools/config/missing --help Tools/config/missing [OPTION]... PROGRAM [ARGUMENT]... Handle `PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file `aclocal.m4' autoconf touch file `configure' autoheader touch file `config.h.in' automake touch all `Makefile.in' files bison create `y.tab.[ch]', if possible, from existing .[ch] flex create `lex.yy.c', if possible, from existing .c help2man touch the output file lex create `lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create `y.tab.[ch]', if possible, from existing .[ch] *** I GOT IT ! Well, partially *************** The above along with the ./configure output gave me the clue. I had folders (directories) with spaces in the names and Mac type characters. I changed all names in the path to the SWIG folder to be Unix compatible and the ./configure ran properly. Except I still have g++ for gcc and the 'make' step still gives the same error: louispec% make make all-am depbase=`echo CParse/cscanner.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \ if g++ -DHAVE_CONFIG_H -I../Source/Include -I../Source/CParse -I../Source/Include -I../Source/DOH -I../Source/CParse -I../Source/Preprocessor -I../Source/Swig -I../Source/Modules -g -O2 -Wall -W -ansi -pedantic -MT CParse/cscanner.o -MD -MP -MF "$depbase.Tpo" -c -o CParse/cscanner.o CParse/cscanner.c; \ then mv -f "$depbase.Tpo" "$depbase.Po"; else rm -f "$depbase.Tpo"; exit 1; fi In file included from CParse/cscanner.c:18: parser.y:1252: error: parse error before `throw' parser.y:1266: error: parse error before `throw' make[2]: *** [CParse/cscanner.o] Error 1 make[1]: *** [all] Error 2 make: *** [source] Error 2 Exit 2 **** Sigh ***************************** > > Configure seems to not be able to find it or thinks it is outdated. > Maybe you have a newer version of the autotools software than I do but > I doubt that since it comes with the system software. I'm using the latest SWIG: 1.3.27 > > more later, I have to run to a talk Thanks for the help. At least I'm part of the way there. Enjoy the talk. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From piet at cs.uu.nl Thu Dec 8 12:04:11 2005 From: piet at cs.uu.nl (Piet van Oostrum) Date: Thu, 08 Dec 2005 12:04:11 +0100 Subject: [Pythonmac-SIG] Converting to AppleEvents In-Reply-To: (Brian Ray's message of "Wed, 7 Dec 2005 09:52:21 -0600") References: Message-ID: >>>>> Brian Ray (BR) wrote: >BR> This seems to work well for now. However, is there a way to have >BR> os.system() wait till it's finished? In other words how to I get the >BR> osascript tool to not return until the script has actually finished. os.system does wait. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: piet at vanoostrum.org From pecora at anvil.nrl.navy.mil Thu Dec 8 22:17:49 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Thu, 08 Dec 2005 16:17:49 -0500 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X Message-ID: <4398A2FD.4060400@anvil.nrl.navy.mil> If you are a newbie or non-guru (like me) and are are having some problems installing SWIG on Mac OS X (10.3.9, but version may not matter for the problems below), you should be aware of some problems I had and their solutions. Many thanks to several people on the email lists for Pythonmac-sig (pythonmac-sig at python.org) and SWIG (swig-user at lists.sourceforge.net) for many valuable hints, clues and pointers. The installation of SWIG on the Mac is the same three-step process as for Unix (% is the prompt): % ./configure % make % make install I had the follow problems with each step and I have the solutions. (1) running ./configure resulted in a file not found. When the script listed the file only a partial path name appeared. Solution: directories (folders) and files with spaces and special Mac symbols (e.g. option-whatever) can cause problems. I had some spaces in my folder names that held the SWIG files. When I removed those and made more Unix-like names, ./configure worked (after one more fix below). (2) running 'make' caused a parse error in CParse when compiling cscanner.c. Solution: when I looked back at ./configure I see that g++ was the chosen gcc compiiler or CC compiler. I was told it should be gcc, not g++. I found the line setenv CC g++ in my login file .tschrc which I got from a colleague. I changed it to setenv CC gcc ran the ./configure (with the directory changes, too) and then the 'make' step worked. (3) running 'make install' would not work since I had no permission to write in some directories. I don't fully understand this since I am the admin and I was running logged in as such, but to no avail. Solution: run this as sudo make install type in the password and you're off. So, does SWIG really work? Not sure yet. A test with make -k check gave mostly good grades to python things except for two C++ problems with templates and enums. The docs say this may not matter. We shall see. At least I got this far. Good luck to all and thanks to many for the help. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From Henning.Ramm at mediapro-gmbh.de Fri Dec 9 09:51:51 2005 From: Henning.Ramm at mediapro-gmbh.de (Henning.Ramm@mediapro-gmbh.de) Date: Fri, 9 Dec 2005 09:51:51 +0100 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X Message-ID: >(3) running 'make install' would not work since I had no permission to >write in some directories. I don't fully understand this since >I am the >admin and I was running logged in as such, but to no avail. > Solution: run this as > >sudo make install > >type in the password and you're off. An admin user is not root, and it's better this way; it's far less a security issue if you can 'get root' at every time with sudo than if you would run everything constantly as root (or an admin user with root permissions). Greetlings, HR From woklist at kyngchaos.com Fri Dec 9 18:56:25 2005 From: woklist at kyngchaos.com (William Kyngesburye) Date: Fri, 9 Dec 2005 11:56:25 -0600 Subject: [Pythonmac-SIG] universal python framework? Message-ID: I'm starting to build universal binaries for a bunch of 'nix stuff, some of which have python bindings/extensions. Has anyone looked at a universal Python framework? I'd hate to have to step backwards to Apple's included Python framework for that, but I may have to. ----- William Kyngesburye http://www.kyngchaos.com/ "Mon Dieu! but they are all alike. Cheating, murdering, lying, fighting, and all for things that the beasts of the jungle would not deign to possess - money to purchase the effeminate pleasures of weaklings. And yet withal bound down by silly customs that make them slaves to their unhappy lot while firm in the belief that they be the lords of creation enjoying the only real pleasures of existence.... - the wisdom of Tarzan From Jack.Jansen at cwi.nl Fri Dec 9 21:36:22 2005 From: Jack.Jansen at cwi.nl (Jack Jansen) Date: Fri, 9 Dec 2005 21:36:22 +0100 Subject: [Pythonmac-SIG] universal python framework? In-Reply-To: References: Message-ID: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> On 9-dec-2005, at 18:56, William Kyngesburye wrote: > I'm starting to build universal binaries for a bunch of 'nix stuff, > some of which have python bindings/extensions. Has anyone looked at > a universal Python framework? I'd hate to have to step backwards to > Apple's included Python framework for that, but I may have to. There's a fairly recent Apple technote that discusses how to build universal binaries for products with a configure/make build procedure, such as Python, and I hope to look at that next week. But Ronald already discovered that distutils has problems with building universal extensions, so that may also turn out to be a problem (although he wants to build something more complicated, with the PPC binary being 10.3/10.4 compatible). And the "easy" way is to simply configure Python twice (Python builds nicely in a different directory than the source, I'm doing that all the time), once for ppc once for x86, and then using lipo to combine everything. -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From bob at redivi.com Fri Dec 9 22:00:10 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 9 Dec 2005 13:00:10 -0800 Subject: [Pythonmac-SIG] universal python framework? In-Reply-To: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> References: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> Message-ID: <52EE1F68-344D-42B1-8B93-A8F828360650@redivi.com> On Dec 9, 2005, at 12:36 PM, Jack Jansen wrote: > > On 9-dec-2005, at 18:56, William Kyngesburye wrote: > >> I'm starting to build universal binaries for a bunch of 'nix stuff, >> some of which have python bindings/extensions. Has anyone looked at >> a universal Python framework? I'd hate to have to step backwards to >> Apple's included Python framework for that, but I may have to. > > There's a fairly recent Apple technote that discusses how to build > universal binaries for products with a configure/make build > procedure, such as Python, and I hope to look at that next week. But > Ronald already discovered that distutils has problems with building > universal extensions, so that may also turn out to be a problem > (although he wants to build something more complicated, with the PPC > binary being 10.3/10.4 compatible). > > And the "easy" way is to simply configure Python twice (Python builds > nicely in a different directory than the source, I'm doing that all > the time), once for ppc once for x86, and then using lipo to combine > everything. That definitely has problems with extensions unless you also manage to keep separate Python trees so that you can do that from distutils.. different pyconfig.h and Makefile. -bob From bob at redivi.com Fri Dec 9 21:41:13 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 9 Dec 2005 12:41:13 -0800 Subject: [Pythonmac-SIG] universal python framework? In-Reply-To: References: Message-ID: <89DE7380-EFF5-4956-8AB3-5BF9CF16BF31@redivi.com> On Dec 9, 2005, at 9:56 AM, William Kyngesburye wrote: > I'm starting to build universal binaries for a bunch of 'nix stuff, > some of which have python bindings/extensions. Has anyone looked at > a universal Python framework? I'd hate to have to step backwards to > Apple's included Python framework for that, but I may have to. You do have to for now. Python doesn't readily build universal. -bob From woklist at kyngchaos.com Fri Dec 9 22:09:33 2005 From: woklist at kyngchaos.com (William Kyngesburye) Date: Fri, 9 Dec 2005 15:09:33 -0600 Subject: [Pythonmac-SIG] universal python framework? In-Reply-To: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> References: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> Message-ID: <5914784A-F235-4E57-8B10-A834F9D924AC@kyngchaos.com> What with one thing or another, that's how I've had to build everything so far - build once for each and merge them. Tho with my limited skills, I've taken a more rough approach - build ppc, duplicate and clean, add in i386 options manually to makefiles, build, merge using the same link commands as the package uses. I didn't know about lipo, that looks like it would simplify the merging. I think I can wait for a universal build of python, and just build the python bits ppc-only for now. Not many (if any) will be able to test the i386 side yet. On Dec 9, 2005, at 2:36 PM, Jack Jansen wrote: > There's a fairly recent Apple technote that discusses how to build > universal binaries for products with a configure/make build > procedure, such as Python, and I hope to look at that next week. But > Ronald already discovered that distutils has problems with building > universal extensions, so that may also turn out to be a problem > (although he wants to build something more complicated, with the PPC > binary being 10.3/10.4 compatible). > > And the "easy" way is to simply configure Python twice (Python builds > nicely in a different directory than the source, I'm doing that all > the time), once for ppc once for x86, and then using lipo to combine > everything. > ----- William Kyngesburye http://www.kyngchaos.com/ Theory of the Universe There is a theory which states that if ever anyone discovers exactly what the universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarrely inexplicable. There is another theory which states that this has already happened. -Hitchhiker's Guide to the Galaxy 2nd season intro From bob at redivi.com Fri Dec 9 22:23:14 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 9 Dec 2005 13:23:14 -0800 Subject: [Pythonmac-SIG] universal python framework? In-Reply-To: <5914784A-F235-4E57-8B10-A834F9D924AC@kyngchaos.com> References: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> <5914784A-F235-4E57-8B10-A834F9D924AC@kyngchaos.com> Message-ID: It's much better to build PPC only if you can't test i386. If you create a broken universal or i386 build, then your software doesn't work on i386 machines. If you create a PPC-only build, it runs on i386 machines.. just not optimally. Much better than broken. -bob On Dec 9, 2005, at 1:09 PM, William Kyngesburye wrote: > What with one thing or another, that's how I've had to build > everything so far - build once for each and merge them. Tho with my > limited skills, I've taken a more rough approach - build ppc, > duplicate and clean, add in i386 options manually to makefiles, > build, merge using the same link commands as the package uses. I > didn't know about lipo, that looks like it would simplify the merging. > > I think I can wait for a universal build of python, and just build > the python bits ppc-only for now. Not many (if any) will be able to > test the i386 side yet. > > > On Dec 9, 2005, at 2:36 PM, Jack Jansen wrote: > >> There's a fairly recent Apple technote that discusses how to build >> universal binaries for products with a configure/make build >> procedure, such as Python, and I hope to look at that next week. But >> Ronald already discovered that distutils has problems with building >> universal extensions, so that may also turn out to be a problem >> (although he wants to build something more complicated, with the PPC >> binary being 10.3/10.4 compatible). >> >> And the "easy" way is to simply configure Python twice (Python builds >> nicely in a different directory than the source, I'm doing that all >> the time), once for ppc once for x86, and then using lipo to combine >> everything. >> > > ----- > William Kyngesburye > http://www.kyngchaos.com/ > > Theory of the Universe > > There is a theory which states that if ever anyone discovers exactly > what the universe is for and why it is here, it will instantly > disappear and be replaced by something even more bizarrely > inexplicable. There is another theory which states that this has > already happened. > > -Hitchhiker's Guide to the Galaxy 2nd season intro > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From zhiyong_peng2003 at yahoo.com Sat Dec 10 00:19:33 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Fri, 9 Dec 2005 15:19:33 -0800 (PST) Subject: [Pythonmac-SIG] import problems Message-ID: <20051209231933.89178.qmail@web35310.mail.mud.yahoo.com> Hi! All When I have module say module.py with sentance like #!pythonw import os from appscript import * and then import from terminal say pythonw, it show me error or warning message /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/aem/send/errors.py:5: DeprecationWarning: Non-ASCII character '\x80' in file /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/macerrors.py on line 326, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details import macerrors But if I erased "from appscript import *" then it will be fine. I think there is problem in appscript Any advice or suggestion? Thanks Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From bob at redivi.com Sat Dec 10 00:38:14 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 9 Dec 2005 15:38:14 -0800 Subject: [Pythonmac-SIG] import problems In-Reply-To: <20051209231933.89178.qmail@web35310.mail.mud.yahoo.com> References: <20051209231933.89178.qmail@web35310.mail.mud.yahoo.com> Message-ID: <02A2066C-DE15-4340-9C66-AC566958371A@redivi.com> On Dec 9, 2005, at 3:19 PM, Zhi Peng wrote: > /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/plat-mac/macerrors.py > on line 326, but no encoding declared; see > http://www.python.org/peps/pep-0263.html for details > import macerrors > > But if I erased "from appscript import *" then it will > be fine. I think there is problem in appscript No, it's a (harmless) bug in Python 2.3 Python 2.3.5 (#1, Mar 20 2005, 20:38:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import macerrors __main__:1: DeprecationWarning: Non-ASCII character '\x80' in file / System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ plat-mac/macerrors.py on line 326, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details Just ignore it, edit the file and remove the offending character (it's in the comment), or use Python 2.4 instead. -bob From zhiyong_peng2003 at yahoo.com Sat Dec 10 00:55:38 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Fri, 9 Dec 2005 15:55:38 -0800 (PST) Subject: [Pythonmac-SIG] import problems In-Reply-To: <02A2066C-DE15-4340-9C66-AC566958371A@redivi.com> Message-ID: <20051209235538.20199.qmail@web35304.mail.mud.yahoo.com> Thanks all I have to add #!pythonw # -*- coding: Latin-1 -*- at beginging of the file macerrors to get rid of warning message What was the difference when I try to install module say I have module.py on Macintosh? from distutils.core import setup setup(name="MyModule", version="1.0" py_modules=["module.py"]) Is above enough to set up the module? Where are "module.py" should be in current dir? Thanks Bob Ippolito wrote: On Dec 9, 2005, at 3:19 PM, Zhi Peng wrote: > /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/plat-mac/macerrors.py > on line 326, but no encoding declared; see > http://www.python.org/peps/pep-0263.html for details > import macerrors > > But if I erased "from appscript import *" then it will > be fine. I think there is problem in appscript No, it's a (harmless) bug in Python 2.3 Python 2.3.5 (#1, Mar 20 2005, 20:38:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import macerrors __main__:1: DeprecationWarning: Non-ASCII character '\x80' in file / System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ plat-mac/macerrors.py on line 326, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details Just ignore it, edit the file and remove the offending character (it's in the comment), or use Python 2.4 instead. -bob --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051209/6eadc7be/attachment.html From bob at redivi.com Sat Dec 10 01:07:07 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 9 Dec 2005 16:07:07 -0800 Subject: [Pythonmac-SIG] import problems In-Reply-To: <20051209235538.20199.qmail@web35304.mail.mud.yahoo.com> References: <20051209235538.20199.qmail@web35304.mail.mud.yahoo.com> Message-ID: <0AE55E17-0E1D-42DD-B9DA-F413A82A3FA7@redivi.com> On Dec 9, 2005, at 3:55 PM, Zhi Peng wrote: > What was the difference when I try to install module say I have > module.py on Macintosh? > > from distutils.core import setup > setup(name="MyModule", version="1.0" py_modules=["module.py"]) > > > Is above enough to set up the module? Where are "module.py" should > be in current dir? I don't really understand the question, but the distutils documentation is here: http://docs.python.org/dist/ I would suggest using packages instead of modules, and to go ahead and use setuptools for anything new. It does a lot of things that distutils should've always done, and integrates with ez_setup, eggs, etc. http://peak.telecommunity.com/DevCenter/setuptools In that case, you'd end up with something like this: from setuptools import setup setup(name=.., version=..., packages=find_packages()) -bob From zhiyong_peng2003 at yahoo.com Sat Dec 10 01:27:22 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Fri, 9 Dec 2005 16:27:22 -0800 (PST) Subject: [Pythonmac-SIG] import problems In-Reply-To: <0AE55E17-0E1D-42DD-B9DA-F413A82A3FA7@redivi.com> Message-ID: <20051210002722.48158.qmail@web35302.mail.mud.yahoo.com> Bob Let me say Thanks a lot for your email First, then I will read corresponding document. Surely it helps a lot. Regards Zhi --- Bob Ippolito wrote: > > On Dec 9, 2005, at 3:55 PM, Zhi Peng wrote: > > > What was the difference when I try to install > module say I have > > module.py on Macintosh? > > > > from distutils.core import setup > > setup(name="MyModule", version="1.0" > py_modules=["module.py"]) > > > > > > Is above enough to set up the module? Where are > "module.py" should > > be in current dir? > > I don't really understand the question, but the > distutils > documentation is here: > http://docs.python.org/dist/ > > I would suggest using packages instead of modules, > and to go ahead > and use setuptools for anything new. It does a lot > of things that > distutils should've always done, and integrates with > ez_setup, eggs, > etc. > http://peak.telecommunity.com/DevCenter/setuptools > > In that case, you'd end up with something like this: > > from setuptools import setup > setup(name=.., version=..., > packages=find_packages()) > > -bob > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From zhiyong_peng2003 at yahoo.com Sat Dec 10 01:41:09 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Fri, 9 Dec 2005 16:41:09 -0800 (PST) Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") Message-ID: <20051210004109.31515.qmail@web35311.mail.mud.yahoo.com> Hi! All In my c code, I have used myMod=PyImport_ImportModule("moduleName") and run on Mac, but it just can not import the "moduleName" for some unknown reason. I am sure I install the "moduleName" by "pythonw setup install". And I can import "moduleName" from command lines such as >pythonw >import moduleName > It is fine. I wonder why PyImport_ImportModule can not import it, while it can import module os by using PyImport_ImportModule("os") Any suggestion? Thanks Zhi --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051209/4957183d/attachment.htm From bob at redivi.com Sat Dec 10 02:15:37 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 9 Dec 2005 17:15:37 -0800 Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: <20051210004109.31515.qmail@web35311.mail.mud.yahoo.com> References: <20051210004109.31515.qmail@web35311.mail.mud.yahoo.com> Message-ID: <2A0B913B-BC58-459E-A9EA-9085749A2270@redivi.com> On Dec 9, 2005, at 4:41 PM, Zhi Peng wrote: > In my c code, I have used myMod=PyImport_ImportModule("moduleName") > and run on Mac, but it just can not import the "moduleName" for > some unknown reason. > > I am sure I install the "moduleName" by "pythonw setup install". > And I can import "moduleName" from command lines such as > > >pythonw > >import moduleName > > > > It is fine. I wonder why PyImport_ImportModule can not import it, > while it can import module os by using > PyImport_ImportModule("os") > > Any suggestion? > Are you sure it's the same version of Python, and the module is on sys.path? Check sys.version and sys.path -bob From zhiyong_peng2003 at yahoo.com Sat Dec 10 05:45:38 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Fri, 9 Dec 2005 20:45:38 -0800 (PST) Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: <2A0B913B-BC58-459E-A9EA-9085749A2270@redivi.com> Message-ID: <20051210044538.9292.qmail@web35305.mail.mud.yahoo.com> Hi! Bob I have not tried to append current directory in sys.path. Maybe I need to do sth sys.path.append("./") and then do import. The module is installed in MacPython package. The os module is in python23.dylib so it can find it and import it. But my module is just a py file. Thanks Zhi Bob Ippolito wrote: On Dec 9, 2005, at 4:41 PM, Zhi Peng wrote: > In my c code, I have used myMod=PyImport_ImportModule("moduleName") > and run on Mac, but it just can not import the "moduleName" for > some unknown reason. > > I am sure I install the "moduleName" by "pythonw setup install". > And I can import "moduleName" from command lines such as > > >pythonw > >import moduleName > > > > It is fine. I wonder why PyImport_ImportModule can not import it, > while it can import module os by using > PyImport_ImportModule("os") > > Any suggestion? > Are you sure it's the same version of Python, and the module is on sys.path? Check sys.version and sys.path -bob --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051209/29529242/attachment.htm From bob at redivi.com Sat Dec 10 06:20:47 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri, 9 Dec 2005 21:20:47 -0800 Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: <20051210044538.9292.qmail@web35305.mail.mud.yahoo.com> References: <20051210044538.9292.qmail@web35305.mail.mud.yahoo.com> Message-ID: <8D2E820F-3F86-4C21-A4A0-D6D49C2EDFA0@redivi.com> Well I have no idea whether you're extending or embedding Python.. and if you are embedding, I have no idea what steps you've taken to initialize the interpreter... so I'm not sure. Like I said before, what you need to do is make absolutely sure you're using the correct Python interpreter, framework, or dylib and also make sure that sys.path is setup properly. This might help:: PyRun_SimpleString("import sys\nprint sys.path\nprint sys.version \nprint sys.executable\n"); -bob On Dec 9, 2005, at 8:45 PM, Zhi Peng wrote: > Hi! Bob > > I have not tried to append current directory in sys.path. Maybe I > need to do sth > sys.path.append("./") and then do import. The module is installed > in MacPython package. The os module is in python23.dylib so it can > find it and import it. But my module is just a py file. > > Thanks > > > Zhi > > Bob Ippolito wrote: > > On Dec 9, 2005, at 4:41 PM, Zhi Peng wrote: > > > In my c code, I have used myMod=PyImport_ImportModule("moduleName") > > and run on Mac, but it just can not import the "moduleName" for > > some unknown reason. > > > > I am sure I install the "moduleName" by "pythonw setup install". > > And I can import "moduleName" from command lines such as > > > > >pythonw > > >import moduleName > > > > > > > It is fine. I wonder why PyImport_ImportModule can not import it, > > while it can import module os by using > > PyImport_ImportModule("os") > > > > Any suggestion? > > > > Are you sure it's the same version of Python, and the module is on > sys.path? Check sys.version and sys.path > > -bob > > > > Yahoo! Shopping > Find Great Deals on Holiday Gifts at Yahoo! Shopping > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From ronaldoussoren at mac.com Sat Dec 10 10:04:44 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Sat, 10 Dec 2005 10:04:44 +0100 Subject: [Pythonmac-SIG] universal python framework? In-Reply-To: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> References: <73BCFA66-4FD8-47F3-8F25-2B45A92CC3CB@cwi.nl> Message-ID: <38A9ACC2-2E74-49E9-9465-EB374D2E16B1@mac.com> On 9-dec-2005, at 21:36, Jack Jansen wrote: > > On 9-dec-2005, at 18:56, William Kyngesburye wrote: > >> I'm starting to build universal binaries for a bunch of 'nix stuff, >> some of which have python bindings/extensions. Has anyone looked at >> a universal Python framework? I'd hate to have to step backwards to >> Apple's included Python framework for that, but I may have to. > > There's a fairly recent Apple technote that discusses how to build > universal binaries for products with a configure/make build > procedure, such as Python, and I hope to look at that next week. But > Ronald already discovered that distutils has problems with building > universal extensions, so that may also turn out to be a problem > (although he wants to build something more complicated, with the PPC > binary being 10.3/10.4 compatible). The problem I discovered has nothing to do with being 10.3 compatible. The problem is that distutils exposes the contents of pyconfig.h through a python interface. Some python packages use that functionality (although I guess only those of people that really understand distutils). This is from the setup.py in cElementTree: config_h = sysconfig.get_config_h_filename() config_h_vars = sysconfig.parse_config_h(open(config_h)) for feature_macro in ["HAVE_MEMMOVE", "HAVE_BCOPY"]: if config_h_vars.has_key(feature_macro): defines.append((feature_macro, "1")) defines.append(("XML_NS", "1")) defines.append(("XML_DTD", "1")) if sys.byteorder == "little": defines.append(("BYTEORDER", "1234")) else: defines.append(("BYTEORDER", "4321")) This luckily doesn't use stuff like 'WORDS_BIGENDIAN' or 'SIZEOF_INT' and should therefore not cause problems with universal builds in that regard. Forwarding sys.byteorder to the compiler does of course cause minor problems. I don't know how serious this problem is, I'd guess that most python packages with extensions don't contain compilications like this. I ran into this issue when I tried to build a binary installer for Python 2.4.2, I tried to replace pyconfig.h by a header file that includes the pyconfig.h for 10.3 or 10.4 based on feature macros, but that caused problems when I tried to build cElementTree. With respect to 10.3 compatibility: I like the fact that there's currently 1 binairy distribution of python for OSX and would like to keep it that way. Getting without having discrepancies in functionality between python-universal running on 10.4-x86 and python-universal running on 10.4-ppc is a bit of a challenge, but should be doable. > > And the "easy" way is to simply configure Python twice (Python builds > nicely in a different directory than the source, I'm doing that all > the time), once for ppc once for x86, and then using lipo to combine > everything. > -- > Jack Jansen, , http://www.cwi.nl/~jack > If I can't dance I don't want to be part of your revolution -- Emma > Goldman > > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From smithsm at samuelsmith.org Sun Dec 11 21:18:35 2005 From: smithsm at samuelsmith.org (Samuel M. Smith) Date: Sun, 11 Dec 2005 13:18:35 -0700 Subject: [Pythonmac-SIG] Framework build of 2.4.2 In-Reply-To: References: <564EDA76-9E6C-4FA6-BEAA-337EEE2BB859@redivi.com> <8816571.1130690177069.JavaMail.ronaldoussoren@mac.com> <744C6C61-23F4-4095-AAB7-86495CADC888@redivi.com> <9336895.1130699331637.JavaMail.ronaldoussoren@mac.com> <2mveze2fh1.fsf@starship.python.net> Message-ID: <2CCE06D8-9B2C-4B69-A9BC-32058BC24D4D@samuelsmith.org> I can't find the installer file listed below. Would you care to share your explicit build steps so I can build it myself. It appeared from the email exchanges that you made some fixes? thanks > BTW. I finally have a working installer at http://pyobjc.sf.net/ > software/MacPython-2.4.2-1.dmg. I have barely tested this as of yet. > > This includes documentation. Annoyingly it is still necessary to > install Bob's Tiger fixes if you want to build extensions on Tiger. > The pyconfig.h created on Panther is not compatible with Tiger, I'll > see if I can find a good and simple solution for that. The easiest > solution I can think of right now is shipping the Tiger version of > pyconfig.h in the installer as well and swapping in the right > pyconfig during installation. From ronaldoussoren at mac.com Sun Dec 11 22:43:04 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Sun, 11 Dec 2005 22:43:04 +0100 Subject: [Pythonmac-SIG] Framework build of 2.4.2 In-Reply-To: <2CCE06D8-9B2C-4B69-A9BC-32058BC24D4D@samuelsmith.org> References: <564EDA76-9E6C-4FA6-BEAA-337EEE2BB859@redivi.com> <8816571.1130690177069.JavaMail.ronaldoussoren@mac.com> <744C6C61-23F4-4095-AAB7-86495CADC888@redivi.com> <9336895.1130699331637.JavaMail.ronaldoussoren@mac.com> <2mveze2fh1.fsf@starship.python.net> <2CCE06D8-9B2C-4B69-A9BC-32058BC24D4D@samuelsmith.org> Message-ID: On 11-dec-2005, at 21:18, Samuel M. Smith wrote: > I can't find the installer file listed below. Would you care to > share your explicit build steps > so I can build it myself. It appeared from the email exchanges that > you made some fixes? I have an updated version of the build script, but am not entirely happy about it. I'll see if I can fix the remaining issues this week. Ronald > > thanks > > > >> BTW. I finally have a working installer at http://pyobjc.sf.net/ >> software/MacPython-2.4.2-1.dmg. I have barely tested this as of yet. >> >> This includes documentation. Annoyingly it is still necessary to >> install Bob's Tiger fixes if you want to build extensions on Tiger. >> The pyconfig.h created on Panther is not compatible with Tiger, I'll >> see if I can find a good and simple solution for that. The easiest >> solution I can think of right now is shipping the Tiger version of >> pyconfig.h in the installer as well and swapping in the right >> pyconfig during installation. > From zhiyong_peng2003 at yahoo.com Mon Dec 12 18:40:12 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 09:40:12 -0800 (PST) Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: <8D2E820F-3F86-4C21-A4A0-D6D49C2EDFA0@redivi.com> Message-ID: <20051212174012.92867.qmail@web35311.mail.mud.yahoo.com> Hi! Bob Following is the main code that I used for test. The sys.path seems correct because I can import when I use pythonw and import SringModule. Everytime I run the program, it said "can not import StringModule". One might use a simple module with only one sentance inside as a "StringModule.py" and "StringModule.pyc". Thanks Zhi ====================================================== #include int main() { PyObject *myMod=NULL,*myClass=NULL,*myModuleInstance=NULL; Py_Initialize(); PyRun_SimpleString("import sys \n"); PyRun_SimpleString("sys.path.append('.\')\n"); PyRun_SimpleString("print sys.path \n"); //myMod=PyImport_ImportModule("os"); myMod=PyImport_ImportModule("StringModule"); if(!myMod) { printf("cannot import StringModule\n"); return TRUE; } return 0; } The 'StringModule' is in the right directory as following: ================================================== zhi-pengs-power-mac-g5:/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3 zpeng$ find . -name 'StringModule.py' -print ./StringModule.py zhi-pengs-power-mac-g5:/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3 zpeng$ find . -name 'StringModule.pyc' -print ./StringModule.pyc --- Bob Ippolito wrote: > Well I have no idea whether you're extending or > embedding Python.. > and if you are embedding, I have no idea what steps > you've taken to > initialize the interpreter... so I'm not sure. > > Like I said before, what you need to do is make > absolutely sure > you're using the correct Python interpreter, > framework, or dylib and > also make sure that sys.path is setup properly. > This might help:: > > PyRun_SimpleString("import sys\nprint > sys.path\nprint sys.version > \nprint sys.executable\n"); > > -bob > > On Dec 9, 2005, at 8:45 PM, Zhi Peng wrote: > > > Hi! Bob > > > > I have not tried to append current directory in > sys.path. Maybe I > > need to do sth > > sys.path.append("./") and then do import. The > module is installed > > in MacPython package. The os module is in > python23.dylib so it can > > find it and import it. But my module is just a py > file. > > > > Thanks > > > > > > Zhi > > > > Bob Ippolito wrote: > > > > On Dec 9, 2005, at 4:41 PM, Zhi Peng wrote: > > > > > In my c code, I have used > myMod=PyImport_ImportModule("moduleName") > > > and run on Mac, but it just can not import the > "moduleName" for > > > some unknown reason. > > > > > > I am sure I install the "moduleName" by "pythonw > setup install". > > > And I can import "moduleName" from command lines > such as > > > > > > >pythonw > > > >import moduleName > > > > > > > > > > It is fine. I wonder why PyImport_ImportModule > can not import it, > > > while it can import module os by using > > > PyImport_ImportModule("os") > > > > > > Any suggestion? > > > > > > > Are you sure it's the same version of Python, and > the module is on > > sys.path? Check sys.version and sys.path > > > > -bob > > > > > > > > Yahoo! Shopping > > Find Great Deals on Holiday Gifts at Yahoo! > Shopping > > _______________________________________________ > > Pythonmac-SIG maillist - > Pythonmac-SIG at python.org > > > http://mail.python.org/mailman/listinfo/pythonmac-sig > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From zhiyong_peng2003 at yahoo.com Mon Dec 12 18:51:29 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 09:51:29 -0800 (PST) Subject: [Pythonmac-SIG] anyone tried to import module from c coe? Message-ID: <20051212175129.91565.qmail@web35310.mail.mud.yahoo.com> Hi All It seems to me it is very strange that it can not import the module that is in python from C code. The sys.path is correct. What else did I miss? I linked obj with python library. Thanks Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From zhiyong_peng2003 at yahoo.com Mon Dec 12 19:02:58 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 10:02:58 -0800 (PST) Subject: [Pythonmac-SIG] pyo and pyc Message-ID: <20051212180258.96189.qmail@web35310.mail.mud.yahoo.com> Hi! All What was the .pyo file on Mac. Could anyone tell me how to make a .pyo file from .py file? Thanks. Regards Zhi --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051212/8e561172/attachment.htm From zhiyong_peng2003 at yahoo.com Mon Dec 12 19:09:28 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 10:09:28 -0800 (PST) Subject: [Pythonmac-SIG] pyo and pyc In-Reply-To: <20051212180258.96189.qmail@web35310.mail.mud.yahoo.com> Message-ID: <20051212180928.99469.qmail@web35310.mail.mud.yahoo.com> When I generate the module, it generated .pyc file but not .pyo file. IS that a reason that I can not import the module from c code? Or something else that I missed. Thanks Zhi Zhi Peng wrote: Hi! All What was the .pyo file on Mac. Could anyone tell me how to make a .pyo file from .py file? Thanks. Regards Zhi --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG at python.org http://mail.python.org/mailman/listinfo/pythonmac-sig --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051212/94863ce4/attachment.html From zhiyong_peng2003 at yahoo.com Mon Dec 12 19:30:54 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 10:30:54 -0800 (PST) Subject: [Pythonmac-SIG] import problems Message-ID: <20051212183054.24864.qmail@web35313.mail.mud.yahoo.com> Hi! All If you use MacPython2.3 on MAc, please try the following code to see if you can get "StringModule" imported. //=============================StringModule.py=========== #!pythonw import os class Module1: def __init__(self): self.var1= 9 def method1(self): self.var1=10; //========================= makefile ==================== YLIB = PYINC=-I./ -I/usr/include -I/usr/include/python2.3 LIBS =-L/usr/lib -ldl -lm -lpython OPTS= -Wall -Wstrict-prototypes PROGRAM=ScriptSupport ScriptSupport::ScriptSupport.o gcc -g ScriptSupport.o $(LIBS) $(PYLIB) -o ScriptSupport ScriptSupport.o:ScriptSupport.c gcc -g ScriptSupport.c -c $(PYINC) $(OPTS) -o ScriptSupport.o clean: rm -f $(PROGRAM) *.o core //================ ScriptSupport.c ======================== #include #define FALSE 0 #define TRUE 1 int main(void) { PyObject *myMod=NULL; Py_Initialize(); PyRun_SimpleString("import sys \n"); PyRun_SimpleString("sys.path.append('.\')\n"); PyRun_SimpleString("print sys.path \n"); //#myMod=PyImport_ImportModule("wave"); myMod=PyImport_ImportModule("StringModule"); if(!myMod) { printf("cannot import StringModule wave\n"); return TRUE; } Py_Finalize(); return 0; } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From zhiyong_peng2003 at yahoo.com Mon Dec 12 20:48:36 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 11:48:36 -0800 (PST) Subject: [Pythonmac-SIG] import problems In-Reply-To: Message-ID: <20051212194836.73437.qmail@web35303.mail.mud.yahoo.com> Thanks Ronald and everyone. My OS is Tiger. This shows me that my Python installation or default has been changed or something is missing for sure. It is strange for me to see this type of results. Regards Zhi --- Ronald Oussoren wrote: > > On 12-dec-2005, at 19:30, Zhi Peng wrote: > > > Hi! All > > > > If you use MacPython2.3 on MAc, please try the > > following code to see if you can get > "StringModule" > > imported. > > This works for me, run see the attached zipfile for > the code I used. > The only change I made was an additional printf to > demonstrate that > the module is indeed imported by print its repr(). > > This is on OSX 10.4.3. > > BTW. I had to reformat the makefile and C code > because those got > mangled along the way, I prefer to include complete > code examples in > an archive. > > Ronald > > > > > > > > //=============================StringModule.py=========== > > #!pythonw > > > > import os > > > > class Module1: > > def __init__(self): > > self.var1= 9 > > def method1(self): > > self.var1=10; > > > > > > > > > > > > //========================= makefile > > ==================== > > YLIB = > > > > > > PYINC=-I./ -I/usr/include -I/usr/include/python2.3 > > LIBS =-L/usr/lib -ldl -lm -lpython > > > > OPTS= -Wall -Wstrict-prototypes > > > > PROGRAM=ScriptSupport > > ScriptSupport::ScriptSupport.o > > gcc -g ScriptSupport.o $(LIBS) $(PYLIB) -o > > ScriptSupport > > ScriptSupport.o:ScriptSupport.c > > gcc -g ScriptSupport.c -c $(PYINC) $(OPTS) > -o > > ScriptSupport.o > > clean: > > rm -f $(PROGRAM) *.o core > > > > > > > > > > > > //================ ScriptSupport.c > > ======================== > > > > #include > > > > #define FALSE 0 > > #define TRUE 1 > > > > int main(void) > > { > > PyObject *myMod=NULL; > > > > > > Py_Initialize(); > > > > PyRun_SimpleString("import sys \n"); > > > > > PyRun_SimpleString("sys.path.append('.\')\n"); > > PyRun_SimpleString("print sys.path \n"); > > > > //#myMod=PyImport_ImportModule("wave"); > > > > > myMod=PyImport_ImportModule("StringModule"); > > if(!myMod) { printf("cannot import > > StringModule wave\n"); return TRUE; } > > > > Py_Finalize(); > > > > return 0; > > } > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > _______________________________________________ > > Pythonmac-SIG maillist - > Pythonmac-SIG at python.org > > > http://mail.python.org/mailman/listinfo/pythonmac-sig > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From ronaldoussoren at mac.com Mon Dec 12 20:50:42 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Mon, 12 Dec 2005 20:50:42 +0100 Subject: [Pythonmac-SIG] import problems In-Reply-To: <20051212194836.73437.qmail@web35303.mail.mud.yahoo.com> References: <20051212194836.73437.qmail@web35303.mail.mud.yahoo.com> Message-ID: <5A3CA59B-BA9D-4BC5-B553-B446300196F4@mac.com> On 12-dec-2005, at 20:48, Zhi Peng wrote: > > Thanks Ronald and everyone. My OS is Tiger. This shows > me that my Python installation or default has been > changed or something is missing for sure. It is > strange for me to see this type of results. What's the output if you insert a call to PyErr_Print on the line that start with "if(!myMod)" (e.g.: if(!myMod) { printf("cannot import StringModule wave\n"); PyErr_Print(); return TRUE; } Please use the version in my zipfile and run 'make' to build and run the ScriptSupport program. Ronald > > > Regards > > Zhi > > > --- Ronald Oussoren wrote: > >> >> On 12-dec-2005, at 19:30, Zhi Peng wrote: >> >>> Hi! All >>> >>> If you use MacPython2.3 on MAc, please try the >>> following code to see if you can get >> "StringModule" >>> imported. >> >> This works for me, run see the attached zipfile for >> the code I used. >> The only change I made was an additional printf to >> demonstrate that >> the module is indeed imported by print its repr(). >> >> This is on OSX 10.4.3. >> >> BTW. I had to reformat the makefile and C code >> because those got >> mangled along the way, I prefer to include complete >> code examples in >> an archive. >> >> Ronald >> >>> >>> >>> >> > //=============================StringModule.py=========== >>> #!pythonw >>> >>> import os >>> >>> class Module1: >>> def __init__(self): >>> self.var1= 9 >>> def method1(self): >>> self.var1=10; >>> >>> >>> >>> >>> >>> //========================= makefile >>> ==================== >>> YLIB = >>> >>> >>> PYINC=-I./ -I/usr/include -I/usr/include/python2.3 >>> LIBS =-L/usr/lib -ldl -lm -lpython >>> >>> OPTS= -Wall -Wstrict-prototypes >>> >>> PROGRAM=ScriptSupport >>> ScriptSupport::ScriptSupport.o >>> gcc -g ScriptSupport.o $(LIBS) $(PYLIB) -o >>> ScriptSupport >>> ScriptSupport.o:ScriptSupport.c >>> gcc -g ScriptSupport.c -c $(PYINC) $(OPTS) >> -o >>> ScriptSupport.o >>> clean: >>> rm -f $(PROGRAM) *.o core >>> >>> >>> >>> >>> >>> //================ ScriptSupport.c >>> ======================== >>> >>> #include >>> >>> #define FALSE 0 >>> #define TRUE 1 >>> >>> int main(void) >>> { >>> PyObject *myMod=NULL; >>> >>> >>> Py_Initialize(); >>> >>> PyRun_SimpleString("import sys \n"); >>> >>> >> PyRun_SimpleString("sys.path.append('.\')\n"); >>> PyRun_SimpleString("print sys.path \n"); >>> >>> //#myMod=PyImport_ImportModule("wave"); >>> >>> >> myMod=PyImport_ImportModule("StringModule"); >>> if(!myMod) { printf("cannot import >>> StringModule wave\n"); return TRUE; } >>> >>> Py_Finalize(); >>> >>> return 0; >>> } >>> >>> >>> __________________________________________________ >>> Do You Yahoo!? >>> Tired of spam? Yahoo! Mail has the best spam >> protection around >>> http://mail.yahoo.com >>> _______________________________________________ >>> Pythonmac-SIG maillist - >> Pythonmac-SIG at python.org >>> >> > http://mail.python.org/mailman/listinfo/pythonmac-sig >> >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com From zhiyong_peng2003 at yahoo.com Mon Dec 12 20:57:47 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 11:57:47 -0800 (PST) Subject: [Pythonmac-SIG] import problems In-Reply-To: <5A3CA59B-BA9D-4BC5-B553-B446300196F4@mac.com> Message-ID: <20051212195747.52287.qmail@web35311.mail.mud.yahoo.com> Hi! Ronald I run your makefile. it is compiled and run as one command. But I still can not import module. The error message is "can not import module wave". I think there is something wrong on my Mac, because the program is simple enough. What was the version of you python? I assume it is python2.3 and tiger OS too? Thanks Regards Zhi --- Ronald Oussoren wrote: > > On 12-dec-2005, at 20:48, Zhi Peng wrote: > > > > > Thanks Ronald and everyone. My OS is Tiger. This > shows > > me that my Python installation or default has been > > changed or something is missing for sure. It is > > strange for me to see this type of results. > > What's the output if you insert a call to > PyErr_Print on the line > that start with "if(!myMod)" (e.g.: > if(!myMod) { printf("cannot import > StringModule wave\n"); > PyErr_Print(); return TRUE; } > > Please use the version in my zipfile and run 'make' > to build and run > the ScriptSupport program. > > Ronald > > > > > > > Regards > > > > Zhi > > > > > > --- Ronald Oussoren > wrote: > > > >> > >> On 12-dec-2005, at 19:30, Zhi Peng wrote: > >> > >>> Hi! All > >>> > >>> If you use MacPython2.3 on MAc, please try the > >>> following code to see if you can get > >> "StringModule" > >>> imported. > >> > >> This works for me, run see the attached zipfile > for > >> the code I used. > >> The only change I made was an additional printf > to > >> demonstrate that > >> the module is indeed imported by print its > repr(). > >> > >> This is on OSX 10.4.3. > >> > >> BTW. I had to reformat the makefile and C code > >> because those got > >> mangled along the way, I prefer to include > complete > >> code examples in > >> an archive. > >> > >> Ronald > >> > >>> > >>> > >>> > >> > > > //=============================StringModule.py=========== > >>> #!pythonw > >>> > >>> import os > >>> > >>> class Module1: > >>> def __init__(self): > >>> self.var1= 9 > >>> def method1(self): > >>> self.var1=10; > >>> > >>> > >>> > >>> > >>> > >>> //========================= makefile > >>> ==================== > >>> YLIB = > >>> > >>> > >>> PYINC=-I./ -I/usr/include > -I/usr/include/python2.3 > >>> LIBS =-L/usr/lib -ldl -lm -lpython > >>> > >>> OPTS= -Wall -Wstrict-prototypes > >>> > >>> PROGRAM=ScriptSupport > >>> ScriptSupport::ScriptSupport.o > >>> gcc -g ScriptSupport.o $(LIBS) $(PYLIB) > -o > >>> ScriptSupport > >>> ScriptSupport.o:ScriptSupport.c > >>> gcc -g ScriptSupport.c -c $(PYINC) > $(OPTS) > >> -o > >>> ScriptSupport.o > >>> clean: > >>> rm -f $(PROGRAM) *.o core > >>> > >>> > >>> > >>> > >>> > >>> //================ ScriptSupport.c > >>> ======================== > >>> > >>> #include > >>> > >>> #define FALSE 0 > >>> #define TRUE 1 > >>> > >>> int main(void) > >>> { > >>> PyObject *myMod=NULL; > >>> > >>> > >>> Py_Initialize(); > >>> > >>> PyRun_SimpleString("import sys \n"); > >>> > >>> > >> PyRun_SimpleString("sys.path.append('.\')\n"); > >>> PyRun_SimpleString("print sys.path \n"); > >>> > >>> //#myMod=PyImport_ImportModule("wave"); > >>> > >>> > >> myMod=PyImport_ImportModule("StringModule"); > >>> if(!myMod) { printf("cannot import > >>> StringModule wave\n"); return TRUE; } > >>> > >>> Py_Finalize(); > >>> > >>> return 0; > >>> } > >>> > >>> > >>> > __________________________________________________ > >>> Do You Yahoo!? > >>> Tired of spam? Yahoo! Mail has the best spam > >> protection around > >>> http://mail.yahoo.com > >>> _______________________________________________ > >>> Pythonmac-SIG maillist - > >> Pythonmac-SIG at python.org > >>> > >> > > > http://mail.python.org/mailman/listinfo/pythonmac-sig > >> > >> > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From ronaldoussoren at mac.com Mon Dec 12 21:36:14 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Mon, 12 Dec 2005 21:36:14 +0100 Subject: [Pythonmac-SIG] import problems In-Reply-To: <20051212195747.52287.qmail@web35311.mail.mud.yahoo.com> References: <20051212195747.52287.qmail@web35311.mail.mud.yahoo.com> Message-ID: On 12-dec-2005, at 20:57, Zhi Peng wrote: > Hi! Ronald > > I run your makefile. it is compiled and run as one > command. But I still can not import module. > The error message is "can not import module wave". That's not a very useful message :-(. BTW. why does it refer to module wave? It should rever to module StringModule. What's the complete output of running ScriptSupport? > > I think there is something wrong on my Mac, because > the program is simple enough. > > What was the version of you python? I assume it is > python2.3 and tiger OS too? Yes, Python 2.3 on Tiger (10.4.3) with Xcode 2.2. Ronald > > > Thanks > > > Regards > > Zhi > > > > --- Ronald Oussoren wrote: > >> >> On 12-dec-2005, at 20:48, Zhi Peng wrote: >> >>> >>> Thanks Ronald and everyone. My OS is Tiger. This >> shows >>> me that my Python installation or default has been >>> changed or something is missing for sure. It is >>> strange for me to see this type of results. >> >> What's the output if you insert a call to >> PyErr_Print on the line >> that start with "if(!myMod)" (e.g.: >> if(!myMod) { printf("cannot import >> StringModule wave\n"); >> PyErr_Print(); return TRUE; } >> >> Please use the version in my zipfile and run 'make' >> to build and run >> the ScriptSupport program. >> >> Ronald >> >>> >>> >>> Regards >>> >>> Zhi >>> >>> >>> --- Ronald Oussoren >> wrote: >>> >>>> >>>> On 12-dec-2005, at 19:30, Zhi Peng wrote: >>>> >>>>> Hi! All >>>>> >>>>> If you use MacPython2.3 on MAc, please try the >>>>> following code to see if you can get >>>> "StringModule" >>>>> imported. >>>> >>>> This works for me, run see the attached zipfile >> for >>>> the code I used. >>>> The only change I made was an additional printf >> to >>>> demonstrate that >>>> the module is indeed imported by print its >> repr(). >>>> >>>> This is on OSX 10.4.3. >>>> >>>> BTW. I had to reformat the makefile and C code >>>> because those got >>>> mangled along the way, I prefer to include >> complete >>>> code examples in >>>> an archive. >>>> >>>> Ronald >>>> >>>>> >>>>> >>>>> >>>> >>> >> > //=============================StringModule.py=========== >>>>> #!pythonw >>>>> >>>>> import os >>>>> >>>>> class Module1: >>>>> def __init__(self): >>>>> self.var1= 9 >>>>> def method1(self): >>>>> self.var1=10; >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> //========================= makefile >>>>> ==================== >>>>> YLIB = >>>>> >>>>> >>>>> PYINC=-I./ -I/usr/include >> -I/usr/include/python2.3 >>>>> LIBS =-L/usr/lib -ldl -lm -lpython >>>>> >>>>> OPTS= -Wall -Wstrict-prototypes >>>>> >>>>> PROGRAM=ScriptSupport >>>>> ScriptSupport::ScriptSupport.o >>>>> gcc -g ScriptSupport.o $(LIBS) $(PYLIB) >> -o >>>>> ScriptSupport >>>>> ScriptSupport.o:ScriptSupport.c >>>>> gcc -g ScriptSupport.c -c $(PYINC) >> $(OPTS) >>>> -o >>>>> ScriptSupport.o >>>>> clean: >>>>> rm -f $(PROGRAM) *.o core >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> //================ ScriptSupport.c >>>>> ======================== >>>>> >>>>> #include >>>>> >>>>> #define FALSE 0 >>>>> #define TRUE 1 >>>>> >>>>> int main(void) >>>>> { >>>>> PyObject *myMod=NULL; >>>>> >>>>> >>>>> Py_Initialize(); >>>>> >>>>> PyRun_SimpleString("import sys \n"); >>>>> >>>>> >>>> PyRun_SimpleString("sys.path.append('.\')\n"); >>>>> PyRun_SimpleString("print sys.path \n"); >>>>> >>>>> //#myMod=PyImport_ImportModule("wave"); >>>>> >>>>> >>>> myMod=PyImport_ImportModule("StringModule"); >>>>> if(!myMod) { printf("cannot import >>>>> StringModule wave\n"); return TRUE; } >>>>> >>>>> Py_Finalize(); >>>>> >>>>> return 0; >>>>> } >>>>> >>>>> >>>>> >> __________________________________________________ >>>>> Do You Yahoo!? >>>>> Tired of spam? Yahoo! Mail has the best spam >>>> protection around >>>>> http://mail.yahoo.com >>>>> _______________________________________________ >>>>> Pythonmac-SIG maillist - >>>> Pythonmac-SIG at python.org >>>>> >>>> >>> >> > http://mail.python.org/mailman/listinfo/pythonmac-sig >>>> >>>> >>> >>> >>> __________________________________________________ >>> Do You Yahoo!? >>> Tired of spam? Yahoo! Mail has the best spam >> protection around >>> http://mail.yahoo.com >> >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com From bob at redivi.com Mon Dec 12 23:39:53 2005 From: bob at redivi.com (Bob Ippolito) Date: Mon, 12 Dec 2005 14:39:53 -0800 Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: <20051212174012.92867.qmail@web35311.mail.mud.yahoo.com> References: <20051212174012.92867.qmail@web35311.mail.mud.yahoo.com> Message-ID: <97DFB70E-5DC5-46DE-90B2-4CC99A07CF18@redivi.com> If sys.path is correct, then it would import. I don't believe you, show the sys.path from the python interpreter and show it from your program. -bob On Dec 12, 2005, at 9:40 AM, Zhi Peng wrote: > > Hi! Bob > > Following is the main code that I used for test. The > sys.path seems correct because I can import when I use > pythonw and import SringModule. Everytime I run the > program, it said "can not import > StringModule". One might use a simple module with only > one sentance inside as a "StringModule.py" and > "StringModule.pyc". > > Thanks > > Zhi > > ====================================================== > > > #include > > > int main() > { > PyObject > *myMod=NULL,*myClass=NULL,*myModuleInstance=NULL; > > > Py_Initialize(); > > PyRun_SimpleString("import sys \n"); > > PyRun_SimpleString("sys.path.append('.\')\n"); > PyRun_SimpleString("print sys.path \n"); > > //myMod=PyImport_ImportModule("os"); > > myMod=PyImport_ImportModule("StringModule"); > if(!myMod) { printf("cannot import > StringModule\n"); return TRUE; } > return 0; > > } > > > > The 'StringModule' is in the right directory as > following: > ================================================== > zhi-pengs-power-mac-g5:/System/Library/Frameworks/Python.framework/ > Versions/2.3/lib/python2.3 > > zpeng$ find . -name 'StringModule.py' -print > ./StringModule.py > > zhi-pengs-power-mac-g5:/System/Library/Frameworks/Python.framework/ > Versions/2.3/lib/python2.3 > > > zpeng$ find . -name 'StringModule.pyc' -print > ./StringModule.pyc > > > > > --- Bob Ippolito wrote: > >> Well I have no idea whether you're extending or >> embedding Python.. >> and if you are embedding, I have no idea what steps >> you've taken to >> initialize the interpreter... so I'm not sure. >> >> Like I said before, what you need to do is make >> absolutely sure >> you're using the correct Python interpreter, >> framework, or dylib and >> also make sure that sys.path is setup properly. >> This might help:: >> >> PyRun_SimpleString("import sys\nprint >> sys.path\nprint sys.version >> \nprint sys.executable\n"); >> >> -bob >> >> On Dec 9, 2005, at 8:45 PM, Zhi Peng wrote: >> >>> Hi! Bob >>> >>> I have not tried to append current directory in >> sys.path. Maybe I >>> need to do sth >>> sys.path.append("./") and then do import. The >> module is installed >>> in MacPython package. The os module is in >> python23.dylib so it can >>> find it and import it. But my module is just a py >> file. >>> >>> Thanks >>> >>> >>> Zhi >>> >>> Bob Ippolito wrote: >>> >>> On Dec 9, 2005, at 4:41 PM, Zhi Peng wrote: >>> >>>> In my c code, I have used >> myMod=PyImport_ImportModule("moduleName") >>>> and run on Mac, but it just can not import the >> "moduleName" for >>>> some unknown reason. >>>> >>>> I am sure I install the "moduleName" by "pythonw >> setup install". >>>> And I can import "moduleName" from command lines >> such as >>>> >>>>> pythonw >>>>> import moduleName >>>>> >>>> >>>> It is fine. I wonder why PyImport_ImportModule >> can not import it, >>>> while it can import module os by using >>>> PyImport_ImportModule("os") >>>> >>>> Any suggestion? >>>> >>> >>> Are you sure it's the same version of Python, and >> the module is on >>> sys.path? Check sys.version and sys.path >>> >>> -bob >>> >>> >>> >>> Yahoo! Shopping >>> Find Great Deals on Holiday Gifts at Yahoo! >> Shopping >>> _______________________________________________ >>> Pythonmac-SIG maillist - >> Pythonmac-SIG at python.org >>> >> > http://mail.python.org/mailman/listinfo/pythonmac-sig >> >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From bob at redivi.com Mon Dec 12 23:40:55 2005 From: bob at redivi.com (Bob Ippolito) Date: Mon, 12 Dec 2005 14:40:55 -0800 Subject: [Pythonmac-SIG] anyone tried to import module from c coe? In-Reply-To: <20051212175129.91565.qmail@web35310.mail.mud.yahoo.com> References: <20051212175129.91565.qmail@web35310.mail.mud.yahoo.com> Message-ID: <99FAE97C-E09D-4A58-8D1E-2B813869E575@redivi.com> On Dec 12, 2005, at 9:51 AM, Zhi Peng wrote: > It seems to me it is very strange that it can not > import the module that is in python from C code. I've done it plenty of times with no problem... if you're having a problem with it, then it's in your code or environment somewhere. You still haven't actually proved that sys.path is correct, I think you're mistaken. -bob From bob at redivi.com Mon Dec 12 23:41:48 2005 From: bob at redivi.com (Bob Ippolito) Date: Mon, 12 Dec 2005 14:41:48 -0800 Subject: [Pythonmac-SIG] pyo and pyc In-Reply-To: <20051212180258.96189.qmail@web35310.mail.mud.yahoo.com> References: <20051212180258.96189.qmail@web35310.mail.mud.yahoo.com> Message-ID: On Dec 12, 2005, at 10:02 AM, Zhi Peng wrote: > What was the .pyo file on Mac. Could anyone tell me how to make > a .pyo file from .py file? Thanks. .pyo files are generated by the Python interpreter when passed the optimize flag. They're the same thing as .pyc, just stripped of docstrings. -bob From zhiyong_peng2003 at yahoo.com Tue Dec 13 02:21:01 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 17:21:01 -0800 (PST) Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: <97DFB70E-5DC5-46DE-90B2-4CC99A07CF18@redivi.com> Message-ID: <20051213012101.81915.qmail@web35311.mail.mud.yahoo.com> Hi! Bob As I said, I can import it from command line by >pythonw >import StringModule > By the way, the StringModule has been installed in the MacPython system as I do a setup. The sys.path print out as following: ============= zhi-pengs-power-mac-g5:~/Desktop/zhiyong/ScriptSupport zpeng$ make gcc -g ScriptSupport.c -c -I./ -I/usr/include -I/usr/include/python2.3 -Wall -Wstrict-prototypes -o ScriptSupport.o gcc -g ScriptSupport.o -L/usr/lib -ldl -lm -lpython -o ScriptSupport ./ScriptSupport ['/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python23.zip', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.3/Extras/lib/python', '.'] cannot import StringModule wave Thanks Zhi --- Bob Ippolito wrote: > If sys.path is correct, then it would import. I > don't believe you, > show the sys.path from the python interpreter and > show it from your > program. > > -bob > > On Dec 12, 2005, at 9:40 AM, Zhi Peng wrote: > > > > > Hi! Bob > > > > Following is the main code that I used for test. > The > > sys.path seems correct because I can import when I > use > > pythonw and import SringModule. Everytime I run > the > > program, it said "can not import > > StringModule". One might use a simple module with > only > > one sentance inside as a "StringModule.py" and > > "StringModule.pyc". > > > > Thanks > > > > Zhi > > > > > ====================================================== > > > > > > #include > > > > > > int main() > > { > > PyObject > > *myMod=NULL,*myClass=NULL,*myModuleInstance=NULL; > > > > > > Py_Initialize(); > > > > PyRun_SimpleString("import sys \n"); > > > > > PyRun_SimpleString("sys.path.append('.\')\n"); > > PyRun_SimpleString("print sys.path \n"); > > > > //myMod=PyImport_ImportModule("os"); > > > > > myMod=PyImport_ImportModule("StringModule"); > > if(!myMod) { printf("cannot import > > StringModule\n"); return TRUE; } > > return 0; > > > > } > > > > > > > > The 'StringModule' is in the right directory as > > following: > > ================================================== > > > zhi-pengs-power-mac-g5:/System/Library/Frameworks/Python.framework/ > > > Versions/2.3/lib/python2.3 > > > > zpeng$ find . -name 'StringModule.py' -print > > ./StringModule.py > > > > > zhi-pengs-power-mac-g5:/System/Library/Frameworks/Python.framework/ > > > Versions/2.3/lib/python2.3 > > > > > > zpeng$ find . -name 'StringModule.pyc' -print > > ./StringModule.pyc > > > > > > > > > > --- Bob Ippolito wrote: > > > >> Well I have no idea whether you're extending or > >> embedding Python.. > >> and if you are embedding, I have no idea what > steps > >> you've taken to > >> initialize the interpreter... so I'm not sure. > >> > >> Like I said before, what you need to do is make > >> absolutely sure > >> you're using the correct Python interpreter, > >> framework, or dylib and > >> also make sure that sys.path is setup properly. > >> This might help:: > >> > >> PyRun_SimpleString("import sys\nprint > >> sys.path\nprint sys.version > >> \nprint sys.executable\n"); > >> > >> -bob > >> > >> On Dec 9, 2005, at 8:45 PM, Zhi Peng wrote: > >> > >>> Hi! Bob > >>> > >>> I have not tried to append current directory in > >> sys.path. Maybe I > >>> need to do sth > >>> sys.path.append("./") and then do import. The > >> module is installed > >>> in MacPython package. The os module is in > >> python23.dylib so it can > >>> find it and import it. But my module is just a > py > >> file. > >>> > >>> Thanks > >>> > >>> > >>> Zhi > >>> > >>> Bob Ippolito wrote: > >>> > >>> On Dec 9, 2005, at 4:41 PM, Zhi Peng wrote: > >>> > >>>> In my c code, I have used > >> myMod=PyImport_ImportModule("moduleName") > >>>> and run on Mac, but it just can not import the > >> "moduleName" for > >>>> some unknown reason. > >>>> > >>>> I am sure I install the "moduleName" by > "pythonw > >> setup install". > >>>> And I can import "moduleName" from command > lines > >> such as > >>>> > >>>>> pythonw > >>>>> import moduleName > >>>>> > >>>> > >>>> It is fine. I wonder why PyImport_ImportModule > >> can not import it, > >>>> while it can import module os by using > >>>> PyImport_ImportModule("os") > >>>> > >>>> Any suggestion? > >>>> > >>> > >>> Are you sure it's the same version of Python, > and > >> the module is on > >>> sys.path? Check sys.version and sys.path > >>> > >>> -bob > >>> > >>> > >>> > >>> Yahoo! Shopping > >>> Find Great Deals on Holiday Gifts at Yahoo! > >> Shopping > >>> _______________________________________________ > >>> Pythonmac-SIG maillist - > >> Pythonmac-SIG at python.org > >>> > >> > > > http://mail.python.org/mailman/listinfo/pythonmac-sig > >> > >> > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > _______________________________________________ > > Pythonmac-SIG maillist - > Pythonmac-SIG at python.org > > > http://mail.python.org/mailman/listinfo/pythonmac-sig > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From zhiyong_peng2003 at yahoo.com Tue Dec 13 02:23:32 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 12 Dec 2005 17:23:32 -0800 (PST) Subject: [Pythonmac-SIG] pyo and pyc In-Reply-To: Message-ID: <20051213012332.71662.qmail@web35301.mail.mud.yahoo.com> I think there are something wrong with my MacPython as the code is simple and I am sure it will be run on Linux. You and another Friend may run this program. He did not get any error. Thanks Zhi --- Bob Ippolito wrote: > > On Dec 12, 2005, at 10:02 AM, Zhi Peng wrote: > > > What was the .pyo file on Mac. Could anyone tell > me how to make > > a .pyo file from .py file? Thanks. > > .pyo files are generated by the Python interpreter > when passed the > optimize flag. They're the same thing as .pyc, just > stripped of > docstrings. > > -bob > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From matthias.oberlaender at daimlerchrysler.com Tue Dec 13 14:20:31 2005 From: matthias.oberlaender at daimlerchrysler.com (matthias.oberlaender@daimlerchrysler.com) Date: Tue, 13 Dec 2005 14:20:31 +0100 Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: Message-ID: (snip) >>>> PyRun_SimpleString("sys.path.append('.\')\n"); (snip) I try to throw in my 5 Cent: The backslash (Windows path separator?) following the dot might be the problem. So let me guess, the program runs on Windows, but not on Unix. (Sorry for my silly quoting, but Lotus Notes is a pain!) -- Matthias From zhiyong_peng2003 at yahoo.com Tue Dec 13 16:25:14 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 07:25:14 -0800 (PST) Subject: [Pythonmac-SIG] Mac PyImport_ImportModule("modulename") In-Reply-To: Message-ID: <20051213152514.84732.qmail@web35310.mail.mud.yahoo.com> Thanks matthias.oberlaender at daimlerchrysler.com wrote: (snip) >>>> PyRun_SimpleString("sys.path.append('.\')\n"); (snip) I try to throw in my 5 Cent: The backslash (Windows path separator?) following the dot might be the problem. So let me guess, the program runs on Windows, but not on Unix. (Sorry for my silly quoting, but Lotus Notes is a pain!) -- Matthias _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG at python.org http://mail.python.org/mailman/listinfo/pythonmac-sig --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/138710c0/attachment.html From Chris.Barker at noaa.gov Tue Dec 13 18:25:46 2005 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Tue, 13 Dec 2005 09:25:46 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <4398A2FD.4060400@anvil.nrl.navy.mil> References: <4398A2FD.4060400@anvil.nrl.navy.mil> Message-ID: <200512130925.46731.Chris.Barker@noaa.gov> Hi Lou, I'm glad you got this working. Thanks for posting the resolution to your problems, it's good to have this stuff archived. If time permits, I hope top do some SWIGing myself, so perhaps we can help each other out. On Thursday 08 December 2005 1:17 pm, Louis Pecora wrote: > Solution: directories (folders) and files with spaces and special > Mac symbols (e.g. option-whatever) can cause problems. Yup. Technically, a file name on *nix can have any charactor in it except a "/", so many utilities use space to separate things that it's hard for things to work right with them in there. I spend most of my time on Linux, so I'm not in the habit of using spaces in file names anyway. > setenv CC g++ > > in my login file .tschrc which I got from a colleague. The dangers of borrowing other people's code! Why are you using tsch anyway? bash really is nicer, unless you're really used to a C shell. And it's the OS-X default (and most Linuxes also). Setting CC to g++ is a very odd thing to do. It's going to break a lot of make files, CC should be a C compiler! > I changed it to > setenv CC gcc You should probably just not set it to anything. gcc should be the default anyway. On my system, /usr/bin/CC is a link to gcc-3.3 > (3) running 'make install' would not work since I had no permission to > write in some directories. I don't fully understand this since I am the > admin and I was running logged in as such, but to no avail. > Solution: run this as > > sudo make install This is VERY standard stuff. I think I recall you're having a hard time transitioning to the multi-user environment of OS-X a few years back, and having some discussion about it on the MacPython list...or maybe that was someone else. OS-X has the best system for dealing with this I've seen. By default, it is set up so that it is impossible to be logged in as the root user (unix talk for system administrator). This is a good thing, as the root user can do anything, and it's remarkable easy to make a mess of your system with a typo at the command line. Also, if you're the root user and you acidentally run some malicious code, it can reek havock (not such an issue for OS-X as Windows, but still an issue). However, obviously some things do need to be done with root privileges. This is what sudo (Super User Do) is. It lets you run a single command as the root user. This is good, as it lets you get what you need done, but it makes it very clear that "I am now messing with the system" you can't do it accidentally. When working from the GUI, whenever you need to do something that requires root privileges, a dialog is popped up, asking for your password. Again a clear sign that you are messing with the system. If you were to download a virus accidentally as an email, a dialog would pop up and ask you for your password, and you know immediately that something was going on you didn't expect. So, on OS-X being an "admin" user only means that you are allowed to use sudo. Contrast this with Windows: an "admin" user can do anything, including accidentally run a virus or something that destroys theire system. However, if you run as a non-admin user, then you can't do anything administrative without loggin out, l then back in as the admin. This is a such a pain that many people just run as admin user all the time. couple this with poorly written software that requires you to run as an admin user (we have some of this in-house!) and hardly anyone doesn't run as an admin user, and surprise surprise! viruses galore! Wow! I got carried away with that! > At least I got this far. I'll be interested in what you come up with, I think our needs are similar. -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 Chris.Barker at noaa.gov From pecora at anvil.nrl.navy.mil Tue Dec 13 18:41:54 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 13 Dec 2005 12:41:54 -0500 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <200512130925.46731.Chris.Barker@noaa.gov> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> Message-ID: <439F07E2.1070501@anvil.nrl.navy.mil> Christopher Barker wrote: >Hi Lou, > >I'm glad you got this working. Thanks for posting the resolution to your >problems, it's good to have this stuff archived. If time permits, I hope top >do some SWIGing myself, so perhaps we can help each other out. > > Sounds good to me. I have mostly made the decision to do future projects in Python with the usual profiling and C module extending, hence my need for speed. I settled on SWIG (at least for now) because it seems established and solid and not too complex for me (I am not a comupter guru). I did get a simple example to work so I am on my way. I will be diving into this more in the future. For graphics, I have chosen wxPython. I know there is matplotlib, but using it interactively baffled me (although several nice people sent me examples). I may include it in my toolbox in the future. For now wxPython also also offers event control. I have yet to learn that and I still mostly do print readline kind of I/0 and menus. I keep it simple, but occasionally GUI stuff is useful. >Yup. Technically, a file name on *nix can have any charactor in it except a >"/", so many utilities use space to separate things that it's hard for things >to work right with them in there. I spend most of my time on Linux, so I'm >not in the habit of using spaces in file names anyway. > > Yeah, I am converting my coding directories over to that style. I have capitulated. :-) > >The dangers of borrowing other people's code! Why are you using tsch anyway? >bash really is nicer, unless you're really used to a C shell. And it's the >OS-X default (and most Linuxes also). > > Well, I thought the default was tsch. Shows what I know. I really don't like the tsch scripting language. It's more clumsy so I suppose I should switch. Not sure how to do that, but I'll look it up. >Setting CC to g++ is a very odd thing to do. It's going to break a lot of make >files, CC should be a C compiler! > > Yeah, the dangers of other's login scripts, huh? Well, I switched it to gcc so I assume it should be better now. SWIG workds, at least. > You should probably just not set it to anything. gcc should be the > default > >anyway. On my system, /usr/bin/CC is a link to gcc-3.3 > > > [cut massive invective against Windows admin mode :-) ] >Wow! I got carried away with that! > > Yeah, but it was soooooo good. > I'll be interested in what you come up with, I think our needs are > similar. > > > I'm sure I'll be back. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From wfspotz at sandia.gov Tue Dec 13 18:38:11 2005 From: wfspotz at sandia.gov (Bill Spotz) Date: Tue, 13 Dec 2005 10:38:11 -0700 Subject: [Pythonmac-SIG] Slow python initialization Message-ID: <72ECC910-89A2-4DCF-8F79-E9DC80B8D6AD@sandia.gov> I recently upgraded my dual-processor G5 from Mac OS X 10.3 to 10.4. Ever since, the python initialization has been extremely slow, maybe 10 seconds or so between issuing the "python" command and getting a prompt. I run some automated tests on this machine, and the delays can add up, dwarfing the actual execution time. The problem persists whether I: * Run python 2.4.2 (/sw/bin/python, compiled w/GCC 4.0.0) or 2.3.5 (/usr/bin/python, compiled w/GCC 3.3) * Run with or without a PYTHONSTARTUP file * Run under bash 3.00.0(1) (/sw/bin/bash) or 2.05b.0(1) (/bin/bash) Has anyone else seen this behavior? Or have a solution? (Similarly, although less related to this mailing list, when I try to use tab- completion under bash, I get a long delay as well.) Thanks ** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-5451 ** ** Albuquerque, NM 87185-0316 Email: wfspotz at sandia.gov ** From bob at redivi.com Tue Dec 13 19:01:52 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 10:01:52 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <439F07E2.1070501@anvil.nrl.navy.mil> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> Message-ID: <83A1891E-0C06-4C1D-9D46-40B5C88E1263@redivi.com> On Dec 13, 2005, at 9:41 AM, Louis Pecora wrote: > Christopher Barker wrote: > >> The dangers of borrowing other people's code! Why are you using >> tsch anyway? >> bash really is nicer, unless you're really used to a C shell. And >> it's the >> OS-X default (and most Linuxes also). >> >> > Well, I thought the default was tsch. Shows what I know. I really > don't like the tsch scripting language. It's more clumsy so I > suppose I > should switch. Not sure how to do that, but I'll look it up. man chsh tcsh was the default up to 10.2. bash is the default in 10.3+. -bob From zhiyong_peng2003 at yahoo.com Tue Dec 13 19:02:46 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 10:02:46 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript Message-ID: <20051213180247.56297.qmail@web35311.mail.mud.yahoo.com> Hi! All I posted a few items in a few days. I think the first problem I had is that it can not import python module when I used "from appscrpt import *" inside modue because appscript need pythonw instead of python. Here is the error message: ======================================================== zhi-pengs-power-mac-g5:~/Documents/projects/c-code/pyToDLL/test1 zpeng$ python Python 2.3.5 (#1, Mar 20 2005, 20:38:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import StringModule Traceback (most recent call last): File "", line 1, in ? File "StringModule.py", line 4, in ? from appscript import * File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/appscript/__init__.py", line 14, in ? from specifier import app, CommandError File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/appscript/specifier.py", line 9, in ? import aem File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/aem/__init__.py", line 25, in ? from send import * File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/aem/send/__init__.py", line 105, in ? raise RuntimeError, "Can't send Apple events: no access to Window Manager. (aem-based scripts must be run within a GUI process; e.g. use 'pythonw', not 'python', if running script in shell)" RuntimeError: Can't send Apple events: no access to Window Manager. (aem-based scripts must be run within a GUI process; e.g. use 'pythonw', not 'python', if running script in shell) >>> ==================================================== Does anyone have any ideal on solving the probelm. Thanks in advance. It seems PyImport_ImportModule also use python instead of pythonw. Regards Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From zhiyong_peng2003 at yahoo.com Tue Dec 13 19:03:09 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 10:03:09 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript Message-ID: <20051213180309.63304.qmail@web35303.mail.mud.yahoo.com> Hi! All I posted a few items in a few days. I think the first problem I had is that it can not import python module when I used "from appscrpt import *" inside modue because appscript need pythonw instead of python. Here is the error message: ======================================================== zhi-pengs-power-mac-g5:~/Documents/projects/c-code/pyToDLL/test1 zpeng$ python Python 2.3.5 (#1, Mar 20 2005, 20:38:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import StringModule Traceback (most recent call last): File "", line 1, in ? File "StringModule.py", line 4, in ? from appscript import * File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/appscript/__init__.py", line 14, in ? from specifier import app, CommandError File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/appscript/specifier.py", line 9, in ? import aem File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/aem/__init__.py", line 25, in ? from send import * File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/aem/send/__init__.py", line 105, in ? raise RuntimeError, "Can't send Apple events: no access to Window Manager. (aem-based scripts must be run within a GUI process; e.g. use 'pythonw', not 'python', if running script in shell)" RuntimeError: Can't send Apple events: no access to Window Manager. (aem-based scripts must be run within a GUI process; e.g. use 'pythonw', not 'python', if running script in shell) >>> ==================================================== Does anyone have any ideal on solving the probelm. Thanks in advance. It seems PyImport_ImportModule also use python instead of pythonw. Regards Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From bob at redivi.com Tue Dec 13 19:03:26 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 10:03:26 -0800 Subject: [Pythonmac-SIG] Slow python initialization In-Reply-To: <72ECC910-89A2-4DCF-8F79-E9DC80B8D6AD@sandia.gov> References: <72ECC910-89A2-4DCF-8F79-E9DC80B8D6AD@sandia.gov> Message-ID: <27B64DFA-B17F-4B28-B844-D39C9AB47FB3@redivi.com> On Dec 13, 2005, at 9:38 AM, Bill Spotz wrote: > I recently upgraded my dual-processor G5 from Mac OS X 10.3 to 10.4. > Ever since, the python initialization has been extremely slow, maybe > 10 seconds or so between issuing the "python" command and getting a > prompt. I run some automated tests on this machine, and the delays > can add up, dwarfing the actual execution time. > > The problem persists whether I: > * Run python 2.4.2 (/sw/bin/python, compiled w/GCC 4.0.0) or > 2.3.5 (/usr/bin/python, compiled w/GCC 3.3) > * Run with or without a PYTHONSTARTUP file > * Run under bash 3.00.0(1) (/sw/bin/bash) or 2.05b.0(1) (/bin/ > bash) > > Has anyone else seen this behavior? Or have a solution? (Similarly, > although less related to this mailing list, when I try to use tab- > completion under bash, I get a long delay as well.) No, but I would profile it with Shark to see where it's spending time. Or even just run it under gdb and break when it's stalling.. I'm guessing it's waiting on some kind of resource. -bob From bob at redivi.com Tue Dec 13 19:29:22 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 10:29:22 -0800 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051213180247.56297.qmail@web35311.mail.mud.yahoo.com> References: <20051213180247.56297.qmail@web35311.mail.mud.yahoo.com> Message-ID: On Dec 13, 2005, at 10:02 AM, Zhi Peng wrote: > I posted a few items in a few days. I think the first > problem I had is that it can not import python module > when I used "from appscrpt import *" inside modue > because appscript need pythonw instead of python. Here > is the error message: -- > It seems PyImport_ImportModule also use python instead > of pythonw. You need to create an application bundle to run your application from. pythonw is just a shell script that executes a Python interpreter that lives inside of an application bundle. -bob From managan at llnl.gov Tue Dec 13 19:12:45 2005 From: managan at llnl.gov (Rob Managan) Date: Tue, 13 Dec 2005 10:12:45 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <439F07E2.1070501@anvil.nrl.navy.mil> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> Message-ID: At 12:41 PM -0500 12/13/05, Louis Pecora wrote: >Christopher Barker wrote: > >>Hi Lou, >> >>I'm glad you got this working. Thanks for posting the resolution to your >>problems, it's good to have this stuff archived. If time permits, I hope top >>do some SWIGing myself, so perhaps we can help each other out. >> >> >Sounds good to me. I have mostly made the decision to do future >projects in Python with the usual profiling and C module extending, >hence my need for speed. I settled on SWIG (at least for now) because >it seems established and solid and not too complex for me (I am not a >comupter guru). I did get a simple example to work so I am on my way. >I will be diving into this more in the future. > >For graphics, I have chosen wxPython. I know there is matplotlib, but >using it interactively baffled me (although several nice people sent me >examples). I may include it in my toolbox in the future. For now >wxPython also also offers event control. I have yet to learn that and I >still mostly do print readline kind of I/0 and menus. I keep it >simple, but occasionally GUI stuff is useful. While I have not tried WxPython I have built C modules for python using SWIG and python's distutils. That trades the headaches of makefiles for writing a setup.py file. I can give an example and they really are not that bad once you have done it once! -- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Rob Managan email managan at llnl.gov LLNL phone: 925-423-0903 P.O. Box 808, L-095 FAX: 925-422-3389 Livermore, CA 94551-0808 From managan at llnl.gov Tue Dec 13 19:08:05 2005 From: managan at llnl.gov (Rob Managan) Date: Tue, 13 Dec 2005 10:08:05 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <439F07E2.1070501@anvil.nrl.navy.mil> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> Message-ID: At 12:41 PM -0500 12/13/05, Louis Pecora wrote: >Christopher Barker wrote: > > > >>The dangers of borrowing other people's code! Why are you using tsch anyway? >>bash really is nicer, unless you're really used to a C shell. And it's the >>OS-X default (and most Linuxes also). >> >> >Well, I thought the default was tsch. Shows what I know. I really >don't like the tsch scripting language. It's more clumsy so I suppose I >should switch. Not sure how to do that, but I'll look it up. > Just to clear this up. The default shell in the first version or two of OSX was tcsh. According to http://www.macdevcenter.com/pub/a/mac/2004/02/24/bash.html the change came in going from Jaguar to Panther. If you upgraded from Jaguar to Panther your default shell was not changed. The URL above goes over some of the differences in the shells and how to switch it yourself -- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Rob Managan email managan at llnl.gov LLNL phone: 925-423-0903 P.O. Box 808, L-095 FAX: 925-422-3389 Livermore, CA 94551-0808 From sw at wordtech-software.com Tue Dec 13 19:18:48 2005 From: sw at wordtech-software.com (Kevin Walzer) Date: Tue, 13 Dec 2005 13:18:48 -0500 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051213180309.63304.qmail@web35303.mail.mud.yahoo.com> References: <20051213180309.63304.qmail@web35303.mail.mud.yahoo.com> Message-ID: <439F1088.4080301@wordtech-software.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Zhi Peng wrote: > Hi! All > > I posted a few items in a few days. I think the first > problem I had is that it can not import python module > when I used "from appscrpt import *" inside modue > because appscript need pythonw instead of python. Here > is the error message: > > ======================================================== > > zhi-pengs-power-mac-g5:~/Documents/projects/c-code/pyToDLL/test1 > zpeng$ python > Python 2.3.5 (#1, Mar 20 2005, 20:38:20) > [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] > on darwin > Type "help", "copyright", "credits" or "license" for > more information. >>>> import StringModule > Traceback (most recent call last): > File "", line 1, in ? > File "StringModule.py", line 4, in ? > from appscript import * > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/appscript/__init__.py", > line 14, in ? > from specifier import app, CommandError > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/appscript/specifier.py", > line 9, in ? > import aem > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/aem/__init__.py", > line 25, in ? > from send import * > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/aem/send/__init__.py", > line 105, in ? > raise RuntimeError, "Can't send Apple events: no > access to Window Manager. (aem-based scripts must be > run within a GUI process; e.g. use 'pythonw', not > 'python', if running script in shell)" > RuntimeError: Can't send Apple events: no access to > Window Manager. (aem-based scripts must be run within > a GUI process; e.g. use 'pythonw', not 'python', if > running script in shell) > > ==================================================== > > Does anyone have any ideal on solving the probelm. > Thanks in advance. > > It seems PyImport_ImportModule also use python instead > of pythonw. > > > Regards > > Zhi > On OS X, scripts that have a GUI must be launched with pythonw, not python. If your script uses Tkinter or wxPython, for instance, you would (from the terminal) launch it by saying "pythonw foo.py." Running it with "python foo.py" will produce errors simlilar to the ones you are reporting. Not sure if appscript modules can be run interactively with the Python interpreter/shell--has can chime in here. - -- Cheers, Kevin Walzer, PhD WordTech Software - "Tame the Terminal" http://www.wordtech-software.com sw at wordtech-software.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD4DBQFDnxCHJmdQs+6YVcoRAkPuAJ9C1Ulazs2NQtrNFfFqxnrPGbj3PwCWMez3 HkUHJT3LnISQoDU/QL0fzg== =BLI9 -----END PGP SIGNATURE----- From pecora at anvil.nrl.navy.mil Tue Dec 13 19:39:20 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 13 Dec 2005 13:39:20 -0500 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> Message-ID: <439F1558.4090708@anvil.nrl.navy.mil> Rob Managan wrote: >While I have not tried WxPython I have built C modules for python >using SWIG and python's distutils. That trades the headaches of >makefiles for writing a setup.py file. I can give an example and they >really are not that bad once you have done it once! > > > I will be honest and admit I do not grok disutils. I sense power there, but have not had the guts nor time to explore it. If you have a simple example that is easy to send, please do. Since I will probably be doing more and more with Python, I am trying to expose myself to useful branches of the Python world without becoming overwhelmed. Thanks. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From bob at redivi.com Tue Dec 13 19:44:40 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 10:44:40 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <439F1558.4090708@anvil.nrl.navy.mil> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <439F1558.4090708@anvil.nrl.navy.mil> Message-ID: On Dec 13, 2005, at 10:39 AM, Louis Pecora wrote: > Rob Managan wrote: > >> While I have not tried WxPython I have built C modules for python >> using SWIG and python's distutils. That trades the headaches of >> makefiles for writing a setup.py file. I can give an example and they >> really are not that bad once you have done it once! >> >> >> > I will be honest and admit I do not grok disutils. I sense power > there, > but have not had the guts nor time to explore it. If you have a > simple > example that is easy to send, please do. Since I will probably be > doing > more and more with Python, I am trying to expose myself to useful > branches of the Python world without becoming overwhelmed. You need to understand distutils, or your experience developing Python extensions will be extremely painful. distutils is not at all difficult. The documentation is pretty good, and you can always look at the thousands of setup.py files out there written by other Python developers. Pick a project similar to yours and use its setup.py as a template. Or, you can do everything manually and live a painful existence... especially because the correct linker flags and compiler options are a mile long on Mac OS X and totally different than those from any other platform. -bob From pecora at anvil.nrl.navy.mil Tue Dec 13 20:20:41 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 13 Dec 2005 14:20:41 -0500 Subject: [Pythonmac-SIG] Distutils for research? In-Reply-To: References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <439F1558.4090708@anvil.nrl.navy.mil> Message-ID: <439F1F09.6080707@anvil.nrl.navy.mil> Bob Ippolito wrote: > > On Dec 13, 2005, at 10:39 AM, Louis Pecora wrote: > >> I will be honest and admit I do not grok disutils. I sense power >> there, >> but have not had the guts nor time to explore it. If you have a simple >> example that is easy to send, please do. Since I will probably be >> doing >> more and more with Python, I am trying to expose myself to useful >> branches of the Python world without becoming overwhelmed. > > > You need to understand distutils, or your experience developing > Python extensions will be extremely painful. distutils is not at all > difficult. The documentation is pretty good, and you can always look > at the thousands of setup.py files out there written by other Python > developers. Pick a project similar to yours and use its setup.py as > a template. > > Or, you can do everything manually and live a painful existence... > especially because the correct linker flags and compiler options are > a mile long on Mac OS X and totally different than those from any > other platform. > > -bob Bob or anyone, I have started to look over distutils, but a question immediately comes to mind. With the idea of trying to avoid learning what I don't need, I gotta ask: Is distutils more for distributing packages/modules than developing? I ask that because as a scientific/number-cruncher type I rarely give anyone my code. It's developed for my own use and research which is typical in the research world. Most code is a one-of-a-kind and is constantly tweaked, reworked, and played with to try new ideas. So the big focus is on the development end: Edit, compile, debug, crunch numbers. Anything that cuts time in that part of the cycle is great (hence the interest in Python for RAD and trials of new ideas). Stuff that helps in distribution is of little help because that's rarely the goal. Comments/opinions welcome. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From bob at redivi.com Tue Dec 13 20:28:14 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 11:28:14 -0800 Subject: [Pythonmac-SIG] Distutils for research? In-Reply-To: <439F1F09.6080707@anvil.nrl.navy.mil> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <439F1558.4090708@anvil.nrl.navy.mil> <439F1F09.6080707@anvil.nrl.navy.mil> Message-ID: <3FEA851D-3F06-49AE-8AC3-5E383E948F94@redivi.com> On Dec 13, 2005, at 11:20 AM, Louis Pecora wrote: > Bob Ippolito wrote: > >> >> On Dec 13, 2005, at 10:39 AM, Louis Pecora wrote: >> >>> I will be honest and admit I do not grok disutils. I sense power >>> there, >>> but have not had the guts nor time to explore it. If you have a >>> simple >>> example that is easy to send, please do. Since I will probably be >>> doing >>> more and more with Python, I am trying to expose myself to useful >>> branches of the Python world without becoming overwhelmed. >> >> >> You need to understand distutils, or your experience developing >> Python extensions will be extremely painful. distutils is not at all >> difficult. The documentation is pretty good, and you can always look >> at the thousands of setup.py files out there written by other Python >> developers. Pick a project similar to yours and use its setup.py as >> a template. >> >> Or, you can do everything manually and live a painful existence... >> especially because the correct linker flags and compiler options are >> a mile long on Mac OS X and totally different than those from any >> other platform. >> >> -bob > > Bob or anyone, > > I have started to look over distutils, but a question immediately > comes > to mind. With the idea of trying to avoid learning what I don't > need, > I gotta ask: > > Is distutils more for distributing packages/modules than developing? No, it solves both problems. One of these two will become very familiar to you: (distutils) python setup.py build_ext -i (if using setuptools) python setup.py develop -bob From hengist.podd at virgin.net Tue Dec 13 20:44:21 2005 From: hengist.podd at virgin.net (has) Date: Tue, 13 Dec 2005 19:44:21 +0000 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <439F1088.4080301@wordtech-software.com> References: <20051213180309.63304.qmail@web35303.mail.mud.yahoo.com> <439F1088.4080301@wordtech-software.com> Message-ID: Kevin Walzer wrote: >Not sure if appscript modules can be run interactively with the Python >interpreter/shell--has can chime in here. Sure, as long as you use pythonw. An interactive shell can be quite handy when learning your way around an application's object model; appscript's built-in help() system works very nicely there. has -- http://freespace.virgin.net/hamish.sanderson/ From pecora at anvil.nrl.navy.mil Tue Dec 13 20:50:00 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Tue, 13 Dec 2005 14:50:00 -0500 Subject: [Pythonmac-SIG] Distutils for research? In-Reply-To: <3FEA851D-3F06-49AE-8AC3-5E383E948F94@redivi.com> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <439F1558.4090708@anvil.nrl.navy.mil> <439F1F09.6080707@anvil.nrl.navy.mil> <3FEA851D-3F06-49AE-8AC3-5E383E948F94@redivi.com> Message-ID: <439F25E8.704@anvil.nrl.navy.mil> Bob Ippolito wrote: >> >> Bob or anyone, >> >> I have started to look over distutils, but a question immediately comes >> to mind. With the idea of trying to avoid learning what I don't need, >> I gotta ask: >> >> Is distutils more for distributing packages/modules than developing? > > > No, it solves both problems. One of these two will become very > familiar to you: > > (distutils) > python setup.py build_ext -i > > (if using setuptools) > python setup.py develop > > -bob Dang! I wanted a 'don't waste your time' answer. :-) Thanks. Back to school. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From Benjamin.Schollnick at xerox.com Tue Dec 13 20:36:29 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Tue, 13 Dec 2005 14:36:29 -0500 Subject: [Pythonmac-SIG] Distutils for research? Message-ID: <266589E1B9392B4C9195CC25A07C73B90183D1DE@usa0300ms04.na.xerox.net> > Is distutils more for distributing packages/modules than developing? The only situation I use distutils is for installing packages/modules, and distributing the software that I write (via py2app & py2exe). To my knowledge distutils is primarily for distributing packages & modules... Someone please correct us if we are wrong. - Ben From bob at redivi.com Tue Dec 13 21:12:09 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 12:12:09 -0800 Subject: [Pythonmac-SIG] Distutils for research? In-Reply-To: <266589E1B9392B4C9195CC25A07C73B90183D1DE@usa0300ms04.na.xerox.net> References: <266589E1B9392B4C9195CC25A07C73B90183D1DE@usa0300ms04.na.xerox.net> Message-ID: <8A421454-D4B3-4227-99FB-6BA5A178FB84@redivi.com> On Dec 13, 2005, at 11:36 AM, Schollnick, Benjamin wrote: > >> Is distutils more for distributing packages/modules than developing? > > The only situation I use distutils is for installing packages/modules, > and distributing the software that I write (via py2app & py2exe). > > To my knowledge distutils is primarily for distributing packages & > modules... It's the only good way to compile extensions, which makes it infinitely useful for extension development as well. However, setuptools is also useful for pure Python development, because setup.py develop goes ahead and checks all your dependencies and adds your working copy to sys.path (ensuring that it doesn't conflict with something already installed). Normally I would manually generate a pth file to add my working copy to sys.path, but creating a minimal setup.py is easier than dealing with any of that. It can also create scripts via entry points, which saves more time. crack:~/src/MyPackage bob$ cd ~ crack:~ bob$ mkdir -p src/MyPackage/MyPackage crack:~ bob$ cd src/MyPackage crack:~/src/MyPackage bob$ touch MyPackage/__init__.py crack:~/src/MyPackage bob$ cat - > setup.py #!/usr/bin/env python from setuptools import setup, find_packages setup(name="MyPackage", version="1.0", packages=find_packages()) crack:~/src/MyPackage bob$ python setup.py develop running develop running egg_info creating MyPackage.egg-info writing ./MyPackage.egg-info/PKG-INFO writing top-level names to ./MyPackage.egg-info/top_level.txt running build_ext Creating /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/site-packages/MyPackage.egg-link (link to .) Adding MyPackage 1.0 to easy-install.pth file Installed /Volumes/Crack/src/MyPackage Processing dependencies for MyPackage==1.0 crack:~/src/MyPackage bob$ cd ~ crack:~ bob$ python -c "import MyPackage; print MyPackage.__file__" /Volumes/Crack/src/MyPackage/MyPackage/__init__.py -bob From bob at redivi.com Tue Dec 13 21:18:33 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 12:18:33 -0800 Subject: [Pythonmac-SIG] Distutils for research? In-Reply-To: <8A421454-D4B3-4227-99FB-6BA5A178FB84@redivi.com> References: <266589E1B9392B4C9195CC25A07C73B90183D1DE@usa0300ms04.na.xerox.net> <8A421454-D4B3-4227-99FB-6BA5A178FB84@redivi.com> Message-ID: <46CD5EF9-17F8-401A-BCEC-316469686B70@redivi.com> On Dec 13, 2005, at 12:12 PM, Bob Ippolito wrote: > > On Dec 13, 2005, at 11:36 AM, Schollnick, Benjamin wrote: > >> >>> Is distutils more for distributing packages/modules than developing? >> >> The only situation I use distutils is for installing packages/ >> modules, >> and distributing the software that I write (via py2app & py2exe). >> >> To my knowledge distutils is primarily for distributing packages & >> modules... > > It's the only good way to compile extensions, which makes it > infinitely useful for extension development as well. > > However, setuptools is also useful for pure Python development, > because setup.py develop goes ahead and checks all your dependencies > and adds your working copy to sys.path (ensuring that it doesn't > conflict with something already installed). Normally I would > manually generate a pth file to add my working copy to sys.path, but > creating a minimal setup.py is easier than dealing with any of that. > It can also create scripts via entry points, which saves more time. > > crack:~/src/MyPackage bob$ cd ~ > crack:~ bob$ mkdir -p src/MyPackage/MyPackage > crack:~ bob$ cd src/MyPackage > crack:~/src/MyPackage bob$ touch MyPackage/__init__.py > crack:~/src/MyPackage bob$ cat - > setup.py > #!/usr/bin/env python > from setuptools import setup, find_packages > setup(name="MyPackage", version="1.0", packages=find_packages()) > crack:~/src/MyPackage bob$ python setup.py develop > running develop > running egg_info > creating MyPackage.egg-info > writing ./MyPackage.egg-info/PKG-INFO > writing top-level names to ./MyPackage.egg-info/top_level.txt > running build_ext > Creating /Library/Frameworks/Python.framework/Versions/2.4/lib/ > python2.4/site-packages/MyPackage.egg-link (link to .) > Adding MyPackage 1.0 to easy-install.pth file > > Installed /Volumes/Crack/src/MyPackage > Processing dependencies for MyPackage==1.0 > crack:~/src/MyPackage bob$ cd ~ > crack:~ bob$ python -c "import MyPackage; print MyPackage.__file__" > /Volumes/Crack/src/MyPackage/MyPackage/__init__.py One thing I forgot to mention, is that setuptools also provides for painless uninstallation. crack:~/src/MyPackage bob$ python setup.py develop -u running develop Removing /Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/site-packages/MyPackage.egg-link (link to .) Removing MyPackage 1.0 from easy-install.pth file crack:~/src/MyPackage bob$ cd ~ crack:~ bob$ python -c "import MyPackage; print MyPackage.__file__" Traceback (most recent call last): File "", line 1, in ? ImportError: No module named MyPackage -bob From zhiyong_peng2003 at yahoo.com Tue Dec 13 21:18:50 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 12:18:50 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: Message-ID: <20051213201850.18022.qmail@web35302.mail.mud.yahoo.com> First of all, Thanks 'Has"'s help during past months. If we use pythonw, then there may be problem in C code to call the python code with appscript inside because it seems PyImport_ImportModule("ModuleName") only works with python instead of pythonw. By the way, I have another question for HAS. For example, I create a textFrame on InDesign as following textFrame = id.make(new=k.text_frame, at=myDoc.page[1],with_properties={k.geometric_bounds:["14p0","7p0","50p0","45p0"]}) then how could I get the geometric_bounds if I have textFrame object? Say textFrame has properties: geometric_bounds, contents etc Thanks Zhi has wrote: Kevin Walzer wrote: >Not sure if appscript modules can be run interactively with the Python >interpreter/shell--has can chime in here. Sure, as long as you use pythonw. An interactive shell can be quite handy when learning your way around an application's object model; appscript's built-in help() system works very nicely there. has -- http://freespace.virgin.net/hamish.sanderson/ _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG at python.org http://mail.python.org/mailman/listinfo/pythonmac-sig --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/e7f4b203/attachment.htm From bob at redivi.com Tue Dec 13 21:34:21 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 12:34:21 -0800 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051213201850.18022.qmail@web35302.mail.mud.yahoo.com> References: <20051213201850.18022.qmail@web35302.mail.mud.yahoo.com> Message-ID: <90053DE0-0541-42B3-B6B3-939FE6ABAD9F@redivi.com> On Dec 13, 2005, at 12:18 PM, Zhi Peng wrote: > If we use pythonw, then there may be problem in C code to call the > python code with appscript inside because it seems > PyImport_ImportModule("ModuleName") only works with python instead > of pythonw. pythonw is just a shell script. You're embedding Python, it's not even an option. You must use an application bundle in order to communicate with WindowServer. You probably shouldn't be embedding Python in the first place.. Much easier that way, because py2app can create the application bundle for you, and you don't have to deal with all of the initialization/ finalization for Python. -bob From zhiyong_peng2003 at yahoo.com Tue Dec 13 21:46:08 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 12:46:08 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <90053DE0-0541-42B3-B6B3-939FE6ABAD9F@redivi.com> Message-ID: <20051213204608.39582.qmail@web35315.mail.mud.yahoo.com> Hi! Bob What you suggested is right. The interesting thing is that I have a lot of old c code which will try to call python code. It is true that I can write pure python code and use py2app (I use py2exe on windows) to make an executable. That will make life easy. But .. I think that I need to do something as you said, try to change all C code to python, it may be easier than that I embeded python to C. Thanks all . Zhi Bob Ippolito wrote: On Dec 13, 2005, at 12:18 PM, Zhi Peng wrote: > If we use pythonw, then there may be problem in C code to call the > python code with appscript inside because it seems > PyImport_ImportModule("ModuleName") only works with python instead > of pythonw. pythonw is just a shell script. You're embedding Python, it's not even an option. You must use an application bundle in order to communicate with WindowServer. You probably shouldn't be embedding Python in the first place.. Much easier that way, because py2app can create the application bundle for you, and you don't have to deal with all of the initialization/ finalization for Python. -bob --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/144517dd/attachment.html From bob at redivi.com Tue Dec 13 21:56:45 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 12:56:45 -0800 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051213204608.39582.qmail@web35315.mail.mud.yahoo.com> References: <20051213204608.39582.qmail@web35315.mail.mud.yahoo.com> Message-ID: <851A2231-D6D2-4311-9ECF-D7A5E424F4AC@redivi.com> You don't have to change it all to Python, you just need to refactor it a bit. Instead of embeding Python from C, you embed C from Python. Of course, it's better to prefer Python code because there will be less of it, it's not always a good idea to just throw all the old code away. -bob On Dec 13, 2005, at 12:46 PM, Zhi Peng wrote: > Hi! Bob > > What you suggested is right. > > The interesting thing is that I have a lot of old c code which will > try to call python code. It is true that I can write pure python > code and use py2app (I use py2exe on windows) to make an > executable. That will make life easy. But .. > > I think that I need to do something as you said, try to change all > C code to python, it may be easier than that I embeded python to C. > > Thanks all . > > Zhi > > > > Bob Ippolito wrote: > > On Dec 13, 2005, at 12:18 PM, Zhi Peng wrote: > > > If we use pythonw, then there may be problem in C code to call the > > python code with appscript inside because it seems > > PyImport_ImportModule("ModuleName") only works with python instead > > of pythonw. > > pythonw is just a shell script. You're embedding Python, it's not > even an option. You must use an application bundle in order to > communicate with WindowServer. > > You probably shouldn't be embedding Python in the first place.. Much > easier that way, because py2app can create the application bundle for > you, and you don't have to deal with all of the initialization/ > finalization for Python. > > -bob > > > > > Yahoo! Shopping > Find Great Deals on Holiday Gifts at Yahoo! Shopping > _______________________________________________ > 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/20051213/36a40f19/attachment.htm From wfspotz at sandia.gov Tue Dec 13 21:59:32 2005 From: wfspotz at sandia.gov (Bill Spotz) Date: Tue, 13 Dec 2005 13:59:32 -0700 Subject: [Pythonmac-SIG] Slow python initialization In-Reply-To: <27B64DFA-B17F-4B28-B844-D39C9AB47FB3@redivi.com> References: <72ECC910-89A2-4DCF-8F79-E9DC80B8D6AD@sandia.gov> <27B64DFA-B17F-4B28-B844-D39C9AB47FB3@redivi.com> Message-ID: OK, I seem to be converging on something here, but I don't know what to do with it. Shark gives me the following tree: 97.6% 97.6% mach_kernel memcmp 0.0% 94.3% mach_kernel vfs_addname 0.0% 94.3% mach_kernel hfs_create_attr_btree 0.0% 94.3% mach_kernel BTIterateRecords 0.0% 94.3% mach_kernel hfs_create_attr_btree 0.0% 94.3% mach_kernel MacToVFSError 0.0% 94.3% mach_kernel VNOP_READDIR 0.0% 94.3% mach_kernel getdirentries 0.0% 94.3% mach_kernel unix_syscall 0.0% 94.3% mach_kernel shandler and under gdb when I break, python is in getdirentries(). (This could also indicate my problem with the bash tab-completion.) I am not aware of any other symptoms that would indicate a speed problem with the file system. Any ideas on where I should go from here? Thanks On Dec 13, 2005, at 11:03 AM, Bob Ippolito wrote: > On Dec 13, 2005, at 9:38 AM, Bill Spotz wrote: > >> I recently upgraded my dual-processor G5 from Mac OS X 10.3 to 10.4. >> Ever since, the python initialization has been extremely slow, maybe >> 10 seconds or so between issuing the "python" command and getting a >> prompt. I run some automated tests on this machine, and the delays >> can add up, dwarfing the actual execution time. >> >> The problem persists whether I: >> * Run python 2.4.2 (/sw/bin/python, compiled w/GCC 4.0.0) or >> 2.3.5 (/usr/bin/python, compiled w/GCC 3.3) >> * Run with or without a PYTHONSTARTUP file >> * Run under bash 3.00.0(1) (/sw/bin/bash) or 2.05b.0(1) (/bin/ >> bash) >> >> Has anyone else seen this behavior? Or have a solution? (Similarly, >> although less related to this mailing list, when I try to use tab- >> completion under bash, I get a long delay as well.) > > No, but I would profile it with Shark to see where it's spending > time. Or even just run it under gdb and break when it's stalling.. > I'm guessing it's waiting on some kind of resource. > > -bob From wfspotz at sandia.gov Tue Dec 13 22:01:45 2005 From: wfspotz at sandia.gov (Bill Spotz) Date: Tue, 13 Dec 2005 14:01:45 -0700 Subject: [Pythonmac-SIG] Slow python initialization In-Reply-To: <27B64DFA-B17F-4B28-B844-D39C9AB47FB3@redivi.com> References: <72ECC910-89A2-4DCF-8F79-E9DC80B8D6AD@sandia.gov> <27B64DFA-B17F-4B28-B844-D39C9AB47FB3@redivi.com> Message-ID: OK, I seem to be converging on something here, but I don't know what to do with it. Shark gives me the following tree: 97.6% 97.6% mach_kernel memcmp 0.0% 94.3% mach_kernel vfs_addname 0.0% 94.3% mach_kernel hfs_create_attr_btree 0.0% 94.3% mach_kernel BTIterateRecords 0.0% 94.3% mach_kernel hfs_create_attr_btree 0.0% 94.3% mach_kernel MacToVFSError 0.0% 94.3% mach_kernel VNOP_READDIR 0.0% 94.3% mach_kernel getdirentries 0.0% 94.3% mach_kernel unix_syscall 0.0% 94.3% mach_kernel shandler and under gdb when I break, python is in getdirentries(). (This could also indicate my problem with the bash tab-completion.) On Dec 13, 2005, at 11:03 AM, Bob Ippolito wrote: > On Dec 13, 2005, at 9:38 AM, Bill Spotz wrote: > >> I recently upgraded my dual-processor G5 from Mac OS X 10.3 to 10.4. >> Ever since, the python initialization has been extremely slow, maybe >> 10 seconds or so between issuing the "python" command and getting a >> prompt. I run some automated tests on this machine, and the delays >> can add up, dwarfing the actual execution time. >> >> The problem persists whether I: >> * Run python 2.4.2 (/sw/bin/python, compiled w/GCC 4.0.0) or >> 2.3.5 (/usr/bin/python, compiled w/GCC 3.3) >> * Run with or without a PYTHONSTARTUP file >> * Run under bash 3.00.0(1) (/sw/bin/bash) or 2.05b.0(1) (/bin/ >> bash) >> >> Has anyone else seen this behavior? Or have a solution? (Similarly, >> although less related to this mailing list, when I try to use tab- >> completion under bash, I get a long delay as well.) > > No, but I would profile it with Shark to see where it's spending > time. Or even just run it under gdb and break when it's stalling.. > I'm guessing it's waiting on some kind of resource. > > -bob ** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-5451 ** ** Albuquerque, NM 87185-0316 Email: wfspotz at sandia.gov ** From bob at redivi.com Tue Dec 13 22:13:08 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 13:13:08 -0800 Subject: [Pythonmac-SIG] Slow python initialization In-Reply-To: References: <72ECC910-89A2-4DCF-8F79-E9DC80B8D6AD@sandia.gov> <27B64DFA-B17F-4B28-B844-D39C9AB47FB3@redivi.com> Message-ID: On Dec 13, 2005, at 1:01 PM, Bill Spotz wrote: > OK, I seem to be converging on something here, but I don't know what > to do with it. Shark gives me the following tree: > > 97.6% 97.6% mach_kernel memcmp > 0.0% 94.3% mach_kernel vfs_addname > 0.0% 94.3% mach_kernel hfs_create_attr_btree > 0.0% 94.3% mach_kernel BTIterateRecords > 0.0% 94.3% mach_kernel hfs_create_attr_btree > 0.0% 94.3% mach_kernel MacToVFSError > 0.0% 94.3% mach_kernel VNOP_READDIR > 0.0% 94.3% mach_kernel getdirentries > 0.0% 94.3% mach_kernel unix_syscall > 0.0% 94.3% mach_kernel shandler > > and under gdb when I break, python is in getdirentries(). (This > could also indicate my problem with the bash tab-completion.) You could find out exactly what dir entries it's looking at with ktrace. This might help: http://bob.pythonmac.org/archives/2005/02/04/advanced-debugging- techniques-ktrace/ I'm guessing either you have some GIGANTIC directories, bad sectors on the disk, or that it's doing getdirentries on some remote filesystem.. AFP, NFS, WebDAV (or .mac) maybe? -bob From managan at llnl.gov Tue Dec 13 22:22:34 2005 From: managan at llnl.gov (Rob Managan) Date: Tue, 13 Dec 2005 13:22:34 -0800 Subject: [Pythonmac-SIG] Distutils for research? In-Reply-To: <46CD5EF9-17F8-401A-BCEC-316469686B70@redivi.com> References: <266589E1B9392B4C9195CC25A07C73B90183D1DE@usa0300ms04.na.xerox.net> <8A421454-D4B3-4227-99FB-6BA5A178FB84@redivi.com> <46CD5EF9-17F8-401A-BCEC-316469686B70@redivi.com> Message-ID: Bob Ippolito gives a simple example of using setuptools to develop modules. That got me interested in installing setuptools. I followed the instructions for a non-admin OSX user and created a .pydistutils.cfg file to point to the site-packages is use with raw distutils stuff. Then I tried to use the ex-setup.py file to install setuptools and I get this error. Extracting setuptools-0.6a8-py2.4.egg to /Users/managan/Documents/local/lib/python2.4/site-packages Installing easy_install script to /Library/Frameworks/Python.framework/Versions/2.4/bin error: /Library/Frameworks/Python.framework/Versions/2.4/bin/easy_install: Permission denied Any idea why it is trying to write to /Library/Frameworks/Python.framework/Versions/2.4/bin ?? I tried various -d -i options but could not get it to work right. Any suggestions? At 12:18 PM -0800 12/13/05, Bob Ippolito wrote: > > It's the only good way to compile extensions, which makes it >> infinitely useful for extension development as well. >> >> However, setuptools is also useful for pure Python development, >> because setup.py develop goes ahead and checks all your dependencies >> and adds your working copy to sys.path (ensuring that it doesn't >> conflict with something already installed). Normally I would >> manually generate a pth file to add my working copy to sys.path, but >> creating a minimal setup.py is easier than dealing with any of that. >> It can also create scripts via entry points, which saves more time. >> >> crack:~/src/MyPackage bob$ cd ~ >> crack:~ bob$ mkdir -p src/MyPackage/MyPackage >> crack:~ bob$ cd src/MyPackage >> crack:~/src/MyPackage bob$ touch MyPackage/__init__.py >> crack:~/src/MyPackage bob$ cat - > setup.py > > #!/usr/bin/env python >> from setuptools import setup, find_packages > > setup(name="MyPackage", version="1.0", packages=find_packages()) >> crack:~/src/MyPackage bob$ python setup.py develop >> running develop >> running egg_info >> creating MyPackage.egg-info >> writing ./MyPackage.egg-info/PKG-INFO >> writing top-level names to ./MyPackage.egg-info/top_level.txt >> running build_ext >> Creating /Library/Frameworks/Python.framework/Versions/2.4/lib/ >> python2.4/site-packages/MyPackage.egg-link (link to .) >> Adding MyPackage 1.0 to easy-install.pth file >> >> Installed /Volumes/Crack/src/MyPackage >> Processing dependencies for MyPackage==1.0 >> crack:~/src/MyPackage bob$ cd ~ >> crack:~ bob$ python -c "import MyPackage; print MyPackage.__file__" > > /Volumes/Crack/src/MyPackage/MyPackage/__init__.py > -- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Rob Managan email managan at llnl.gov LLNL phone: 925-423-0903 P.O. Box 808, L-095 FAX: 925-422-3389 Livermore, CA 94551-0808 From zhiyong_peng2003 at yahoo.com Tue Dec 13 22:30:12 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 13:30:12 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <851A2231-D6D2-4311-9ECF-D7A5E424F4AC@redivi.com> Message-ID: <20051213213012.79928.qmail@web35304.mail.mud.yahoo.com> Bob Actually there is only one step away, that is, pythonw and python. With python, I can import modules by using PyImport_ImportModule("name"). But I have to use pythonw since I used appscript. Then I can not import modules sucessfully with same commands. If converting C code to python, there will be a lot of changes too because C is strict typed language while python everything is Object. I have to make .so or .dylib in order to allow python code to call C code. That will be still a lot of work. Regards Zhi Bob Ippolito wrote: You don't have to change it all to Python, you just need to refactor it a bit.? Instead of embeding Python from C, you embed C from Python.? Of course, it's better to prefer Python code because there will be less of it, it's not always a good idea to just throw all the old code away. -bob On Dec 13, 2005, at 12:46 PM, Zhi Peng wrote: Hi! Bob ? What you suggested is right. ? The interesting thing is that I have a lot of old c code which will try to call python code. It is true that I can write pure python code and use py2app (I use py2exe on windows) to make an executable. That? will make life easy. But .. ? I think that I need to do something as you said, try to change all C code to python, it may be easier than that I embeded python to C. ? Thanks all . ? Zhi ? Bob Ippolito wrote: On Dec 13, 2005, at 12:18 PM, Zhi Peng wrote: > If we use pythonw, then there may be problem in C code to call the > python code with appscript inside because it seems > PyImport_ImportModule("ModuleName") only works with python instead > of pythonw. pythonw is just a shell script. You're embedding Python, it's not even an option. You must use an application bundle in order to communicate with WindowServer. You probably shouldn't be embedding Python in the first place.. Much easier that way, because py2app can create the application bundle for you, and you don't have to deal with all of the initialization/ finalization for Python. -bob --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping _______________________________________________ Pythonmac-SIG maillist? -? Pythonmac-SIG at python.org http://mail.python.org/mailman/listinfo/pythonmac-sig --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/6c54ae8e/attachment-0001.htm From bob at redivi.com Tue Dec 13 22:31:44 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 13:31:44 -0800 Subject: [Pythonmac-SIG] Distutils for research? In-Reply-To: References: <266589E1B9392B4C9195CC25A07C73B90183D1DE@usa0300ms04.na.xerox.net> <8A421454-D4B3-4227-99FB-6BA5A178FB84@redivi.com> <46CD5EF9-17F8-401A-BCEC-316469686B70@redivi.com> Message-ID: On Dec 13, 2005, at 1:22 PM, Rob Managan wrote: > Bob Ippolito gives a simple example of using setuptools to develop > modules. That got me interested in installing setuptools. I followed > the instructions for a non-admin OSX user and created a > .pydistutils.cfg file to point to the site-packages is use with raw > distutils stuff. Then I tried to use the ex-setup.py file to install > setuptools and I get this error. > > Extracting setuptools-0.6a8-py2.4.egg to > /Users/managan/Documents/local/lib/python2.4/site-packages > Installing easy_install script to > /Library/Frameworks/Python.framework/Versions/2.4/bin > error: > /Library/Frameworks/Python.framework/Versions/2.4/bin/easy_install: > Permission denied > > > Any idea why it is trying to write to > /Library/Frameworks/Python.framework/Versions/2.4/bin ?? > > I tried various -d -i options but could not get it to work right. That's where scripts get installed ($PREFIX/bin). You probably forgot to set install_scripts to something else in .pydistutils.cfg -bob From bob at redivi.com Tue Dec 13 22:55:06 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 13:55:06 -0800 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051213213012.79928.qmail@web35304.mail.mud.yahoo.com> References: <20051213213012.79928.qmail@web35304.mail.mud.yahoo.com> Message-ID: <53743457-A6A4-44E1-8ADC-71254365E031@redivi.com> On Dec 13, 2005, at 1:30 PM, Zhi Peng wrote: > Actually there is only one step away, that is, pythonw and python. > With python, I can import modules by using PyImport_ImportModule > ("name"). But I have to use pythonw since I used appscript. Then I > can not import modules sucessfully with same commands. No. As I've said three or four times already in this thread, that is not an option because pythonw doesn't exist. It's just a shell script that starts the Python interpreter from within an application bundle. It's the exact same interpreter that is used when you type python, it's just symlinked to somewhere else. To get that behavior you MUST use an application bundle. It's a simple matter of creating a few directories and an Info.plist and putting your application in there. Quite trivial if you're using Xcode because it's got support for application bundles, where the normal GCC toolchain does not. > If converting C code to python, there will be a lot of changes too > because C is strict typed language while python everything is > Object. I have to make .so or .dylib in order to allow python code > to call C code. That will be still a lot of work. No, it's not a lot of changes. Trivially you could remove your Python initialization/finalization code and change the rest of main() to be callable from Python and turn that into an extension module. 20-30 minutes work at most. That would solve the immediate problem because you wouldn't be embedding Python anymore. -bob From wfspotz at sandia.gov Tue Dec 13 23:53:44 2005 From: wfspotz at sandia.gov (Bill Spotz) Date: Tue, 13 Dec 2005 15:53:44 -0700 Subject: [Pythonmac-SIG] Slow python initialization In-Reply-To: <17311.15221.214174.710829@terry.jones.tc> References: <72ECC910-89A2-4DCF-8F79-E9DC80B8D6AD@sandia.gov> <27B64DFA-B17F-4B28-B844-D39C9AB47FB3@redivi.com> <17311.15221.214174.710829@terry.jones.tc> Message-ID: <34A44600-2139-4856-BF15-502A20D53518@sandia.gov> Suspecting the hard drive, I ran Disk Utility on it from another startup disk. The Disk Repair option found, among other things, a large number of orphaned nodes (inodes?) whose names started with "temp" and repaired them. Whatever it did, it seems to have fixed my problem. Thanks. On Dec 13, 2005, at 2:21 PM, Terry Jones wrote: > Hi Bill > >>>>>> "Bob" == Bob Ippolito writes: > Bob> I'm guessing either you have some GIGANTIC directories, bad > sectors on > Bob> the disk, or that it's doing getdirentries on some remote > Bob> filesystem.. AFP, NFS, WebDAV (or .mac) maybe? > > You might also want to bring up /Applications/Utilities/Disk > Utility.app > and click on the drive (the parent of any volumes you'll see > listed). What > is the S.M.A.R.T. status displayed as at the bottom? > > I don't know how to interpret the status, but if it doesn't say > 'Verified' > you may have a drive problem. The above was suggested to me by a > friend at > Apple when I ran into a problem perhaps related to yours. Eventually I > found that a system .h file had some kind of disk error. It was > slowing and > breaking compiles. I moved it aside, got a copy of the file from > elsewhere, and everything has been fine since. (My SMART status was > Verified btw) > > Terry From zhiyong_peng2003 at yahoo.com Wed Dec 14 00:59:40 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 15:59:40 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <53743457-A6A4-44E1-8ADC-71254365E031@redivi.com> Message-ID: <20051213235940.94194.qmail@web35301.mail.mud.yahoo.com> Hi! Bob As I tried to make shared dynamic library, ld command shows some error message ld: Undefined symbols: dyld_stub_binding_helper I do not know which lib including this "dyld_stub_binding_helper" even though I used "nm" to find it. The list libs that I used is -L/usr/lib -L/usr/local/lib -lpython -lc -lm -lSystemStubs -lSystem_profile It may need more lib? anyone knoew. This may be old problem that people had. Thanks Zhi Bob Ippolito wrote: On Dec 13, 2005, at 1:30 PM, Zhi Peng wrote: > Actually there is only one step away, that is, pythonw and python. > With python, I can import modules by using PyImport_ImportModule > ("name"). But I have to use pythonw since I used appscript. Then I > can not import modules sucessfully with same commands. No. As I've said three or four times already in this thread, that is not an option because pythonw doesn't exist. It's just a shell script that starts the Python interpreter from within an application bundle. It's the exact same interpreter that is used when you type python, it's just symlinked to somewhere else. To get that behavior you MUST use an application bundle. It's a simple matter of creating a few directories and an Info.plist and putting your application in there. Quite trivial if you're using Xcode because it's got support for application bundles, where the normal GCC toolchain does not. > If converting C code to python, there will be a lot of changes too > because C is strict typed language while python everything is > Object. I have to make .so or .dylib in order to allow python code > to call C code. That will be still a lot of work. No, it's not a lot of changes. Trivially you could remove your Python initialization/finalization code and change the rest of main() to be callable from Python and turn that into an extension module. 20-30 minutes work at most. That would solve the immediate problem because you wouldn't be embedding Python anymore. -bob --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/02bc96d8/attachment.htm From bob at redivi.com Wed Dec 14 01:09:22 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 16:09:22 -0800 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051213235940.94194.qmail@web35301.mail.mud.yahoo.com> References: <20051213235940.94194.qmail@web35301.mail.mud.yahoo.com> Message-ID: On Dec 13, 2005, at 3:59 PM, Zhi Peng wrote: > As I tried to make shared dynamic library, ld command shows some > error message > > ld: Undefined symbols: > dyld_stub_binding_helper > > I do not know which lib including this "dyld_stub_binding_helper" > even though I used "nm" to find it. The list libs that I used is > -L/usr/lib -L/usr/local/lib -lpython -lc -lm -lSystemStubs - > lSystem_profile > > It may need more lib? anyone knoew. This may be old problem that > people had. Use distutils to compile extensions. Don't try and do it manually. -bob From zhiyong_peng2003 at yahoo.com Wed Dec 14 01:45:52 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 16:45:52 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: Message-ID: <20051214004552.77541.qmail@web35308.mail.mud.yahoo.com> See if I go the right direction. On Wed, I will use my old code to build .so file which is run on Linux. See what happen. I used swig and get name.so file and get rid of error message. When I start python or pythonw and import name from command line, it just hang there. It is interesting (not show any error). I would rather write a little more code on this part. On Linux, it generate name.so, is it same name style on MAc ? any difference? Thanks Bob and others. Regards Zhi Bob Ippolito wrote: On Dec 13, 2005, at 3:59 PM, Zhi Peng wrote: > As I tried to make shared dynamic library, ld command shows some > error message > > ld: Undefined symbols: > dyld_stub_binding_helper > > I do not know which lib including this "dyld_stub_binding_helper" > even though I used "nm" to find it. The list libs that I used is > -L/usr/lib -L/usr/local/lib -lpython -lc -lm -lSystemStubs - > lSystem_profile > > It may need more lib? anyone knoew. This may be old problem that > people had. Use distutils to compile extensions. Don't try and do it manually. -bob --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/1039f15c/attachment.htm From bob at redivi.com Wed Dec 14 01:53:41 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 13 Dec 2005 16:53:41 -0800 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051214004552.77541.qmail@web35308.mail.mud.yahoo.com> References: <20051214004552.77541.qmail@web35308.mail.mud.yahoo.com> Message-ID: <77FC8268-C618-435D-BC07-88E49EB0BF6F@redivi.com> On Dec 13, 2005, at 4:45 PM, Zhi Peng wrote: > See if I go the right direction. > > On Wed, I will use my old code to build .so file which is run on > Linux. See what happen. > > I used swig and get name.so file and get rid of error message. When > I start python or pythonw and import name > from command line, it just hang there. It is interesting (not show > any error). I would rather write a little more code on this part. > On Linux, it generate name.so, is it same name style on MAc ? any > difference? Thanks Bob and others. > Use distutils, it knows how to build extensions on all platforms. If you're not using distutils, then you'll almost certainly do something incorrectly. Distutils knows better than you which compiler and linker options to use for linking extensions. Yes, the naming convention for Python extensions on Linux and Mac OS X happens to be the same. The actual extension binaries are going to be very different and totally incompatible though. -bob From fairwinds at eastlink.ca Wed Dec 14 03:43:41 2005 From: fairwinds at eastlink.ca (David Pratt) Date: Tue, 13 Dec 2005 22:43:41 -0400 Subject: [Pythonmac-SIG] WebKitCtl on wxpython 2.6 Message-ID: <439F86DD.8010807@eastlink.ca> Hi. I am wondering if anyone has a working example of using a WebKitCtl for Mac with wxpython. I am wanting HTMLWindow functionality but have not been able to create an instance. Many thanks. David From zhiyong_peng2003 at yahoo.com Wed Dec 14 04:24:02 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 13 Dec 2005 19:24:02 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <77FC8268-C618-435D-BC07-88E49EB0BF6F@redivi.com> Message-ID: <20051214032402.22020.qmail@web35303.mail.mud.yahoo.com> If part of all code can be compiled as .so library on Mac and also be imported by python, it will be ideal case. As I tried swig utility, it seems it does not work well on Mac. It does not show the error message. I do not know the reason. The compile and ld linker seems fine. I would like to have a small C code and then compile and linked as dynamic library so that it can be imported by python code as we had in Linux platform. I have not tried it completely. except by swig. Mac terminal looks like unix/linux, but there are some difference, which I may not know enough. In C code, all argumnet, parameters have to be changed to in PyObject form, otherwise, python code may not be able to call the function. Not sure if anyone trys swig utility on other platform? on swig home page, there is an example, it might work on linux/unix. But it does not work well on Mac as I tried it. Thanks for all info and help. Zhi Bob Ippolito wrote: Bob Ippolito wrote: On Dec 13, 2005, at 4:45 PM, Zhi Peng wrote: > See if I go the right direction. > > On Wed, I will use my old code to build .so file which is run on > Linux. See what happen. > > I used swig and get name.so file and get rid of error message. When > I start python or pythonw and import name > from command line, it just hang there. It is interesting (not show > any error). I would rather write a little more code on this part. > On Linux, it generate name.so, is it same name style on MAc ? any > difference? Thanks Bob and others. > Use distutils, it knows how to build extensions on all platforms. If you're not using distutils, then you'll almost certainly do something incorrectly. Distutils knows better than you which compiler and linker options to use for linking extensions. Yes, the naming convention for Python extensions on Linux and Mac OS X happens to be the same. The actual extension binaries are going to be very different and totally incompatible though. -bob --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/8c18c74d/attachment.htm From Chris.Barker at noaa.gov Wed Dec 14 18:55:55 2005 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 14 Dec 2005 09:55:55 -0800 Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <20051214032402.22020.qmail@web35303.mail.mud.yahoo.com> References: <20051214032402.22020.qmail@web35303.mail.mud.yahoo.com> Message-ID: <200512140955.55370.Chris.Barker@noaa.gov> On Tuesday 13 December 2005 7:24 pm, Zhi Peng wrote: > I would like > to have a small C code and then compile and linked as dynamic library so > that it can be imported by python code as we had in Linux platform. Are you doing exactly the same thing on OS-X and Linux? Are you using distutils to compile your *.so? If so, it should work. > Mac terminal looks like unix/linux, but there are some difference, which > I may not know enough. The differences, as far as this is concerned, are: * that OS-X requires different flags and what not for compiling and linking -- distutils should take care of that for you * Any GUI program needs to be run from inside an application bundle. This is true for pure C / C++ programs as well. For Python, pythonw does that for you. > In C code, all argumnet, parameters have to be > changed to in PyObject form, otherwise, python code may not be able to call > the function. This makes it sound like you are doing more than trying to get an extension that works on Linux to work on the mac. Yes, extensions can only recieve and return PyObjects to/from Python code, but inside your extension you jsut write regular old C. SWIG is one way to generate code that translates C types into PyObjects. You can also do it by hand (or use pyrex, Boost::python, SIP, etc.). > Not sure if anyone trys swig utility on other platform? I've used it on Linux only, but it certainly works on OS-X. wxPython is built with it, for a large-scale example! > on > swig home page, there is an example, it might work on linux/unix. But it > does not work well on Mac as I tried it. post that example, if we are to help you, that's exactly what we need, a simple example. And post exactly what you did to compile it! -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 Chris.Barker at noaa.gov From Chris.Barker at noaa.gov Wed Dec 14 19:15:40 2005 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 14 Dec 2005 10:15:40 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <439F07E2.1070501@anvil.nrl.navy.mil> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> Message-ID: <200512141015.40814.Chris.Barker@noaa.gov> HI all, Perhaps this is getting bit off-topic, but other seemed interested, so here goes. By the way, I didn't intend to send my whole diatribe about Windows security to the list, sorry about that. On Tuesday 13 December 2005 9:41 am, Louis Pecora wrote: > For graphics, I have chosen wxPython. I know there is matplotlib, but > using it interactively baffled me (although several nice people sent me > examples). I may include it in my toolbox in the future. Well, matplotlib and wxPython solve very different problems. MPL by itself is not intended to build applications with. to do that, you use another GUI toolkit (wxPython, PyGtk, TkInter), and if you need plotting, you can embedd MPL windows in your app. There has been a long recent thread about doing this with wxPython on the MPL list recently. If you need plotting in your apps, be sure to read it. You might also want to check out wx.lib.floatcanvas. It's designed to display and interact with data in arbitrary floating point coordinates. It provides zooming and panning and simple projections(for maps). It could be useful. If it looks like it is, let me know and I'll send you the latest version and some more examples of how to use it (I wrote it). > I have yet to learn that and I > still mostly do print readline kind of I/0 and menus. I keep it > simple, but occasionally GUI stuff is useful. Yes, it is, but it takes a lot longer to write GUI code than simple raw0input calls! Get yourself on the wxPython-users list. In particular, check the recent threads initiated by Rich Shepard. he's like you: A scientist without a whole lot of CS background, learning wxPython for apps to drive his models. > Yeah, the dangers of other's login scripts, huh? Well, I switched it to > gcc so I assume it should be better now. I'd remove that setenv call altogether, It might override Apple's defaults, and break other things. If you switch to bash, that will kill it. Then you'll probably need a .profile file with at least this in it: export PATH="$PATH:/usr/local/bin" or export PATH="/usr/local/bin:$PATH" depending on whether you want your stuff or Apple's as default in your shell. Rob Managan wrote: > While I have not tried WxPython I have built C modules for python > using SWIG and python's distutils. That trades the headaches of > makefiles for writing a setup.py file. I can give an example and they > really are not that bad once you have done it once! I'd love to see an example. Does it run SWIG for you too? > Is distutils more for distributing packages/modules than developing? Absolutely necessary for developing extensions. And not hard for simple set-ups. Bob Ippolito wrote: > However, setuptools is also useful for pure Python development, ? Bob, what do you see as the future of setuptools? Will in be in the standard lib in future versions? -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 Chris.Barker at noaa.gov From managan at llnl.gov Wed Dec 14 19:43:24 2005 From: managan at llnl.gov (Rob Managan) Date: Wed, 14 Dec 2005 10:43:24 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <200512141015.40814.Chris.Barker@noaa.gov> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <200512141015.40814.Chris.Barker@noaa.gov> Message-ID: > >I'd love to see an example. Does it run SWIG for you too? > > > Is distutils more for distributing packages/modules than developing? > YES! I have not gotten Ippolito's reference to setuptools working yet on my system but I do have a setup.py that runs SWIG. Distutils has limited support for SWIG in it. The problem is that SWIG gets run (and creates the shadow .py file) after distutils has already handled .py files. So you have to either do "python setup.py" twice or explicitly do "python setup.py build_ext install" so that the build_ext command runs SWIG and builds the extension module and then install goes back and copies everything where it needs to go. Here is a simple setup.py for this (somewhat modified from mine to make it generic but it should work). If you need to add source files beyond what SWIG produces I think you add them to the list that has "package + '.i'" in it. #!/usr/bin/env python from distutils.core import setup, Extension # package is the the module name and the name of the SWIG .i file # Probably good to use the same in py_modules at the bottom. package = 'mymodule' version = '0.1' # add any directories to search for include files include_dirs = ['../src',] # add any directories to search for libraries lib_dirs = ['.',] # add any libraries name to link against libraries = ['readline','termcap','X11'] #extra_comp_args = [] extra_comp_args = ['-Wno-strict-prototypes',] setup(name = package, version = version, description = '', author = 'My Name', author_email = 'myname at somewhere.com', url = 'http://', ext_modules = [Extension('_'+package, [package+'.i'], include_dirs=include_dirs, library_dirs=lib_dirs, libraries=libraries, extra_compile_args=extra_comp_args, )], py_modules = ['mymodule',] ) -- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Rob Managan email managan at llnl.gov LLNL phone: 925-423-0903 P.O. Box 808, L-095 FAX: 925-422-3389 Livermore, CA 94551-0808 From pecora at anvil.nrl.navy.mil Wed Dec 14 20:13:44 2005 From: pecora at anvil.nrl.navy.mil (Louis Pecora) Date: Wed, 14 Dec 2005 14:13:44 -0500 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <200512141015.40814.Chris.Barker@noaa.gov> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <200512141015.40814.Chris.Barker@noaa.gov> Message-ID: <43A06EE8.40507@anvil.nrl.navy.mil> Christopher Barker wrote: >HI all, > >Perhaps this is getting bit off-topic, but other seemed interested, so here >goes. By the way, I didn't intend to send my whole diatribe about Windows >security to the list, sorry about that. > > Nah. I LOVED it! :-) > Well, matplotlib and wxPython solve very different problems. MPL by > itself is > >not intended to build applications with. to do that, you use another GUI >toolkit (wxPython, PyGtk, TkInter), and if you need plotting, you can embedd >MPL windows in your app. There has been a long recent thread about doing this >with wxPython on the MPL list recently. If you need plotting in your apps, be >sure to read it. > > Thanks will do (if I get some time). >You might also want to check out wx.lib.floatcanvas. It's designed to display >and interact with data in arbitrary floating point coordinates. It provides >zooming and panning and simple projections(for maps). It could be useful. If >it looks like it is, let me know and I'll send you the latest version and >some more examples of how to use it (I wrote it). > > This sounds good. You are a handy guy. >Yes, it is, but it takes a lot longer to write GUI code than simple raw0input >calls! > > Yep. KISS is what I try to do to avoid the last 'S'. :-) >Get yourself on the wxPython-users list. In particular, check the recent >threads initiated by Rich Shepard. he's like you: A scientist without a whole >lot of CS background, learning wxPython for apps to drive his models. > > Yikes! Another email list, but sounds like good info. thanks. >I'd remove that setenv call altogether, It might override Apple's defaults, >and break other things. If you switch to bash, that will kill it. Then you'll >probably need a .profile file with at least this in it: > >export PATH="$PATH:/usr/local/bin" >or >export PATH="/usr/local/bin:$PATH" > >depending on whether you want your stuff or Apple's as default in your shell. > > Got a .profile started already. Thanks. >Rob Managan wrote: > > >>While I have not tried WxPython I have built C modules for python >>using SWIG and python's distutils. That trades the headaches of >>makefiles for writing a setup.py file. I can give an example and they >>really are not that bad once you have done it once! >> >> > >I'd love to see an example. Does it run SWIG for you too? > > It's the example that comes with the Swig down load, called, appropriately, 'example'. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora at anvil.nrl.navy.mil From ronaldoussoren at mac.com Wed Dec 14 21:27:01 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Wed, 14 Dec 2005 21:27:01 +0100 Subject: [Pythonmac-SIG] Framework build of 2.4.2 In-Reply-To: <2CCE06D8-9B2C-4B69-A9BC-32058BC24D4D@samuelsmith.org> References: <564EDA76-9E6C-4FA6-BEAA-337EEE2BB859@redivi.com> <8816571.1130690177069.JavaMail.ronaldoussoren@mac.com> <744C6C61-23F4-4095-AAB7-86495CADC888@redivi.com> <9336895.1130699331637.JavaMail.ronaldoussoren@mac.com> <2mveze2fh1.fsf@starship.python.net> <2CCE06D8-9B2C-4B69-A9BC-32058BC24D4D@samuelsmith.org> Message-ID: On 11-dec-2005, at 21:18, Samuel M. Smith wrote: > I can't find the installer file listed below. Would you care to > share your explicit build steps > so I can build it myself. It appeared from the email exchanges that > you made some fixes? My changes are at https://sourceforge.net/tracker/index.php? func=detail&aid=1380777&group_id=5470&atid=305470 These changes are incomplete. I haven't found a satisfactory solution for dealing with pyconfig.h. This file needs to be patched if you want to build Python on OSX 10.3 yet want to build extensions on OSX 10.4 as well. Ronald > > thanks > > > >> BTW. I finally have a working installer at http://pyobjc.sf.net/ >> software/MacPython-2.4.2-1.dmg. I have barely tested this as of yet. >> >> This includes documentation. Annoyingly it is still necessary to >> install Bob's Tiger fixes if you want to build extensions on Tiger. >> The pyconfig.h created on Panther is not compatible with Tiger, I'll >> see if I can find a good and simple solution for that. The easiest >> solution I can think of right now is shipping the Tiger version of >> pyconfig.h in the installer as well and swapping in the right >> pyconfig during installation. > From smithsm at samuelsmith.org Wed Dec 14 22:33:17 2005 From: smithsm at samuelsmith.org (Samuel M.Smith) Date: Wed, 14 Dec 2005 14:33:17 -0700 Subject: [Pythonmac-SIG] Framework build of 2.4.2 In-Reply-To: References: <564EDA76-9E6C-4FA6-BEAA-337EEE2BB859@redivi.com> <8816571.1130690177069.JavaMail.ronaldoussoren@mac.com> <744C6C61-23F4-4095-AAB7-86495CADC888@redivi.com> <9336895.1130699331637.JavaMail.ronaldoussoren@mac.com> <2mveze2fh1.fsf@starship.python.net> <2CCE06D8-9B2C-4B69-A9BC-32058BC24D4D@samuelsmith.org> Message-ID: thanks. I am not sure how to use your patch. I apply the patch to the python 2.4.2 source and then do a ./ configure, make, make install? I have OS X 10.4.3 On 14 Dec, 2005, at 13:27, Ronald Oussoren wrote: > > On 11-dec-2005, at 21:18, Samuel M. Smith wrote: > >> I can't find the installer file listed below. Would you care to >> share your explicit build steps >> so I can build it myself. It appeared from the email exchanges >> that you made some fixes? > > My changes are at https://sourceforge.net/tracker/index.php? > func=detail&aid=1380777&group_id=5470&atid=305470 > > These changes are incomplete. I haven't found a satisfactory > solution for dealing with pyconfig.h. This file needs to be patched > if you want to build Python on OSX 10.3 yet want to build > extensions on OSX 10.4 as well. > > Ronald From bob at redivi.com Thu Dec 15 01:53:06 2005 From: bob at redivi.com (Bob Ippolito) Date: Wed, 14 Dec 2005 16:53:06 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <200512141015.40814.Chris.Barker@noaa.gov> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <200512141015.40814.Chris.Barker@noaa.gov> Message-ID: <7CECC4FA-8E94-44A8-81DF-BEDB5B4E517B@redivi.com> On Dec 14, 2005, at 10:15 AM, Christopher Barker wrote: > Bob Ippolito wrote: >> However, setuptools is also useful for pure Python development, > > Bob, what do you see as the future of setuptools? Will in be in the > standard > lib in future versions? Not in any immediate future version, but it really doesn't matter. The majority of packages that use setuptools include the ez_install script, which bootstraps the downloading and installation of setuptools if necessary. -bob From bob at redivi.com Thu Dec 15 02:06:39 2005 From: bob at redivi.com (Bob Ippolito) Date: Wed, 14 Dec 2005 17:06:39 -0800 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <7CECC4FA-8E94-44A8-81DF-BEDB5B4E517B@redivi.com> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <200512141015.40814.Chris.Barker@noaa.gov> <7CECC4FA-8E94-44A8-81DF-BEDB5B4E517B@redivi.com> Message-ID: <029CB036-2AA2-4ACC-BEF2-A30AA6F21CBB@redivi.com> On Dec 14, 2005, at 4:53 PM, Bob Ippolito wrote: > > On Dec 14, 2005, at 10:15 AM, Christopher Barker wrote: > >> Bob Ippolito wrote: >>> However, setuptools is also useful for pure Python development, >> >> Bob, what do you see as the future of setuptools? Will in be in the >> standard >> lib in future versions? > > Not in any immediate future version, but it really doesn't matter. > The majority of packages that use setuptools include the ez_install > script, which bootstraps the downloading and installation of > setuptools if necessary. ez_setup, that is. -bob From zhiyong_peng2003 at yahoo.com Thu Dec 15 03:20:39 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Wed, 14 Dec 2005 18:20:39 -0800 (PST) Subject: [Pythonmac-SIG] py2app for python2.3 Message-ID: <20051215022039.38494.qmail@web35305.mail.mud.yahoo.com> Hi! All I downloaded py2app but it failed in installation. Where can I download the right version for python2.3 on Mac Tiger? Thanks Zhi --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051214/0d327961/attachment.html From zhiyong_peng2003 at yahoo.com Thu Dec 15 03:23:29 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Wed, 14 Dec 2005 18:23:29 -0800 (PST) Subject: [Pythonmac-SIG] pythonw and python with applescript In-Reply-To: <200512140955.55370.Chris.Barker@noaa.gov> Message-ID: <20051215022329.16601.qmail@web35302.mail.mud.yahoo.com> Thanks, Chris I will send my simple example to you later on Zhi Christopher Barker wrote: On Tuesday 13 December 2005 7:24 pm, Zhi Peng wrote: > I would like > to have a small C code and then compile and linked as dynamic library so > that it can be imported by python code as we had in Linux platform. Are you doing exactly the same thing on OS-X and Linux? Are you using distutils to compile your *.so? If so, it should work. > Mac terminal looks like unix/linux, but there are some difference, which > I may not know enough. The differences, as far as this is concerned, are: * that OS-X requires different flags and what not for compiling and linking -- distutils should take care of that for you * Any GUI program needs to be run from inside an application bundle. This is true for pure C / C++ programs as well. For Python, pythonw does that for you. > In C code, all argumnet, parameters have to be > changed to in PyObject form, otherwise, python code may not be able to call > the function. This makes it sound like you are doing more than trying to get an extension that works on Linux to work on the mac. Yes, extensions can only recieve and return PyObjects to/from Python code, but inside your extension you jsut write regular old C. SWIG is one way to generate code that translates C types into PyObjects. You can also do it by hand (or use pyrex, Boost::python, SIP, etc.). > Not sure if anyone trys swig utility on other platform? I've used it on Linux only, but it certainly works on OS-X. wxPython is built with it, for a large-scale example! > on > swig home page, there is an example, it might work on linux/unix. But it > does not work well on Mac as I tried it. post that example, if we are to help you, that's exactly what we need, a simple example. And post exactly what you did to compile it! -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 Chris.Barker at noaa.gov _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG at python.org http://mail.python.org/mailman/listinfo/pythonmac-sig --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051214/9e213157/attachment.htm From bob at redivi.com Thu Dec 15 03:31:25 2005 From: bob at redivi.com (Bob Ippolito) Date: Wed, 14 Dec 2005 18:31:25 -0800 Subject: [Pythonmac-SIG] py2app for python2.3 In-Reply-To: <20051215022039.38494.qmail@web35305.mail.mud.yahoo.com> References: <20051215022039.38494.qmail@web35305.mail.mud.yahoo.com> Message-ID: <51F620C1-BE06-4B45-8A4C-7FE7168C08E1@redivi.com> Where did you get it from, what did you download, what did you type or open, and what failed *specifically*? On Dec 14, 2005, at 6:20 PM, Zhi Peng wrote: > Hi! All > > I downloaded py2app but it failed in installation. Where can I > download the right version for python2.3 on Mac Tiger? Thanks > > > Zhi > > Yahoo! Shopping > Find Great Deals on Holiday Gifts at Yahoo! Shopping > _______________________________________________ > 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/20051214/7d41e91c/attachment.html From ronaldoussoren at mac.com Thu Dec 15 07:46:24 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Thu, 15 Dec 2005 07:46:24 +0100 Subject: [Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X In-Reply-To: <7CECC4FA-8E94-44A8-81DF-BEDB5B4E517B@redivi.com> References: <4398A2FD.4060400@anvil.nrl.navy.mil> <200512130925.46731.Chris.Barker@noaa.gov> <439F07E2.1070501@anvil.nrl.navy.mil> <200512141015.40814.Chris.Barker@noaa.gov> <7CECC4FA-8E94-44A8-81DF-BEDB5B4E517B@redivi.com> Message-ID: <7F6B0DD9-DF2A-4AA5-B6C0-946F9A1FF6E8@mac.com> On 15-dec-2005, at 1:53, Bob Ippolito wrote: > > On Dec 14, 2005, at 10:15 AM, Christopher Barker wrote: > >> Bob Ippolito wrote: >>> However, setuptools is also useful for pure Python development, >> >> Bob, what do you see as the future of setuptools? Will in be in the >> standard >> lib in future versions? > > Not in any immediate future version, but it really doesn't matter. > The majority of packages that use setuptools include the ez_install > script, which bootstraps the downloading and installation of > setuptools if necessary. That's IMHO an important feature of setuptools: it seriously reduces the amount of work you have to do to install packages that are not part of the standard library (especially for packages that have dependencies on other packages). Ronald > > -bob > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From ewestra at wave.co.nz Wed Dec 14 20:36:54 2005 From: ewestra at wave.co.nz (Erik Westra) Date: Thu, 15 Dec 2005 08:36:54 +1300 Subject: [Pythonmac-SIG] py2app uses wrong version of wxPython? Message-ID: Greetings, I've been successfully using py2app for about a year now to build an application bundle out of a large wxPython application I've developed. Recently, I upgraded my development machine to OSX 10.4.2, and installed wxPython 2.6.1.0 and py2app 0.2. I'm using the Apple-supplied Python interpreter (version 2.3.5) and the "TigerPython23Compat.pkg" package to ensure that the Python interpreter finds wxPython 2.6.1.0 instead of the Apple-suppled version 2.5.3. This works fine when my application is run directly from the command- line -- a simple "import wx" correctly imports version 2.6.1.0 and the application runs as normal. However, when I use py2app to create an application bundle, the resulting application starts up, but soon crashes because it's running a completely different version of wxPython -- not version 2.5.3, which would make some sense, but version 2.6.0.1! The weird thing is that I never installed wxPython 2.6.0.1 on my machine -- the /Library/Python/2.3/wx-2.6-mac-ansi/wx/__version__.py file definitely shows the version as 2.6.1.0, and I used "grep" to search for the string "2.6.0.1" in "/Library" and "/System", without success. So I'm at a complete loss to understand how an application bundle created using py2app could use a version of wxPython I never installed. I'm not sure if the problem is an obscure bug in py2app, if something is screwed up in the wxPython 2.6.1.0 library (maybe it includes the wrong version of an .so files or something), or if I've done something stupid to cause the problem myself. But, whatever the cause, it seems very strange that the following code: import wx print wx.__version__ prints "2.6.1.0" when run in the Python interpreter, but prints "2.6.0.1" when run as an application bundle built using py2app. Any suggestions? Note: I'm not using wxversion to choose the version of wxPython to use, so that shouldn't be causing any problems. In case it helps, here's a (simplified) copy of the "setup.py" file I'm using to build the application using py2app: ####################################################################### """ setup.py Simplified py2app setup script for the "Ensemble" application. """ from distutils.core import setup import py2app import sys import os def rmrf(path): """ Delete the given directory tree. """ entries=os.listdir(path) for e in entries: fullname=os.path.join(path,e) if os.path.isdir(fullname): rmrf(fullname) else: os.remove(fullname) os.rmdir(path) def buildApp(): """ Build our standalone application, using py2app. We store our generated Ensemble.app bundle into the ensemble/build-mac/standalone directory. """ if os.path.exists("disk-image"): rmrf("disk-image") os.mkdir("disk-image") os.mkdir("disk-image/dNet Ensemble") sys.path.insert(0, "../framework") # Won't be necessary with py2app v0.1.7 plist = dict( CFBundleIconFile = "Ensemble", CFBundleName = "dNet Ensemble", CFBundleShortVersionString = "2.x", CFBundleGetInfoString = "dNet Ensemble 2.x", CFBundleExecutable = "dNet Ensemble", CFBundleIdentifier = "com.dnet.ensemble", ) app = dict(script="../framework/main.py") setup( app=[app], options={'py2app' : {'bdist_base' : "temp", 'dist_dir' : "disk-image/dNet Ensemble", 'iconfile' : "Ensemble.icns", 'plist' : plist, 'includes' : "requiredModules", }, } ) if __name__ == "__main__": buildApp() ####################################################################### Thanks in advance for any suggestions you may have! - Erik. From bray at sent.com Thu Dec 15 15:08:23 2005 From: bray at sent.com (bray@sent.com) Date: Thu, 15 Dec 2005 08:08:23 -0600 Subject: [Pythonmac-SIG] py2app uses wrong version of wxPython? In-Reply-To: References: Message-ID: <1134655703.13914.249868311@webmail.messagingengine.com> I am not sure if this will helpful to you or not. But I did recall something on VersionSelect, found here . Otherwise, take a look at you environment variables from the command line and compare this to what is set for py2app. Brian From hengist.podd at virgin.net Thu Dec 15 20:07:19 2005 From: hengist.podd at virgin.net (has) Date: Thu, 15 Dec 2005 19:07:19 +0000 Subject: [Pythonmac-SIG] appscript installer 1.2 - looking for feedback Message-ID: Hi folks, Just posted a preview of the next appscript installer package at: http://freespace.virgin.net/hamish.sanderson/Appscript-Installer-1.2.dmg.gz Unfortunately, Nick's too busy with real life work these days so this one's built by me. Contains installers for Python 2.3 and 2.4 on both OS 10.3 and 10.4. I've rearranged some stuff and it's not very polished, but seems to work okay at this end. If a few folk would like to give it a try and let me know if everything's okay or not before I do the official release it would be much appreciated. Thanks, has -- http://freespace.virgin.net/hamish.sanderson/ From kevino at theolliviers.com Fri Dec 16 02:05:58 2005 From: kevino at theolliviers.com (Kevin Ollivier) Date: Thu, 15 Dec 2005 17:05:58 -0800 Subject: [Pythonmac-SIG] py2app uses wrong version of wxPython? In-Reply-To: References: Message-ID: <737D7EB9-5291-47FB-A067-BB02588AD462@theolliviers.com> On Dec 14, 2005, at 11:36 AM, Erik Westra wrote: [snip] > I'm not sure if the problem is an obscure bug in py2app, if something > is screwed up in the wxPython 2.6.1.0 library (maybe it includes the > wrong version of an .so files or something), or if I've done > something stupid to cause the problem myself. But, whatever the > cause, it seems very strange that the following code: > > import wx > print wx.__version__ > > prints "2.6.1.0" when run in the Python interpreter, but prints > "2.6.0.1" when run as an application bundle built using py2app. > > Any suggestions? When you run py2app, the output should indicate exactly where it is getting the wxPython scripts and dlls from. Search the py2app output for any instances of 'wx' in the filename, then track down those locations and see what the wxPython version is there. I've released bundles using 2.6.1.0 so I don't think that in and of itself is the problem here. Thanks, Kevin > Note: I'm not using wxversion to choose the version of wxPython to > use, so that shouldn't be causing any problems. > > In case it helps, here's a (simplified) copy of the "setup.py" file > I'm using to build the application using py2app: > > ###################################################################### > # > > """ setup.py > > Simplified py2app setup script for the "Ensemble" application. > """ > from distutils.core import setup > import py2app > import sys > import os > > > def rmrf(path): > """ Delete the given directory tree. > """ > entries=os.listdir(path) > for e in entries: > fullname=os.path.join(path,e) > if os.path.isdir(fullname): > rmrf(fullname) > else: > os.remove(fullname) > os.rmdir(path) > > > def buildApp(): > """ Build our standalone application, using py2app. > > We store our generated Ensemble.app bundle into the > ensemble/build-mac/standalone directory. > """ > if os.path.exists("disk-image"): > rmrf("disk-image") > > os.mkdir("disk-image") > os.mkdir("disk-image/dNet Ensemble") > > sys.path.insert(0, "../framework") # Won't be necessary with > py2app v0.1.7 > > plist = dict( > CFBundleIconFile = "Ensemble", > CFBundleName = "dNet Ensemble", > CFBundleShortVersionString = "2.x", > CFBundleGetInfoString = "dNet Ensemble 2.x", > CFBundleExecutable = "dNet Ensemble", > CFBundleIdentifier = "com.dnet.ensemble", > ) > > app = dict(script="../framework/main.py") > > setup( > app=[app], > options={'py2app' : {'bdist_base' : "temp", > 'dist_dir' : "disk-image/dNet > Ensemble", > 'iconfile' : "Ensemble.icns", > 'plist' : plist, > 'includes' : "requiredModules", > }, > } > ) > > > if __name__ == "__main__": > buildApp() > > ###################################################################### > # > > Thanks in advance for any suggestions you may have! > > - Erik. > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From hengist.podd at virgin.net Sun Dec 18 09:33:58 2005 From: hengist.podd at virgin.net (has) Date: Sun, 18 Dec 2005 08:33:58 +0000 Subject: [Pythonmac-SIG] [ann] Appscript Installer 1.2 released Message-ID: Hi folks, Just posted a new version of Appscript Installer, containing appscript 0.15.2 and related modules, documentation and tools: http://freespace.virgin.net/hamish.sanderson/appscript.html Binaries for both Apple-installed Python 2.3 and user-installed Python 2.4 on Mac OS X 10.3 and 10.4 are provided. Many thanks to the folks who've donated to this project in the last few months (paid for a copy of OS 10.3 and some much-needed replacement parts), and to Nick Matsakis for developing and distributing previous appscript installers. Enjoy, has -- http://freespace.virgin.net/hamish.sanderson/ From fonnesbeck at gmail.com Mon Dec 19 20:11:53 2005 From: fonnesbeck at gmail.com (Chris Fonnesbeck) Date: Mon, 19 Dec 2005 14:11:53 -0500 Subject: [Pythonmac-SIG] strange py2app errors Message-ID: <723eb6930512191111v11fc59f8peb5ed8f063fe1486@mail.gmail.com> I have been trying to install py2app 0.2 on OSX 10.4, following the instructions: python setup.py bdist_mpkg --open However, when I try this, I get the follwing: writing byte-compilation script '/tmp/tmp-xbkg3.py' /usr/bin/python -OO /tmp/tmp-xbkg3.py removing /tmp/tmp-xbkg3.py copying files for scheme doc error: cannot copy tree 'doc': not a directory Any ideas how to resolve this? -- Chris Fonnesbeck Atlanta, GA From zhiyong_peng2003 at yahoo.com Mon Dec 19 23:52:09 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Mon, 19 Dec 2005 14:52:09 -0800 (PST) Subject: [Pythonmac-SIG] import tlb Message-ID: <20051219225209.44312.qmail@web37203.mail.mud.yahoo.com> Hi! Does anyone try to import .tlb type library on MAc platform? It seems Mac (link codewarrior) can run MFC based application such as on CodeWarrior 9? Regards Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From matthias.oberlaender at daimlerchrysler.com Tue Dec 20 16:23:55 2005 From: matthias.oberlaender at daimlerchrysler.com (matthias.oberlaender@daimlerchrysler.com) Date: Tue, 20 Dec 2005 16:23:55 +0100 Subject: [Pythonmac-SIG] Linking against a Python extension Message-ID: First question: Is it possible to link against a normally built Python extension? More specifically, I want to pass the '.so' file of some Python extension as an extra link argument to the 'weave.inline' function. This seems to work quite well on Linux. But I suspect, on Mac OS X the answer is 'no'. I just want this confirmed. Second question: Can I use distutils right out-of-the-box to create a dynamically linked shared library on OS X? Thanks! Matthias From ewestra at wave.co.nz Tue Dec 20 21:10:12 2005 From: ewestra at wave.co.nz (Erik Westra) Date: Wed, 21 Dec 2005 09:10:12 +1300 Subject: [Pythonmac-SIG] py2app uses wrong version of wxPython? In-Reply-To: <737D7EB9-5291-47FB-A067-BB02588AD462@theolliviers.com> References: <737D7EB9-5291-47FB-A067-BB02588AD462@theolliviers.com> Message-ID: <7997402F-40E1-4A13-B26B-854A56051770@wave.co.nz> Hi Kevin, > When you run py2app, the output should indicate exactly where it is > getting the wxPython scripts and dlls from. Search the py2app > output for any instances of 'wx' in the filename, then track down > those locations and see what the wxPython version is there. I've > released bundles using 2.6.1.0 so I don't think that in and of > itself is the problem here. Thanks -- it was the clue I needed to figure this out. When I had copied the source code from my old machine, I'd accidentally copied a "temp" directory which was used by py2app as the "bdist_base" input to the setup() call, and that temp directory included the older copy of wxPython. I'm not sure why py2app didn't recognise that the files were out of date and replace them with the newer version, but never mind - I simply deleted the "temp" directory, ran py2app again, and it works. Thanks, everyone, for your suggestions and help! - Erik. From bob at redivi.com Tue Dec 20 22:25:28 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 20 Dec 2005 13:25:28 -0800 (PST) Subject: [Pythonmac-SIG] Linking against a Python extension In-Reply-To: References: Message-ID: <33005.216.27.181.31.1135113928.squirrel@webmail.redivi.com> > First question: Is it possible to link against a normally built Python > extension? > > More specifically, I want to pass the '.so' file of some Python extension > as an extra link argument to the 'weave.inline' function. This seems to > work quite well on Linux. But I suspect, on Mac OS X the answer is 'no'. > I just want this confirmed. No. That's not the right way to do it anyway, you need to make a table of pointers available as a PyCObject or similar and get at it that way. Look at how something like Numeric exports its interface. > Second question: Can I use distutils right out-of-the-box to create a > dynamically linked shared library on OS X? I doubt it. Even if you could, don't do that. It's not portable and the search paths for dynamic libraries are relative to DYLD_LIBRARY_PATH and the executable, so you wouldn't be ab -bob From zhiyong_peng2003 at yahoo.com Tue Dec 20 22:34:04 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 20 Dec 2005 13:34:04 -0800 (PST) Subject: [Pythonmac-SIG] instance of iTune or Finder Message-ID: <20051220213404.70127.qmail@web37205.mail.mud.yahoo.com> Hi! All Did anyone try to catch an instance of iTune or Finder under Mac by C or python? What OSA function should I use? Thanks Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051220/817e92bd/attachment.htm From zhiyong_peng2003 at yahoo.com Tue Dec 20 22:46:51 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Tue, 20 Dec 2005 13:46:51 -0800 (PST) Subject: [Pythonmac-SIG] tell application Message-ID: <20051220214651.39372.qmail@web37210.mail.mud.yahoo.com> Hi! All Could I ask you, what exactly corresponding c or python code on apple script "tell application iTune" or "tell application Finder"? Thanks Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051220/836248a9/attachment.htm From hengist.podd at virgin.net Wed Dec 21 01:56:05 2005 From: hengist.podd at virgin.net (has) Date: Wed, 21 Dec 2005 00:56:05 +0000 Subject: [Pythonmac-SIG] PyObjC + AEInstallEventHandler crash? Message-ID: Hi all, Trying to figure why the following test app crashes when a 'testtest' Apple event is sent to it: ------------------------------------------------------------ # cocoatest.py from PyObjCTools import AppHelper from Carbon.AE import AEInstallEventHandler AEInstallEventHandler('test', 'test', lambda evt, res:0) AppHelper.runEventLoop() ------------------------------------------------------------ # setup.py from distutils.core import setup import py2app setup(app=['cocoatest.py'], data_files=['MainMenu.nib']) # default IB application nib ------------------------------------------------------------ -- test.applescript tell application "cocoatest" to ?event testtest? ------------------------------------------------------------ The test app builds and runs fine, but running the test.applescript causes it to fall over with the following traceback: ------------------------------------------------------------ Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000008 Thread 0 Crashed: 0 org.python.python 0x10023684 PyFrame_New + 32 (frameobject.c:540) 1 org.python.python 0x1007aab0 PyEval_EvalCodeEx + 148 (ceval.c:2523) 2 org.python.python 0x10026274 function_call + 344 (funcobject.c:548) 3 org.python.python 0x1000c348 PyObject_Call + 48 (abstract.c:1752) 4 org.python.python 0x1007c26c PyEval_CallObjectWithKeywords + 256 (ceval.c:3420) 5 _AE.so 0x0024b9d8 _AEDesc_NewBorrowed + 476 6 com.apple.AE 0x914ab960 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 208 7 com.apple.AE 0x914ab7fc dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 44 8 com.apple.AE 0x914ab654 aeProcessAppleEvent + 284 9 com.apple.HIToolbox 0x93188940 AEProcessAppleEvent + 60 10 com.apple.AppKit 0x93683adc _DPSNextEvent + 856 11 com.apple.AppKit 0x936835c8 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 116 12 com.apple.AppKit 0x9367fb0c -[NSApplication run] + 472 13 com.apple.AppKit 0x93770618 NSApplicationMain + 452 14 _AppKit.so 0x0040810c init_AppKit + 6484 15 org.python.python 0x1007c5ec call_function + 828 (ceval.c:3547) 16 org.python.python 0x1007a140 PyEval_EvalFrame + 8888 (ceval.c:2163) 17 org.python.python 0x1007b284 PyEval_EvalCodeEx + 2152 (ceval.c:2730) 18 org.python.python 0x1007c8cc fast_function + 356 (ceval.c:3644) 19 org.python.python 0x1007c6c4 call_function + 1044 (ceval.c:3568) 20 org.python.python 0x1007a140 PyEval_EvalFrame + 8888 (ceval.c:2163) 21 org.python.python 0x1007b284 PyEval_EvalCodeEx + 2152 (ceval.c:2730) 22 org.python.python 0x1007e678 PyEval_EvalCode + 48 (ceval.c:484) 23 org.python.python 0x100b2ee0 run_node + 76 (pythonrun.c:1265) 24 org.python.python 0x10070af4 builtin_execfile + 520 (bltinmodule.c:623) 25 org.python.python 0x1007c5ec call_function + 828 (ceval.c:3547) 26 org.python.python 0x1007a140 PyEval_EvalFrame + 8888 (ceval.c:2163) 27 org.python.python 0x1007b284 PyEval_EvalCodeEx + 2152 (ceval.c:2730) 28 org.python.python 0x1007c8cc fast_function + 356 (ceval.c:3644) 29 org.python.python 0x1007c6c4 call_function + 1044 (ceval.c:3568) 30 org.python.python 0x1007a140 PyEval_EvalFrame + 8888 (ceval.c:2163) 31 org.python.python 0x1007b284 PyEval_EvalCodeEx + 2152 (ceval.c:2730) 32 org.python.python 0x1007e678 PyEval_EvalCode + 48 (ceval.c:484) 33 org.python.python 0x100b2ee0 run_node + 76 (pythonrun.c:1265) 34 org.python.python 0x100b266c PyRun_SimpleFileExFlags + 592 (pythonrun.c:863) 35 ...onmac.unspecified.cocoatest 0x00003db0 0x1000 + 11696 36 ...onmac.unspecified.cocoatest 0x00003e50 0x1000 + 11856 37 ...onmac.unspecified.cocoatest 0x00002414 0x1000 + 5140 38 dyld 0x8fe01048 _dyld_start + 60 ------------------------------------------------------------ Additional notes: the test app doesn't crash when AppKit.NSAppleEventManager is used to install the event handler function, nor when CarbonEvt is used instead of PyObjC. I'm getting a similar crash in some CarbonX.OSA code within a PyObjC-based app and reckon identifying what's causing the test app to crash will help me solve the problem there. Any ideas as to the cause, suggestions where to look, how to debug it more effectively, etc. would be a big help as I've been stuck on this for more than a day now and have only just fitted a new laptop case after the last temper tantrum. :p Many thanks, has -- http://freespace.virgin.net/hamish.sanderson/ From bob at redivi.com Wed Dec 21 02:51:25 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 20 Dec 2005 17:51:25 -0800 (PST) Subject: [Pythonmac-SIG] PyObjC + AEInstallEventHandler crash? In-Reply-To: References: Message-ID: <33427.216.27.181.31.1135129885.squirrel@webmail.redivi.com> > Trying to figure why the following test app crashes when a 'testtest' > Apple event is sent to it: > > ------------------------------------------------------------ > # cocoatest.py > > from PyObjCTools import AppHelper > from Carbon.AE import AEInstallEventHandler > > AEInstallEventHandler('test', 'test', lambda evt, res:0) > > AppHelper.runEventLoop() > > ------------------------------------------------------------ > > Additional notes: the test app doesn't crash when > AppKit.NSAppleEventManager is used to install the event handler function, > nor when CarbonEvt is used instead of PyObjC. > > I'm getting a similar crash in some CarbonX.OSA code within a PyObjC-based > app and reckon identifying what's causing the test app to crash will help > me solve the problem there. Any ideas as to the cause, suggestions where > to look, how to debug it more effectively, etc. would be a big help as > I've been stuck on this for more than a day now and have only just fitted > a new laptop case after the last temper tantrum. :p My guess is that there's a refcount or GIL bug in Carbon.AE.AEInstallEventHandler. I'd use NSAppleEventManager... I've used it before and it works just fine. def initializeAsynchronousAppleEvents(self): aem = NSAppleEventManager.sharedAppleEventManager() aem.setEventHandler_andSelector_forEventClass_andEventID_( self, 'handleAppleEvent:withReplyEvent:', struct.unpack('>i', 'aevt')[0], struct.unpack('>i', 'ansr')[0]) def handleAppleEvent_withReplyEvent_(self, event, replyEvent): reply = event.aeDesc() ... -bob From bob at redivi.com Wed Dec 21 05:09:20 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 20 Dec 2005 20:09:20 -0800 (PST) Subject: [Pythonmac-SIG] PyObjC + AEInstallEventHandler crash? In-Reply-To: References: <33427.216.27.181.31.1135129885.squirrel@webmail.redivi.com> Message-ID: <33454.216.27.181.31.1135138160.squirrel@webmail.redivi.com> > Bob Ippolito wrote: > >> > Trying to figure why the following test app crashes when a 'testtest' >> > Apple event is sent to it: >> >>My guess is that there's a refcount or GIL bug in >>Carbon.AE.AEInstallEventHandler. > > How would a GIL bug manifest itself? I always assumed it only became an > issue with multiple threads, but it's not something I understand all that > well. When you release the GIL and call into Python before acquiring it again, it'll almost definitely crash. It doesn't matter if there are multiple threads running, the threading machinery is probably active (it definitely is if PyObjC is imported), which means that you'll have the threadstate as NULL and you'll dereference a NULL pointer somewhere in Python machinery -- boom. >>I'd use NSAppleEventManager... I've used it before and it works just >> fine. > > As I said, the reason I'm interested in why this example fails is because > I get a very similar crash in very similar code when using PyObjC with > CarbonX.OSA. (OSA.c's GenericSendFunction is cribbed from AE.c's > GenericEventHandler.) I didn't show that code because it's a bit more > complex, but that's the crash I'm really interested in fixing. If my guess is right, you probably borrowed broken code :) The handler that gets called into needs to do something like this. There is an older style of doing this with threadstates and whatnot, but the PyGILState API is much easier to deal with. void callback_from_c(void *data) { PyGILState_STATE state; PyObject *result; state = PyGILState_Ensure(); /* call into Python */ result = PyObject_CallFunctionObjArgs((PyObject *)data); /* clean up */ if (result == NULL) { PyErr_Print(); PyErr_Clear(); } else { Py_DECREF(result); } PyGILState_Release(state); } -bob From matthias.oberlaender at daimlerchrysler.com Wed Dec 21 08:50:56 2005 From: matthias.oberlaender at daimlerchrysler.com (matthias.oberlaender@daimlerchrysler.com) Date: Wed, 21 Dec 2005 08:50:56 +0100 Subject: [Pythonmac-SIG] Linking against a Python extension In-Reply-To: <33005.216.27.181.31.1135113928.squirrel@webmail.redivi.com> Message-ID: bob at redivi.com schrieb am 20.12.2005 22:25:28: > > First question: Is it possible to link against a normally built Python > > extension? > > > > More specifically, I want to pass the '.so' file of some Python extension > > as an extra link argument to the 'weave.inline' function. This seems to > > work quite well on Linux. But I suspect, on Mac OS X the answer is 'no'. > > I just want this confirmed. > > No. That's not the right way to do it anyway, you need to make a table of > pointers available as a PyCObject or similar and get at it that way. Look > at how something like Numeric exports its interface. Ok, I explain my use case in more details: Sometimes I find it convenient to use weave's inline feature for compiling and linking small pieces of C code at runtime. There are a bunch of private C helper functions I reuse again and again. On OS X I have thrown them into a framework so I could let weave link against it using the _platform specific_ option pattern "-F somedir -framework mychelpers". So actually, I don't access anything in mychelpers directly from Python, but only indirectly via weave as an "ad hoc" wrapping tool. I think, PyCObjects are not necessary here. I was wondering how one could do that in a uniform way on both, Mac and Linux. So I tried to let distutils build a minimal extension by only adding an initmychelpers function that calls Py_InitModule with an empty method list. On Linux I can let weave use the .so file as an additional input file to the linker. It works! Locating this file is also easy if the extension module is on the python search path: import mychelpers; mychelpers.__file__. But following the same pattern on the Mac resulted in the error message: ld: .../mychelpers.so is input for the dynamic link editor, is not relocatable by the static link editor again After some hours of googling, reading and blind trying I now (hopefully) understand why: On OS X a Python extension is not a "shared object" (in the Linux sense) and not a dynamic library, but a (Mach-O) bundle, and a Mach-O bundle is more similar to an executable file than to an object file. In particular: It cannot be input to the linker again. Dead end. Period. Correct? > > > Second question: Can I use distutils right out-of-the-box to create a > > dynamically linked shared library on OS X? > > I doubt it. Even if you could, don't do that. It's not portable and the > search paths for dynamic libraries are relative to DYLD_LIBRARY_PATH and > the executable, so you wouldn't be ab > Ok, that's what I expected. Thank you. -- Matthias From bob at redivi.com Wed Dec 21 11:34:11 2005 From: bob at redivi.com (Bob Ippolito) Date: Wed, 21 Dec 2005 02:34:11 -0800 (PST) Subject: [Pythonmac-SIG] Linking against a Python extension In-Reply-To: References: <33005.216.27.181.31.1135113928.squirrel@webmail.redivi.com> Message-ID: <33029.216.27.181.31.1135161251.squirrel@webmail.redivi.com> > > bob at redivi.com schrieb am 20.12.2005 22:25:28: > >> > First question: Is it possible to link against a normally built Python >> > extension? >> > >> > More specifically, I want to pass the '.so' file of some Python > extension >> > as an extra link argument to the 'weave.inline' function. This seems >> to >> > work quite well on Linux. But I suspect, on Mac OS X the answer is > 'no'. >> > I just want this confirmed. >> >> No. That's not the right way to do it anyway, you need to make a table > of >> pointers available as a PyCObject or similar and get at it that way. > Look >> at how something like Numeric exports its interface. > > After some hours of googling, reading and blind trying I now (hopefully) > understand why: On OS X a Python extension is not a "shared object" (in > the > Linux sense) and not a dynamic library, but a (Mach-O) bundle, and a > Mach-O > bundle is more similar to an executable file than to an object file. In > particular: It cannot be input to the linker again. Dead end. Period. > Correct? Correct. I think it might be possible to use a MH_DYLIB as a Python extension just by implementation detail, but distutils doesn't link that way and you shouldn't. Using a table of function pointers is the only right way to share C functionality between Python extensions, despite what you're able to make work on one platform or another. -bob From spe.stani.be at gmail.com Wed Dec 21 21:46:01 2005 From: spe.stani.be at gmail.com (SPE Stani's Python Editor) Date: Wed, 21 Dec 2005 21:46:01 +0100 Subject: [Pythonmac-SIG] ANN: SPE 0.8.1.c IDE (realtime error underlining & script tooltips) Message-ID: <2078a7ad0512211246g2504d605j3e21871a1a204f94@mail.gmail.com> Release news from http://pythonide.stani.be This new release is for under your Christmas tree. (If you want more presents, just donate to SPE and receive the manual in your mailbox ;-) There are so many changes and fixes. The new cool features not to be missed are the realtime error underlinging and the tooltips for the file tabs, which gives you a preview of the file by the docstring. Mac users should upgrade as this fixed the most critical bug of SPE on Mac, the click inside selection crash. So just open the package and discover the present... :**New features**: - errors are underlined in red as you type (as preference) - tooltips on tabs showing path and docstring - drag and drop for script tabs - Edit>Show docstring (Ctrl+Shift+Space) - middle click pastes selected text - single instance application (enable it as preference) :**Improved features**: - file tabs (thanks to Andrea Gavana's NotebookCtrl) - add single click toggle for explore (not for Mac) - better code completion and docstring - dialog popup to confirm save before executing whole file - if signature not specified opens a choose file dialog - selected text is now always copied to the find dialog :**Fixes**: - clicking inside selection=deselect(no mac crash anymore) - launching debugger - removed unnecessary print statement - find in files clear behavior (by Thurston Stone) - ask to save before running a modified file - changed text 'save before run' to 'save before execute' - run with sys.executable (movable python) - info.PYTHON_EXEC to pythonw for Mac - __name__ in shell is now "__main__" for executing scripts - Kiki dialog box (by Andrea Gavana) - import sys when right version wxPython is not found **Changes**: - auto reload change file is off by default :**Contributors**: - Andrea Gavana - Thurston Stone - Bill Peterson (manual review) - Michael Foord (manual review) - Theo de Ridder (for a lot of suggestions & critical feedback) :**Donations**: - Ramon Diaz-Uriarte, http://ligarto.org/rdiaz (15 euro) - Dmeetry Raizman, Symula Inc, http://www.symula.com (20 dollar) Both donators received the SPE manual. :**Installation**: - See http://pythonide.stani.be/manual/html/manual2.html - There is now an update section for MacOS X! :**Development**: - http://developer.berlios.de/mail/?group_id=4161\ SVN 117 About SPE: SPE is a python IDE with auto-indentation, auto completion, call tips, syntax coloring, uml viewer, syntax highlighting, class explorer, source index, auto todo list, sticky notes, integrated pycrust shell, python file browser, recent file browser, drag&drop, context help, ... Special is its blender support with a blender 3d object browser and its ability to run interactively inside blender. Spe integrates with XRCed (gui designer) and ships with wxGlade (gui designer), PyChecker (source code doctor), Kiki (regular expression console) and WinPdb (remote, multi-threaded debugger). SPE is looking for people who can take screenshots for the new tutorial. The development of SPE is driven by its donations. Anyone who donates can ask for an nice pdf version of the manual without ads (60 pages). -- http://pythonide.stani.be http://pythonide.stani.be/screenshots http://pythonide.stani.be/manual/html/manual.html From Jack.Jansen at cwi.nl Wed Dec 21 23:40:55 2005 From: Jack.Jansen at cwi.nl (Jack Jansen) Date: Wed, 21 Dec 2005 23:40:55 +0100 Subject: [Pythonmac-SIG] PyObjC + AEInstallEventHandler crash? In-Reply-To: <33427.216.27.181.31.1135129885.squirrel@webmail.redivi.com> References: <33427.216.27.181.31.1135129885.squirrel@webmail.redivi.com> Message-ID: <3B381801-689F-4F4C-A891-37D6BB467FA2@cwi.nl> On 21-dec-2005, at 2:51, Bob Ippolito wrote: >> Trying to figure why the following test app crashes when a 'testtest' >> Apple event is sent to it: >> >> ------------------------------------------------------------ >> # cocoatest.py >> >> from PyObjCTools import AppHelper >> from Carbon.AE import AEInstallEventHandler >> >> AEInstallEventHandler('test', 'test', lambda evt, res:0) >> >> AppHelper.runEventLoop() >> >> ------------------------------------------------------------ >> >> Additional notes: the test app doesn't crash when >> AppKit.NSAppleEventManager is used to install the event handler >> function, >> nor when CarbonEvt is used instead of PyObjC. >> >> I'm getting a similar crash in some CarbonX.OSA code within a >> PyObjC-based >> app and reckon identifying what's causing the test app to crash >> will help >> me solve the problem there. Any ideas as to the cause, suggestions >> where >> to look, how to debug it more effectively, etc. would be a big >> help as >> I've been stuck on this for more than a day now and have only just >> fitted >> a new laptop case after the last temper tantrum. :p > > My guess is that there's a refcount or GIL bug in > Carbon.AE.AEInstallEventHandler. You guessed correctly: AEInstallEventHandler is blissfully unaware of refcounts. It simply passes the address of the callback function object to the C AEInstallEventHandler, and hopes the object still exists when the callback comes. The workaround is to keep a reference to the object around. Which is apparently also the normal case, I think this is the first report I've seen of this problem, and I wouldn't be surprised if this code even predates my responsibility for the toolbox modules (i.e. Guido himself wrote this:-). -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From bgranger at scu.edu Fri Dec 23 19:53:35 2005 From: bgranger at scu.edu (Brian Granger) Date: Fri, 23 Dec 2005 10:53:35 -0800 Subject: [Pythonmac-SIG] ANN: PyXG 0.2.0 Message-ID: <3841F800-54ED-4A8E-8066-BD2D95C18A79@scu.edu> Hello fellow Xgrid/Python users, This is to announce the second release (0.2.0) of PyXG. PyXG is an object oriented Python interface to Xgrid. New in this release: - A new website (pyxg.scipy.org) - A google mailing list - A Subversion repository to speed development - Overhauled documentation - Package installers for two distributions of python - Kerberos support - More flexible handling of job and grid identifiers - More consistent coding style With PyXG you can: - Start and manage Xgrid jobs quickly using Python's elegant syntax. - Use Xgrid from within python scripts as well as in interactive Python sessions. - Submit and manage simple (one task) and batch (many task) Xgrid jobs. - Get job information and retrieve job results - Work with multiple Xgrid controllers and grids simultaneously. This is a new release with lots of changes, so if you find any bugs, please let me know. Brian Granger bgranger at scu.edu From fairwinds at eastlink.ca Tue Dec 27 20:54:27 2005 From: fairwinds at eastlink.ca (David Pratt) Date: Tue, 27 Dec 2005 15:54:27 -0400 Subject: [Pythonmac-SIG] Pythonmac 10.2 wxPython and 2.4.1 In-Reply-To: <33454.216.27.181.31.1135138160.squirrel@webmail.redivi.com> References: <33427.216.27.181.31.1135129885.squirrel@webmail.redivi.com> <33454.216.27.181.31.1135138160.squirrel@webmail.redivi.com> Message-ID: <43B19BF3.7080506@eastlink.ca> I am trying to determine what to about my mac with python. I am running 10.2.8 and have been using 2.3.5 and the wxpython ansi though I really need the unicode build. This has been satisfactory since I can still do most everything except now I am finding more packages coming out with generator expressions and decorators that are not able to operate on 2.3.5. I checked the pythonmac site and I realize the focus is now 10.3. What are my options for having a working python 2.4.1 installation with a working unicode wxPython as well. I don't want to upgrade my OS for 150.00 at this point since I will eventually be purchasing a new machine in the next year. Regards, David From ronaldoussoren at mac.com Wed Dec 28 09:36:50 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Wed, 28 Dec 2005 09:36:50 +0100 Subject: [Pythonmac-SIG] Pythonmac 10.2 wxPython and 2.4.1 In-Reply-To: <43B19BF3.7080506@eastlink.ca> References: <33427.216.27.181.31.1135129885.squirrel@webmail.redivi.com> <33454.216.27.181.31.1135138160.squirrel@webmail.redivi.com> <43B19BF3.7080506@eastlink.ca> Message-ID: <54F7FBC0-E306-4CC4-932C-32E4D360D67A@mac.com> On 27-dec-2005, at 20:54, David Pratt wrote: > I am trying to determine what to about my mac with python. I am > running > 10.2.8 and have been using 2.3.5 and the wxpython ansi though I really > need the unicode build. This has been satisfactory since I can > still do > most everything except now I am finding more packages coming out with > generator expressions and decorators that are not able to operate > on 2.3.5. > > I checked the pythonmac site and I realize the focus is now 10.3. What > are my options for having a working python 2.4.1 installation with a > working unicode wxPython as well. You'll have to build it yourself. That's not very hard, extract the tar archive and run: cd Python-2.4.2 ./configure --enable-framework make sudo make install You'll have to install TclTk before doing this if you want to use tkinter or IDLE. Ronald > > I don't want to upgrade my OS for 150.00 at this point since I will > eventually be purchasing a new machine in the next year. > > Regards, > David > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig From goodger at python.org Wed Dec 28 16:10:19 2005 From: goodger at python.org (David Goodger) Date: Wed, 28 Dec 2005 10:10:19 -0500 Subject: [Pythonmac-SIG] PyCon TX 2006: Early-bird registration ends Dec. 31! Message-ID: <43B2AADB.3050501@python.org> Early bird registration for PyCon TX 2006 ends on December 31st, so there are only a few days LEFT. To register, please visit: http://us.pycon.org/TX2006/Registration You can still register after Dec. 31st, but the cost will go up by US$65 (US$25 for students). This year PyCon will feature a day of tutorials before the three days of regular presentations. Course outlines for all the tutorials have been posted; see http://wiki.python.org/moin/PyCon2006/Tutorials All of the PyCon tutorials are still open for new registrations, but space is limited, and we suspect they'll all be filled up by the time early-bird registration closes. Don't forget to book your hotel room, too. PyCon TX 2006 is being held at a Dallas/Addison hotel, and we have negotiated a special low rate: http://us.pycon.org/Addison/Hotels We hope to see you in Texas! -- David Goodger (on behalf of A.M. Kuchling, Chair, PyCon 2006) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 249 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20051228/1ac6d5e5/signature.pgp From zhiyong_peng2003 at yahoo.com Thu Dec 29 18:43:28 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Thu, 29 Dec 2005 09:43:28 -0800 (PST) Subject: [Pythonmac-SIG] general rule Message-ID: <20051229174328.26018.qmail@web37215.mail.mud.yahoo.com> Hi! All If I would like to use C (Coddewarrior for example) to call Applescript for iTune or Finder or other application, what is the general rule or code should be except ask OS to run the script especially when I would like to pass data back and forth between C and applescript? Thanks Zhi __________________________________ Yahoo! for Good - Make a difference this year. http://brand.yahoo.com/cybergivingweek2005/ From zhiyong_peng2003 at yahoo.com Thu Dec 29 18:43:32 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Thu, 29 Dec 2005 09:43:32 -0800 (PST) Subject: [Pythonmac-SIG] general rule Message-ID: <20051229174332.86288.qmail@web37207.mail.mud.yahoo.com> Hi! All If I would like to use C (Coddewarrior for example) to call Applescript for iTune or Finder or other application, what is the general rule or code should be except ask OS to run the script especially when I would like to pass data back and forth between C and applescript? Thanks Zhi __________________________________________ Yahoo! DSL ? Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com From zhiyong_peng2003 at yahoo.com Thu Dec 29 18:43:32 2005 From: zhiyong_peng2003 at yahoo.com (Zhi Peng) Date: Thu, 29 Dec 2005 09:43:32 -0800 (PST) Subject: [Pythonmac-SIG] general rule Message-ID: <20051229174332.15473.qmail@web37205.mail.mud.yahoo.com> Hi! All If I would like to use C (Coddewarrior for example) to call Applescript for iTune or Finder or other application, what is the general rule or code should be except ask OS to run the script especially when I would like to pass data back and forth between C and applescript? Thanks Zhi __________________________________ Yahoo! for Good - Make a difference this year. http://brand.yahoo.com/cybergivingweek2005/