2009/04/13

Grr OSX and Python.

So, I have a new MacBook. (For work, but, it's at home now).

I thought to myself - I'll have a little mess around with directed graphs in python.

So, I installed the igraph python package into the default python in OSX 1.5.3 - which is python 2.5.1

And discovered that cairo - the vectorised rendering package that igraph wants to use to display plots of your graphs - isn't installed.

So:

easy_install pycairo

(chug chug chug - error, you need python >= 2.6)

Great, I think, that's easy.

Go to www.python.org, grab latest OSX installer for python 2.6.1, run, install.

> python
"Hi, I'm still version 2.5.1, since the installer installs to a totally different location than the defaults for preinstalled python."

> export $PATH=/usr/local/bin:$PATH

> python
"Ok, you got me, I'm 2.6"

Right.

> easy_install pycairo
(chug chug chug - nope, you've still not got anything greater than 2.5 installed)

*sound of MacBook flying through open window*

(Oh, and installing from the pycairo package on the Cairo website results in an apparently successful install ... but python2.6 can't see the module. Nor can it see anything I've installed in python2.5 - and I can't work out where the python2.5 stuff has been put.)

EDITed to add: So, adding the location of the Framework build of python2.6 makes cairo importable in 2.6... but even Finder doesn't seem to know where the 2.5 packages I installed with MacPorts are...

EDITED again, to add: Hm. MacPorts seems unable to realise that I have python2.6 installed, and I'm not sure how to tell it. So far, my potential fun morning of playing with python has turned into something considerably more frustrating than OSX is supposed to be - I'd have done this in minutes in Ubuntu!
As soon as Jaunty comes out, I'm repartitioning this thing to have a decent, working, OS on it.

THIRD EDIT:
More hm. Something seems to be broken about python package install with setup.py now, too.
Downloading igraph and (with python2.6 as the default python in my path) in the root of the unpacked directory:
sam-skipseys-macbook:python-igraph-0.5.1 samskipsey$ python setup.py config
setup.py:25: DeprecationWarning: os.popen3 is deprecated. Use the subprocess module.
to_child, from_child, err_child = popen3(command)
Include path: /usr/include/igraph /usr/local/include/igraph
Library path:
running config
sam-skipseys-macbook:python-igraph-0.5.1 samskipsey$ python setup.py build
setup.py:25: DeprecationWarning: os.popen3 is deprecated. Use the subprocess module.
to_child, from_child, err_child = popen3(command)
Include path: /usr/include/igraph /usr/local/include/igraph
Library path:
running build
running build_py
running build_ext
running build_scripts
creating build/scripts-2.6
copying and adjusting scripts/igraph -> build/scripts-2.6
changing mode of build/scripts-2.6/igraph from 644 to 755
sam-skipseys-macbook:python-igraph-0.5.1 samskipsey$ sudo python setup.py install
setup.py:25: DeprecationWarning: os.popen3 is deprecated. Use the subprocess module.
to_child, from_child, err_child = popen3(command)
Include path: /usr/include/igraph /usr/local/include/igraph
Library path:
running install
running bdist_egg
running egg_info
writing python_igraph.egg-info/PKG-INFO
writing top-level names to python_igraph.egg-info/top_level.txt
writing dependency_links to python_igraph.egg-info/dependency_links.txt
reading manifest file 'python_igraph.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'debian/changelog'
warning: no files found matching 'debian/control'
warning: no files found matching 'debian/prepare'
writing manifest file 'python_igraph.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.3-i386/egg
running install_lib
running build_py
running build_ext
creating stub loader for igraph/core.so
byte-compiling build/bdist.macosx-10.3-i386/egg/igraph/core.py to core.pyc
installing package data to build/bdist.macosx-10.3-i386/egg
running install_data
error: can't copy '/usr/local/lib/libigraph.dylib': doesn't exist or not a regular file

Which is just a bit shit, really.

FINAL EDIT:
Finally, it works, after hand-editing the setup.py that igraph uses. Tch.

2 comments:

Unknown said...

What did you edit? I'm having the same problem with libigraph.0.dylib and google returns your blog for questions about it.
Thanks.

Unknown said...

I changed the

if "macosx" in plat:
data_files = [('/usr/lib', [ list of locations for libigraph ])]

block so that the list of locations was in /opt/local/lib/ rather than /usr/local/lib/
and therefore reflected the actual situation better.