RE: [Pythonmac-SIG] magic file info
/usr/bin/magic determines the file type heuristically by parsing /usr/share/file/magic and then reading a couple bytes out of the given file. This appears to be a direct Python translation of the file command, with an embedded copy of a magic table: http://www.demonseed.net/~jp/code/magic.py Thank you! I could have written a magic parser myself, but it's better if I don't need to. ;-) I only thought there would be a standard module that I overlooked. Best regards, Henning Hraban Ramm Südkurier Medienhaus / MediaPro Support/Admin/Development Dept. ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] cross-platform puzzle
You were (Bob was) more or less right -- which is no surprise. The problem turned out to stem from the fact that when the dialog-processing code adds a new word as a dictionary key, what it adds is a string that wx.TextCtrl returns when a word is double-clicked. On Windows, this included a trailling space, on Mac it didn't. So when the word-without-trailing-space was looked up, the program could find it on Mac but not on Windows. So why did my wx.TextCtrl show different double-click behavior on the two platforms? Though I'm using Python 2.3 on both, my wxPython on Mac is 2.5.3.1 and on Win it was 2.5.2.8 (dumb!) so I thought that might be the problem. But no: I upgraded on Win, and I get the same behavior. I'll report this on the wxPython list. Easily fixed, of course -- in the dialog-return code, instead of word = selstring.lower() I just make it word = selstring.lower().strip() Many thanks! It was driving me crazy, and you steered me right. Charles Hartman Professor of English, Poet in Residence http://cherry.conncoll.edu/cohar http://villex.blogspot.com On Feb 21, 2005, at 9:15 PM, Bob Ippolito wrote: On Feb 21, 2005, at 8:58 PM, Charles Hartman wrote: On Feb 21, 2005, at 8:03 PM, Bob Ippolito wrote: On Feb 21, 2005, at 7:49 PM, Charles Hartman wrote: This may be the wrong list for this question. Send me away if so, but I thought I'd try here first. I'm building Mac and Windows versions of an application with a dictionary as one main data structure. A dialog box lets the user type a string which is then used to change the value associated with one of the keys, or to generate a new key-value pair. At least if the pair is new, on Windows the test if word in self.Dict: newvalue = self.Dict[word] fails even though, in the debugger, the string I see for 'word' is identical to one of the keys now visible in self.Dict. This is in Windows only; the Mac version works fine. The dialog box is making the proper return on both platforms, and the new key-value pair is being inserted into the dictionary. I haven't yet checked what happens if the key was an existing one and only the value is changed, and I suppose that might turn out to be the crucial question. But either way, I'm very puzzled to find a cross-platform disparity in this area. What am I missing? I don't think you've provided enough detail to provide a useful guess. You don't even specify what fails means, let alone which toolkit you're using to collect the input from the user, etc. Those two lines of code are going to do the same thing regardless of platform and should never raise an exception (if that's what fail means) -- assuming that Dict is a dict and word is a str or unicode (which is what you implied). Sorry, I'll try to be more specific. I'm using wxPython 2.5.3.1, developing under Mac 10.3 with the factory-issue Framework Python 2.3. I'm trying to run also under Win XP (when I get time on a Windows machine every other day). I'm using the WingIDE on both platforms. And on Windows XP you are also using wxPython 2.5.3.1 with Python 2.3? The app contains a dictionary whose keys are strings (English words) and whose values are lists of strings (one string per syllable, stress encoded as all caps). The program can figure out the syllabification and stress of about 5/6 of the words it encounters, so the dictionary contains the exceptions. If the user thinks the program is giving a word the wrong number of syllables or the wrong stress, s/he can double-click on the word, which brings up a wx.Dialog. The dialog has two fields (plus OK and Cancel buttons) The first field shows how the program thinks the word should be treated -- either the value associated with it in the dictionary or the value returned by routines that figure out syllabification and stress. (The user sees no difference between these cases.) The second field is a text field that allows the user to type in a new encoding for the word (syllables delimited by spaces, the stressed syllable in all caps). The string which the user types in is converted to a list of strings, like the other values in the dictionary. If the word was already a key in the dictionary, its value is replaced by the new one. If not, the word is added to the dictionary as a new key, with a value which is the list made from the string typed by the user. On both Mac and Windows, the modal wx.Dialog comes up fine. When it's closed the return value (the string typed by the user) is as expected. If the word was not a key in the dictionary, it shows up as a new key whose value is the string the user typed in. All correct on both platforms. After that, the program goes back and looks up all the words (in the line of words being processed) in the dictionary. Again, if it doesn't find a word it calculates how to syllabify-and-stress it. The method that does this begins by testing whether the word is in the dictionary: if word
Re: [Pythonmac-SIG] Versions, Frameworks, Linking, PantherPythonFix
so if you build all of your extensions on a 10.2 environment BTW I don't actually have a 10.2 environment. The Mac Mini comes with 10.3. In other words for a maximally redistributable application: - Install PantherPythonFix immediately, on any Mac OS X 10.3 machine that you will use distutils on, without hesitation My biggest 3rd party dependency is wxPython. Is there any way of telling if it was built on a machine with the fix applied? - Build your application and all extensions on the lowest common denominator version of Mac OS X *not* using the vendor Python. I don't see a MacPython for 10.3. I don't really care about Linux -- I'm sure it's possible to bundle the vendor Python with your application, but I'm not sure why you would do such a thing. Is that default behavior for cx_Freeze? It is the default behaviour of both py2exe and cx-Freeze to bundle the Python interpretter with your app. No distinction is made between vendor and non-vendor. I believe they can also both be made to not include an interpretter, but that is *very* rare. The simple reason for always including the interpretter is because you know things work. Otherwise you are at the mercy of whatever can be on other machines which will generally various incompatible versions. (On Linux Python is randomly compiled as two bytes per unicode char on some machines and four bytes on others.) For non-trivial apps, there isn't much in the way of binary compatibility. For example, look at the most popular app on SourceForge, and how they have different downloads for each Linux distro and version: http://gaim.sourceforge.net/downloads.php Roger ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Versions, Frameworks, Linking, PantherPythonFix
On Feb 22, 2005, at 12:18, Roger Binns wrote: so if you build all of your extensions on a 10.2 environment BTW I don't actually have a 10.2 environment. The Mac Mini comes with 10.3. Then you can't build 10.2 compatible software.. no big deal. In other words for a maximally redistributable application: - Install PantherPythonFix immediately, on any Mac OS X 10.3 machine that you will use distutils on, without hesitation My biggest 3rd party dependency is wxPython. Is there any way of telling if it was built on a machine with the fix applied? It wasn't. - Build your application and all extensions on the lowest common denominator version of Mac OS X *not* using the vendor Python. I don't see a MacPython for 10.3. MacPython for 10.2 works with 10.3. I don't really care about Linux -- I'm sure it's possible to bundle the vendor Python with your application, but I'm not sure why you would do such a thing. Is that default behavior for cx_Freeze? It is the default behaviour of both py2exe and cx-Freeze to bundle the Python interpretter with your app. No distinction is made between vendor and non-vendor. I believe they can also both be made to not include an interpretter, but that is *very* rare. There is no vendor Python on Windows, so py2exe can make no such distinction. The simple reason for always including the interpretter is because you know things work. Otherwise you are at the mercy of whatever can be on other machines which will generally various incompatible versions. (On Linux Python is randomly compiled as two bytes per unicode char on some machines and four bytes on others.) For non-trivial apps, there isn't much in the way of binary compatibility. For example, look at the most popular app on SourceForge, and how they have different downloads for each Linux distro and version: http://gaim.sourceforge.net/downloads.php It's the default behavior of py2app to bundle the interpreter too, except in the vendor case. -bob ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] cross-platform puzzle
Charles Hartman [EMAIL PROTECTED] writes: So why did my wx.TextCtrl show different double-click behavior on the two platforms? Though I'm using Python 2.3 on both, my wxPython on Mac is 2.5.3.1 and on Win it was 2.5.2.8 (dumb!) so I thought that might be the problem. But no: I upgraded on Win, and I get the same behavior. I'll report this on the wxPython list. I think it might be the underlying controls behaving differently. Certainly on Mac double-clicking gets you just the word selected (but if you then press delete, a preceding space will be deleted). It's too long since I used windows to be sure how it behaves, but it wouldn't surprise me if it was different. Cheers, mwh -- Emacs is a fashion statement. No, Gnus is a fashion statement. Emacs is clothing. Everyone else is running around naked. -- Karl Kleinpaste Jonadab the Unsightly One, gnu.emacs.gnus ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Why do I need PantherPythonFix?
On Feb 22, 2005, at 17:23, Chris Barker wrote: Bob Ippolito wrote: It is not yet public knowledge as to whether applications built with the vendor Python 2.3.0 on Mac OS X 10.3 will work on Mac OS X 10.4. Given that Python 2.3.x was in the WWDC sources and setup to build as a framework in the same place, then signs point to yes. However, if Apple changes their minds and go with 2.4, then the answer will probably be no. Is there any way to us to lobby Apple to include whatever bits of python 2.3 are needed to keep Py2App bundled apps running on new systems, when they upgrade to 2.4? http://bugreport.apple.com/ Yes, you will have to set your PATH if you want this one to be default. I never do this. Whenever I've run multiple version of python, with any given python code, I know what version I want to use, so I put something like: #!/usr/bin/env python2.3.4 at the top of the __main__ file and the setup.py, and I'm done. It's more reliable that messing with PATH, and hoping it stays in the right order. I also rarely screw with PATH. Using /usr/bin/env is saying let PATH decide. I use explicit paths like: # MacPython 2.3.5 /usr/local/bin/python2.3 # DarwinPorts Python 2.3.5 /opt/local/bin/python2.3 etc.. -bob ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] package manager.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 HI all, this is probably a question that has been answered on the wiki, but i can't seem to find it. I decided to try and upgrade my version of Numeric (currently 23.1) (building the latest Biopython was causing errors) but the packagmanager gives me a 404 errror opening http://www.python.org/packman/version-0.3/darwin-7.80- Power_Macintosh.plist. I've tried the official unofficial database, but when i attempt to upgrade numeric I get told that there is no package for apple installed python 2.3 download manually. I thought all macpython used apples python now? ealier in the night i tried to install a few packages, like reportlab, and the packager appeared to die half way through. I was letting me download packages, but have i corrupted its database? Can i repair this, or should I attempt to build all these packages by hand. If so can anyone resolve the errors in building i have below? cheers Kim Building numeric 23.7 from the source dies, building 'lapack_lite' extension gcc -Wl,-F. -Wl,-F. -bundle -framework Python build/temp.darwin-7.8.0-Power_Macintosh-2.3/Src/lapack_litemodule.o - -L/usr/lib/atlas -llapack -lcblas -lf77blas -latlas -lg2c -o build/lib.darwin-7.8.0-Power_Macintosh-2.3/lapack_lite.so -framework vecLib ld: warning -L: directory name (/usr/lib/atlas) does not exist ld: can't locate file for: -llapack error: command 'gcc' failed with exit status 1 Building Biopython1.40b fails with Bio/Cluster/clustermodule.c:2:33: Numeric/arrayobject.h: No such file or directory Bio/Cluster/clustermodule.c:20: error: parse error before PyArrayObject Bio/Cluster/clustermodule.c:2:33: Numeric/arrayobject.h: No such file or directory Bio/Cluster/clustermodule.c:20: error: parse error before PyArrayObject Dr Kim Branson Peter Doherty Fellow Protein Structure and Function St Vincents Institute for Medical Research 41 Victoria Parade, Fitzroy Victoria 3065, Australia. Phone: +613 9288 2480 Fax: +613 94162 676 Ph +613 9662 7136 [EMAIL PROTECTED] [EMAIL PROTECTED] www.svi.edu.au -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) iD8DBQFCG7qter2hmGbHcokRAnuQAJ4uXdKQRdl7QbE4Q9MhjqdQ9XPUnACgpk7Q iTG4ghKd1x3jBERpACax8DI= =j37O -END PGP SIGNATURE- ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Why do I need PantherPythonFix?
Bob Ippolito wrote: I also rarely screw with PATH. Using /usr/bin/env is saying let PATH decide. right. I am always working across platforms, so I want to specify which python to use, but not specify where to find it. I use explicit paths like: # MacPython 2.3.5 /usr/local/bin/python2.3 # DarwinPorts Python 2.3.5 /opt/local/bin/python2.3 which are not going to work on my Linux box. I guess if you want to have two different python2.3.4s, you need to do this, however. -CHB -- Christopher Barker, Ph.D. Oceanographer NOAA/ORR/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] package manager.
Kim Branson wrote: HI all, this is probably a question that has been answered on the wiki, but i can't seem to find it. I decided to try and upgrade my version of Numeric (currently 23.1) (building the latest Biopython was causing errors) but the packagmanager gives me a 404 errror opening http://www.python.org/packman/version-0.3/darwin-7.80- Power_Macintosh.plist. These package repositories are pretty much unmaintained now. An up-to-date Installer.app-type package is available thanks to Bob Ippolito. http://undefined.org/python/packages.html -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Why do I need PantherPythonFix?
On Feb 22, 2005, at 18:06, Chris Barker wrote: Bob Ippolito wrote: I also rarely screw with PATH. Using /usr/bin/env is saying let PATH decide. right. I am always working across platforms, so I want to specify which python to use, but not specify where to find it. I use explicit paths like: # MacPython 2.3.5 /usr/local/bin/python2.3 # DarwinPorts Python 2.3.5 /opt/local/bin/python2.3 which are not going to work on my Linux box. I guess if you want to have two different python2.3.4s, you need to do this, however. /usr/bin/env python2.3.5 is only going to work if Python 2.3.5 is already on your PATH. If you do not explicitly change your path, it will never be there, since /usr/local/bin, /opt/local/bin, etc. are not on the PATH by default. -bob ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Versions, Frameworks, Linking, PantherPythonFix
My biggest 3rd party dependency is wxPython. Is there any way of telling if it was built on a machine with the fix applied? It wasn't. Thank you for checking. I have passed on the request to Robin to run PantherPythonFix on his 10.3 build machine. There is no vendor Python on Windows, so py2exe can make no such distinction. Technically there is on many HP/Compaq machines :-) And in the thread on setting PATH, that is exactly what I need to do since the code is cross platform. I actually can't see *any* benefit to me at all of Apple's Python. Are there any instructions anywhere on how to remove Apple's version, and put on an official Python.org blessed version and ensure the latter resides somewhere on my path? The various web pages are all pretty confusing and appear contradictory: http://www.python.org/download/ http://www.python.org/download/download_mac.html http://homepages.cwi.nl/~jack/macpython/ http://homepages.cwi.nl/~jack/macpython/beta.html Roger ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig