Re: [Pythonmac-SIG] How to get setuptools to build a Universal Binary?

2009-01-08 Thread Joe Strout

Ned Deily wrote:

Note, I haven't tested this so YMMV.  If you can get away with using a 
5.0 client, that should work.  But if you just fix-up the 5.1 libs with 
a couple of copies that should work, too.   Go to the directory of your 
mysql installation, probably something like:


cd /usr/local/mysql-5.1.30-osx10.4-universal

Then:

cd lib
ls -l *.dylib
file *.dylib

sudo sh

cp -p libmysqlclient.16.0.0.dylib libmysqlclient.16.dylib
cp -p libmysqlclient.16.0.0.dylib libmysqlclient.dylib

cp -p libmysqlclient_r.16.0.0.dylib libmysqlclient_r.16.dylib
cp -p libmysqlclient_r.16.0.0.dylib libmysqlclient_r.dylib


Hmm.  This doesn't appear to have worked, but it's failing in an odd way 
that I don't understand.  Here's what I did:


1. The above copying, vebatim.
2. In the MySQL-python-1.2.2 source directory:
   2a. sudo python setup.py clean
   2b. sudo python setup.py build
   2c. sudo python setup.py install
3. In my project directory:
   3a. rm -rf build/*
   3b. rm -rf dist/*
   3c. python setup.py py2app
4. Ran the resulting app on ANY machine -- even the one I just built it 
on -- and it fails with:


...File "IADB.pyc", line 12, in 
 ImportError: No module named MySQLdb

Note that the program still works fine when I run it on the command line 
(with "python eTownCentral.py"), and when I enter python and try "import 
MySQLdb" that works too, so I haven't broken MySQLdb completely.  It's 
just not included in my app bundle now.  Within Frameworks, I see only 
libwx_macud-2.8.0.dylib and Python.framework; no libmysqlclient at all. 
 And in lib-dynload, there is no longer a _mysqldb.so.


The weird thing is, my python source and setup.py have not changed.  So 
why is py2app suddenly failing to realize that it should include MySQLdb?


Thanks,
- Joe

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] real-time video capturing and processing

2009-01-08 Thread Michael Graber

hi all,

first: theres a library called VideoCapture for Win32 environments  
which makes it possible to access video-capture devices. is there  
something similar for macs?


second: i would like to do real-time video-processing (like bright- 
spot detection, movement detection, ...) using images recorded by a  
webcam. is python suited to do so? any references?


i appreciate your hints to this quite crude question.

best,
michael
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] How to get setuptools to build a Universal Binary?

2009-01-08 Thread Joe Strout
I'm (still) trying to make a neatly packaged Python app that works on 
both PPC and Intel Macs.  All is good except for mysqldb; following the 
procedure I've documented at 
, my app bundle 
contains an Intel-only binary of the mysqldb library 
(libmysqlclient_r.16.dylib).


This page 
(http://developer.apple.com/opensource/buildingopensourceuniversal.html) 
at Apple suggests a possible solution: build separate Intel and PPC 
binaries, and then combine them with lipo.  But of course that's using 
Makefiles.  MySQLdb instead uses setuptools.


So: does anyone have a clue how I can convince setuptools to build a PPC 
binary (or better yet, a Universal one) on an Intel machine?


This may or may not also be involved:
  

Any advice will be greatly appreciated...

Thanks,
- Joe


--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] How to get setuptools to build a Universal Binary? [SOLVED!]

2009-01-08 Thread Joe Strout
Woot!  I finally got my MySQLdb-using Python app working as a Universal 
Binary!  (Trying to make sure all the relevant keywords are there for 
future googlers.)


The root cause of most of the trouble was the broken 5.1 MySQL 
distribution (bug #41940 on the MySQL tracker).  I tried patching it up 
as Ned suggested, but that didn't work for me.  However, going back to 
5.0 did work.


Here's what I did in more detail:

1. Deleted /usr/local/mysql-5.1.30-osx10.4-universal, and the 
MySQL-python egg (in 
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/).


2. Downloaded the mysql-5.0.67-osx10.4-universal tarball from the MySQL 
5.0 downloads page.  Unpacked this into /usr/local, changed ownership 
and group as usual, and made the symlink to it as /usr/local/mysql. 
(Confirmed that all dylibs in its lib directory were really universal, 
using "file *.dylib".)


3. Reinstalled MySQLdb using the easy method Ned suggested: 
"easy_install -Z MySQL-python".  This worked fine; all the extra hackery 
at 
 
appears to be unnecessary when you use easy_install, as is the manual 
unzipping of the egg (provided you remember the -Z flag).  Navigated 
into the newly created egg in site-packages and verified that the 
_mysql.so file was universal.


4. Rebuilt my app with py2app.

The resulting app works in 10.4 and 10.5 on both PPC and Intel machines. 
 Hooray!


Now, let's see... I owe a beer (or other beverage of choice) to Ned, 
Chris, Robin, and Andy... and I'm off to make a donation to both 
wxPython and MySQLdb...


Many thanks,
- Joe


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] How to get setuptools to build a Universal Binary? [SOLVED!]

2009-01-08 Thread Daniel Miller


Woot!  I finally got my MySQLdb-using Python app working as a  
Universal Binary!


Excellent! I'm glad you got it working.

The root cause of most of the trouble was the broken 5.1 MySQL  
distribution (bug #41940 on the MySQL tracker).  I tried patching  
it up as Ned suggested, but that didn't work for me.  However,  
going back to 5.0 did work.


Out of curiosity, what does the mysql_config command give you now?  
i.e. the output of:


$ mysql_config --cflags


Cheers,
Daniel

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] How to get setuptools to build a Universal Binary? [SOLVED!]

2009-01-08 Thread Joe Strout

Daniel Miller wrote:

The root cause of most of the trouble was the broken 5.1 MySQL 
distribution (bug #41940 on the MySQL tracker).  I tried patching it 
up as Ned suggested, but that didn't work for me.  However, going back 
to 5.0 did work.


Out of curiosity, what does the mysql_config command give you now? i.e. 
the output of:


$ mysql_config --cflags


Still no "arch" flags:

-I/usr/local/mysql/include  -g -Os  -fno-common   -D_P1003_1B_VISIBLE 
-DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT



Best,
- Joe


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Building MySqldb for Universal Python

2009-01-08 Thread Christopher Barker

NOTE: I'm sending this all here, so it will be here for the archives


This is about trying to build a Universal MySqlDb module for the 
python.org Universal python (2.5.2 in this case). The issue is that you 
need to start with Universal MySQL libs. MySQL does indeed distribute 
Universal libs (ppc, ppc64, and i386 -- apparently not i386-64), but 
only as a tarball, not as as in installer in a .dmg.


However, there appears to be a bug in the tarball for version 5.1.30, 
and this note is about that:



I've got my curiosity up, so I've poked into this a bit more:

looking in:

/usr/local/mysql-5.1.30-osx10.4-universal/lib

things are clearly broken for example, we have:

15266468 Nov 20 23:32 libmysqlclient.16.0.0.dylib
4781040 Nov 15 14:57 libmysqlclient.16.dylib

The 16.0.0 version is Universal (ppc, ppc64, and i386), and the 16.dylib 
one is only i386 (and this in on a ppc machine!) different date, too...


But it's not just that. If I look in the ppc build I got from MySQL:

/usr/local/mysql-5.1.30-osx10.4-powerpc/lib

Nov 15 15:29 libmysqlclient.16.0.0.dylib
27 Jan  7 13:13 libmysqlclient.16.dylib -> libmysqlclient.16.0.0.dylib

so the 16.dylib version is supposed to be a symlink to the 16.0.0.dylib 
version, which is the usual *nix practice. Indeed, there are no symlinks 
in the lib dir at all.



So I think the way proper way to fix it is not to copy, but rather to 
fix the symlinks. Here's a script to do it (it needs to be run from the 
lib dir):


#!/bin/sh

# script to fix mysql lib dir in Universal dist

ln -s -f libmysqlclient.16.0.0.dylib libmysqlclient.16.dylib
ln -s -f libmysqlclient.16.0.0.dylib libmysqlclient.dylib

ln -s -f libmysqlclient_r.16.0.0.dylib libmysqlclient_r.16.dylib
ln -s -f libmysqlclient_r.16.0.0.dylib libmysqlclient_r.dylib

(also enclosed as a file)

Now to test the build of the python extension (MySQL-python-1.2.2)

first remove any old build and dist dirs (distutils is not so good at 
cleaning up):


$ rm -rf build dist

now try the build:

$ python setup.py build

no errors, and I see: "-arch ppc -arch i386" in the gcc line, so it 
looks like it's getting a universal build. Poking into:


build/lib.macosx-10.3-ppc-2.5 (distutils isn't really smart about 
Universal, so it creates this dir named for the host system)


I get:
file _mysql.so
_mysql.so: Mach-O universal binary with 2 architectures
_mysql.so (for architecture i386):  Mach-O bundle i386
_mysql.so (for architecture ppc):   Mach-O bundle ppc


which looks good. and:

$ otool -L _mysql.so _mysql.so:
/usr/local/mysql/lib/libmysqlclient_r.16.dylib (compatibility 
version 17.0.0, current version 17.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current 
version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, 
current version 88.3.9)
/usr/lib/libmx.A.dylib (compatibility version 1.0.0, current 
version 47.1.0)


and just to make sure:

$ file /usr/local/mysql/lib/libmysqlclient_r.16.dylib
/usr/local/mysql/lib/libmysqlclient_r.16.dylib: symbolic link to 
`libmysqlclient_r.16.0.0.dylib'


that's the link I created. And:

$ file /usr/local/mysql/lib/libmysqlclient_r.16.0.0.dylib

/usr/local/mysql/lib/libmysqlclient_r.16.0.0.dylib: Mach-O universal 
binary with 3 architectures


/usr/local/mysql/lib/libmysqlclient_r.16.0.0.dylib (for architecture 
i386): Mach-O dynamically linked shared library i386
/usr/local/mysql/lib/libmysqlclient_r.16.0.0.dylib (for architecture 
ppc64):Mach-O 64-bit dynamically linked shared library ppc64
/usr/local/mysql/lib/libmysqlclient_r.16.0.0.dylib (for architecture 
ppc):  Mach-O dynamically linked shared library ppc


Which is what we want.

$ python setup.py install

note: I have setuptools set to never install zip packages, 'cause they 
don't work right with py2app, and I like being able to see what's in 
them, etc. You can do this by creating a .pydistutils.cfg  file in your 
home dir, and putting:


[easy_install]
zip-ok = 0

in it.

now to test:

$ python
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _mysql
>>>

At least it imports -- I don't have anything real to test with!

Further note:

It would be nice to distribute a binary of the python package. However, 
it would depend in that mysql dylib. I think the right way to do it 
would be to link the python extension against the static lib instead. To 
do that, I'm going to (temporarily) remove all the dylibs from the mysql 
lib dir, so it can only link to the static lib.


(in the mysql libs dir)

$ mkdir temp
$ mv *.dylib temp/

now build the python lib again:

$ rm -rf build dist

$ python setup.py build

which ran without errors.

check the lib:

$ otool -L _mysql.so
_mysql.so:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current 
version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility ver

Re: [Pythonmac-SIG] How to get setuptools to build a Universal Binary?

2009-01-08 Thread Christopher Barker

Joe Strout wrote:
Hmm.  This doesn't appear to have worked, but it's failing in an odd way 
that I don't understand.  Here's what I did:


1. The above copying, vebatim.
2. In the MySQL-python-1.2.2 source directory:
   2a. sudo python setup.py clean


I recommend actually deleting the build and dist directories -- 
distutils in not all that good at cleaning up.



 ImportError: No module named MySQLdb


that is odd.


> why is py2app suddenly failing to realize that it should include MySQLdb?

One guess -- I think "setup.py install" puts a zipped egg in by default, 
and py2app does not work well with zipped eggs. I couldn't figure out 
how to tell it not to do that (with easy install, you pass the -Z 
option). However, I set a preferences file so that it would never put in 
zipped eggs:


by creating a .pydistutils.cfg  file in your home dir, and putting:

[easy_install]
zip-ok = 0

in it. (I found that on the web somewhere...)


Take a look at the other note I jsut posted -- I have successfully build 
a Universal version that is statically linked to the mysql lib -- though 
I don't know if it works beyond importing-- can you test for me?


-Chris

PS: I think you may owe me two beers now ;-)



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] How to get setuptools to build a Universal Binary? [SOLVED!]

2009-01-08 Thread Christopher Barker

Joe Strout wrote:
Woot!  I finally got my MySQLdb-using Python app working as a Universal 
Binary!


glad you got it working -- a couple comments for the record:

The root cause of most of the trouble was the broken 5.1 MySQL 
distribution (bug #41940 on the MySQL tracker).


Ned, thanks for posting this bug.



 I tried patching it up  as Ned suggested, but that didn't work for me.


see my recent post: Building MySqldb for Universal Python

It worked fine for me.

3. Reinstalled MySQLdb using the easy method Ned suggested: 
"easy_install -Z MySQL-python".  This worked fine; all the extra hackery 
at 
 
appears to be unnecessary when you use easy_install,


Note that easy_install runs the same old "setup.py build" that you do by 
hand - so the bugs that that post corrects are probably fixed in the source.



By the way, I've build a binary universal egg that should be 
re-distributable - please let me know if you want to test it, or have a 
place to host it.


-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] PythonMagick

2009-01-08 Thread Lyle Gunderson

Has anyone installed PythonMagick on Mac OS X?

I have ImageMagick and Python both installed and working on my Mac,  
so a way to make them work together seems like a great idea.


I found it and downloaded it in source code form. Source code is  
fine, but there is a list of requirements for other bits of software  
that I have never heard of, so I would like to know if this is going  
to work before I start chasing all this stuff down.


Thanks in anticipation,

--Lyle
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] How to get setuptools to build a Universal Binary? [SOLVED!]

2009-01-08 Thread Ned Deily
Chris,

Thanks for all the work on this.  And nice summary!  Just one comment:

In article <4966593d.8060...@noaa.gov>,
 Christopher Barker  wrote:
> By the way, I've build a binary universal egg that should be 
> re-distributable - please let me know if you want to test it, or have a 
> place to host it.

Putting it out on the web isn't worth, IMHO.  I fear it would turn into 
YAPackage that doesn't get updated and eventually causes more trouble 
than it's worth.  Looking back over Joe's experience, my take it that 
the root cause of nearly all of the difficulties was the faulty MySQL 
5.1.30 distribution, which of course he had no reason to assume was bad.  
If he had been lucky enough to start with the 5.0 dist he ended up with 
and followed the standard install of MySQLdb, the MySQL part of his app 
building would have been straightforward.

I think documenting the problem with 5.1.30, which we've done in the 
pythonmac world and on the MySQL tracker, and if necessary "encouraging" 
a resolution over at MySQL are sufficient actions for now.

In any case, just my $0.02.

--Ned

-- 
 Ned Deily,
 n...@acm.org

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] real-time video capturing and processing

2009-01-08 Thread Zachary Pincus

Hi Michael,

I see some faint traces on Google of something called "PySight" that  
can grab images from iSight cameras. There may be some Apple-provided  
frameworks for grabbing iSight images as well, which could be called  
via PyObjC. Failing that, I'm sure you can find some C-level webcam  
drivers for OS X. Writing python wrappers for these (using either  
Cython [an update to pyrex] or even just the Python API) shouldn't be  
a big trouble at all if you've any C experience. (I could provide some  
help/advice along these lines if you need.)


My suggestion is to learn a bit about numpy, the python numerical  
computing module, and it's friend scipy, which provides more domain- 
specific routines. Specifically, passing a chunk of memory  
(representing an image as an array of bytes) from a C library to numpy  
is extremely easy, using the C API or even Cython. And scipy provides  
good image-manipulation tools in its ndimage and signal sub-modules.  
These are all in C and fortran, so real-time should be achievable. The  
numpy and scipy lists have really good folks on them who know their  
stuff (including some imaging people), so if you have specific  
questions about image processing with those tools, definitely ask there.


Alternately, there are python wrappers for OpenCV, which provides a  
TON of basic to advanced imaging stuff. It can be a bit overwhelming,  
but it's good and optimized for speed. (OpenCV has webcam drivers, but  
I don't think they work on OS X.) IMO, the ctypes-based wrappers are  
likely better and easier to use/extend than the SWIG ones.


Visualization might be tricky, though...  you'll likely (?) want some  
way to blit the images to the screen at some point, and so you'll want  
to choose a GUI toolkit. You could use Cocoa with PyObjC, or tkinter,  
or wx, or whatever. Most of these can accept a blob of memory and draw  
it on screen as a image. I use Pyglet, which is a nice, thin, cross- 
platform wrapper for simple windowing and OpenGL. (No widget toolkit  
for pyglet, but I just use it to throw pixels onto a 2D surface as  
fast as possible.) As a bonus, I've written some code that allows you  
to run a pyglet window in the background, which can be controlled from  
the python interpreter. (Most windowing toolkits need their own main()  
routine to run, which precludes interactive control via a python  
shell, unless you embed that in the main(). Ipython has tools to do  
this for wx and tkinter, but it's a bit klugey, IMO.) Ask me if you  
want this code.


Zach Pincus

Postdoctoral Fellow, lab of Frank Slack
Molecular, Cellular and Developmental Biology
Yale University




On Jan 7, 2009, at 9:35 AM, Michael Graber wrote:


hi all,

first: theres a library called VideoCapture for Win32 environments  
which makes it possible to access video-capture devices. is there  
something similar for macs?


second: i would like to do real-time video-processing (like bright- 
spot detection, movement detection, ...) using images recorded by a  
webcam. is python suited to do so? any references?


i appreciate your hints to this quite crude question.

best,
michael
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig








___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] MySQLdb Universal binary: call for testers

2009-01-08 Thread Christopher Barker

Hi folks,

I've built what I think should be a binary egg for mySQLdb. It should 
work for the python.org Universal build of python2.5, on OS-X 10.3.9 and 
above.


However, it hasn't really been tested.

I haven't enclosed it here, as it's about 3MB, but if you drop me a 
note, I'll send it to you to test.


Once it's been tested, the MySQLdb folks have offered to put it up on 
their sourceforge download page, which would be nice.


-Chris




--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig