{"id":202,"date":"2013-04-01T18:40:56","date_gmt":"2013-04-01T18:40:56","guid":{"rendered":"http:\/\/www.reades.com\/?p=202"},"modified":"2013-04-01T18:40:56","modified_gmt":"2013-04-01T18:40:56","slug":"plotting-igraph-on-lion-and-mountain-lion","status":"publish","type":"post","link":"http:\/\/www.reades.com\/wp\/?p=202","title":{"rendered":"Plotting &#038; iGraph on Lion and Mountain Lion"},"content":{"rendered":"<p>\t\t\t\t<i>Note: this was previously posted at <a href=\"http:\/\/simulacra.blogs.casa.ucl.ac.uk\/2012\/08\/plotting-and-igraph-on-lion-and-mountain-lion\/\" target=\"_blank\" rel=\"noopener\">simulacra.info<\/a>, but I am in the process of (re)organising my technical notes and tutorials.<\/i><\/p>\n<p>After giving up on Gephi (again, I really should learn), I decided it was time to get to grips with Python and iGraph since I really need to produce multiple iterations of a graph. The matmos at CASA have, of course, been touting Python for ages, but I&#8217;ve just not had the time\/incentive to install and, more importantly, actually get around to using it&#8230; until now. <!--more-->Of course, like all such migrations, there has been a bit of a learning curve, so I&#8217;m documenting this to save you (and me) the trouble later because it turns out that Lion and Mountain Lion aren&#8217;t 100% iGraph friendly out of the box.<\/p>\n<p>iGraph itself is easy to install, you can just download and run the installer from\u00a0<a href=\"http:\/\/igraph.sourceforge.net\/download.html\">SourceForge<\/a>\u00a0but the supporting libraries to enable plotting have some issues. Below is what I\u00a0adapted from information provided by the people at \u00a0<a href=\"http:\/\/ffmpeg.org\/trac\/ffmpeg\/wiki\/MacOSXCompilationGuide\">ffMpeg<\/a>.<\/p>\n<p>You will need to start by grabbing\u00a0<a href=\"http:\/\/tukaani.org\/xz\/\">xz<\/a>, which is (yet another) compression\/decompression library promising better performance than the venerable gz or bzip:<br \/>\n<code><br \/>\n.\/configure<br \/>\nmake &amp;&amp; sudo make install<br \/>\n<\/code><\/p>\n<p>You need xz so that you can decompress glib, but before you can compile glib, you will also need the latest version of\u00a0<a href=\"ftp:\/\/ftp.gnu.org\/gnu\/gettext\/\">gettext<\/a>. Furthermore,\u00a0<a href=\"http:\/\/ffmpeg.org\/trac\/ffmpeg\/wiki\/MacOSXCompilationGuide\">per the instructions<\/a>\u00a0you will need to manually edit one of the files to get it to compile on Lion or Mountain Lion. Namely, open:<\/p>\n<pre>gettext-tools\/gnulib-lib\/stpncpy.c<\/pre>\n<p>and change it such that you have added a line reading:<\/p>\n<pre>#undef stpncpy<\/pre>\n<p>just before the line reading:<\/p>\n<pre>#ifndef weak_alias<\/pre>\n<p>From there, it&#8217;s your usual:<br \/>\n<code><br \/>\n.\/configure<br \/>\nmake &amp;&amp; sudo make install<br \/>\n<\/code><\/p>\n<p>Now you can finally move on to installing\u00a0<a href=\"http:\/\/ftp.gnome.org\/pub\/GNOME\/sources\/glib\/2.33\/\">glib<\/a>, which will be need for compiling Cairo properly. Note that this is the point where you have to start passing in more and more command line arguments to configure:<br \/>\n<code><br \/>\nxz -d glib-2.33.10.tar.xz<br \/>\ntar -xvf\u00a0glib-2.33.10.tar<br \/>\ncd glib-2.33.10<br \/>\nLIBFFI_CFLAGS=-I\/usr\/include\/ffi LIBFFI_LIBS=-lffi .\/configure; make &amp;&amp; sudo make\u00a0install<br \/>\n<\/code><\/p>\n<p>Phew, we&#8217;re getting there. Now it&#8217;s time for\u00a0<a href=\"http:\/\/pkgconfig.freedesktop.org\/releases\/\">pkg-config<\/a>:<br \/>\n<code><br \/>\nGLIB_CFLAGS=\"-I\/usr\/local\/include\/glib-2.0 -I\/usr\/local\/lib\/glib-2.0\/include\" GLIB_LIBS=\"-lglib-2.0 -lgio-2.0\" .\/configure --with-pc-path=\"\/usr\/X11\/lib\/pkgconfig:\/usr\/X11\/share\/pkgconfig:\/usr\/lib\/pkgconfig:\/usr\/local\/lib\/pkgconfig\"<br \/>\nmake &amp;&amp; sudo make install<br \/>\n<\/code><\/p>\n<p>I was able to skip straight to installing pycairo because I had already installed Cairo as part of my last update to\u00a0<a href=\"http:\/\/www.qgis.org\/\">QGIS<\/a>. The excellent\u00a0<a href=\"http:\/\/www.kyngchaos.com\/\">KyngChaos<\/a>\u00a0has a\u00a0<a href=\"http:\/\/www.kyngchaos.com\/software\/unixport\">handy set of installers<\/a>\u00a0to keep things simple.<\/p>\n<p>And finally it&#8217;s time for\u00a0<a href=\"http:\/\/www.cairographics.org\/pycairo\/\">pyCairo<\/a>\u00a0(you probably want py2cairo since OSX is using Python 2.7):<br \/>\n<code><br \/>\n.\/waf configure<br \/>\n.\/waf build<br \/>\nsudo .\/waf install<\/code><\/p>\n<p>You may also care to add this line to your<\/p>\n<pre>.bash_login<\/pre>\n<p>file:<br \/>\n<code><br \/>\nexport PYTHONPATH=\"\/usr\/lib\/python2.7:$PYTHONPATH\"<br \/>\n<\/code><br \/>\n(You may also\u00a0<i>not<\/i>\u00a0want to add\u00a0<code>python2.6<\/code>\u00a0or\u00a0<code>python2.5<\/code>\u00a0to your Python path since this will give you some interesting errors&#8230; as I discovered.)\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note: this was previously posted at simulacra.info, but I am in the process of (re)organising my technical notes and tutorials. After giving up on Gephi (again, I really should learn), I decided it was time to get to grips with Python and iGraph since I really need to produce multiple iterations of a graph. The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[58,74,85,114],"class_list":["post-202","post","type-post","status-publish","format-standard","hentry","category-tutorials","tag-igraph","tag-networks","tag-python","tag-visualisation"],"_links":{"self":[{"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=202"}],"version-history":[{"count":0,"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/202\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.reades.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}