Opened 15 years ago

Closed 15 years ago

#19114 closed submission (fixed)

New Port: Mapnik

Reported by: dbsgeo@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 1.7.0
Keywords: gis, graphics, boost, python Cc: mf2k (Frank Schima)
Port: Mapnik

Description

A few other tickets (#12784,#18071) have posted Portfiles for Mapnik.

Here is an updated port for the new 0.6.0 release, in the hopes that the core MacPorts team can help push it over a few last hurdles.

This document (hosted where I developed the portfile) describes a notable problem with boost:

http://mapnik-utils.googlecode.com/svn/sandbox/ports/README.txt

Attachments (7)

Portfile (4.2 KB) - added by dbsgeo@… 15 years ago.
Portfile against svn tag of Mapnik 0.6.0 (for development - ultimately we can build against tarred release)
Portfile.2 (4.2 KB) - added by dbsgeo@… 15 years ago.
Updated portfile that fetches from tarred release
Portfile.3 (4.2 KB) - added by mf2k (Frank Schima) 15 years ago.
I'm attaching my version of the portfile with some fixes such as switching to bzip2 so it downloads.
Portfile.4 (4.2 KB) - added by dbsgeo@… 15 years ago.
Portfile.5 (4.2 KB) - added by dbsgeo@… 15 years ago.
Python 2.6 Port (abandoning python25 version)
patch-src-Sconscript.diff (668 bytes) - added by dbsgeo@… 15 years ago.
install_name patch to allow libmapnik.dylib to be found by python bindings without setting DYLD_LIBRARY_PATH
Portfile.6 (4.6 KB) - added by dbsgeo@… 15 years ago.
Mapnik Portfile working with boost 1.38 and python26

Download all attachments as: .zip

Change History (22)

Changed 15 years ago by dbsgeo@…

Attachment: Portfile added

Portfile against svn tag of Mapnik 0.6.0 (for development - ultimately we can build against tarred release)

comment:1 Changed 15 years ago by raimue (Rainer Müller)

Tarballs seem to be available already.

Changed 15 years ago by dbsgeo@…

Attachment: Portfile.2 added

Updated portfile that fetches from tarred release

comment:2 Changed 15 years ago by mf2k (Frank Schima)

Port: Mapnik added

comment:3 Changed 15 years ago by mf2k (Frank Schima)

Cc: macsforever2000@… added

Cc Me!

comment:4 Changed 15 years ago by mf2k (Frank Schima)

I'm not able to get this to run. It builds fine, but I see the following error in ipython2.5

$ ipython2.5 
Python 2.5.4 (r254:67916, Apr 11 2009, 14:47:01) 
Type "copyright", "credits" or "license" for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import mapnik
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

/Users/frank/Downloads/mapnik-0.6.0/scons/<ipython console> in <module>()

/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mapnik/__init__.py in <module>()
     52 setdlopenflags(RTLD_NOW | RTLD_GLOBAL)
     53 
---> 54 from _mapnik import *
     55 from paths import inputpluginspath, fontscollectionpath
     56 

ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mapnik/_mapnik.so, 10): Library not loaded: libmapnik.dylib
  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mapnik/_mapnik.so
  Reason: image not found

Changed 15 years ago by mf2k (Frank Schima)

Attachment: Portfile.3 added

I'm attaching my version of the portfile with some fixes such as switching to bzip2 so it downloads.

comment:5 Changed 15 years ago by dbsgeo@…

Great, thanks for taking a look at this and for the fixes.

I'm curious about the switch to using:

FRAMEWORK_PYTHON=True

My experience is that will more likely link the python module against the system python, and will create a version mismatch if boost is correctly linked to the macports python (but see #17998).

What does this give on your system?

otool -L /opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mapnik/_mapnik.so

And

otool -L /opt/local/lib/mapnik/libmapnik.dylib

Regarding the error, this is happening because libmapnik.dylib is likely installed in

/opt/local/lib/mapnik/libmapnik.dylib

but not automatically found without:

export DYLD_LIBRARY_PATH=/opt/local/lib/mapnik/

Does setting that allow the library to be found?

comment:6 Changed 15 years ago by dbsgeo@…

Okay, looks like I've got a fix for the library issue. Using export DYLD_LIBRARY_PATH=/opt/local/lib/ is a disaster.

Here is a patch that fixes things by providing the full path to the library location:

See: http://qin.laya.com/tech_coding_help/dylib_linking.html

Index: src/SConscript
===================================================================
--- src/SConscript	(revision 1105)
+++ src/SConscript	(working copy)
@@ -31,13 +31,15 @@
 
 install_prefix = env['DESTDIR'] + '/' + prefix
 
+libdir = os.path.normpath(install_prefix + '/' + env['LIBDIR_SCHEMA'])
+
 libraries = env['LIBS']
 
 if env['INTERNAL_LIBAGG']:
     libraries.insert(0, 'agg')
 
 if env['PLATFORM'] == 'Darwin':
-    linkflags = '-Wl,-install_name,libmapnik.dylib'
+    linkflags = '-Wl,-install_name,%s/libmapnik.dylib' % libdir
 elif env['PLATFORM'] == 'SunOS' and env['CXX'].startswith('CC'):
     linkflags = '-R. -h libmapnik.so'
 else: # Linux and others

comment:7 Changed 15 years ago by dbsgeo@…

Also, attaching a new portfile which removes the optional LIB_DIR_NAME usage (which does not affect the libmapnik.dylib but will result in problems with fonts due to a bug now fixed in trunk.

Changed 15 years ago by dbsgeo@…

Attachment: Portfile.4 added

comment:8 Changed 15 years ago by dbsgeo@…

Okay, I've given up with python25 because the boost python port can link against it.

But the python26 install with boost +python26 works.

So, I'm attaching a new Portfile for python 26 from here:

http://mapnik-utils.googlecode.com/svn/sandbox/ports/graphics/py26-mapnik/Portfile

with a slightly improved 'src/SConscript' patch as well.

It will need python26 rebuilt after:

http://trac.macports.org/changeset/50085

Changed 15 years ago by dbsgeo@…

Attachment: Portfile.5 added

Python 2.6 Port (abandoning python25 version)

Changed 15 years ago by dbsgeo@…

Attachment: patch-src-Sconscript.diff added

install_name patch to allow libmapnik.dylib to be found by python bindings without setting DYLD_LIBRARY_PATH

comment:9 Changed 15 years ago by dbsgeo@…

This Portfile is now working great for the first time for me with Portfile.5, the corresponding patch, and these steps:

sudo port install python26 python_select
sudo python_select python26
sudo port install jam 
sudo port install boost +icu +python26
sudo port install py26-mapnik

comment:10 Changed 15 years ago by dbsgeo@…

I should mention that one small problem still exists.

The SCons build tool is failing to properly sense build targets so all files are being compiled twice. Adding the argument --debug=explain show that SCons is being dumb here so I need to look into why this as happening as it makes the build take twice as long.

An alternative would be to build and install in one fell swoop but I'm not sure about how to do that in the Portfile syntax yet.

comment:11 Changed 15 years ago by dbsgeo@…

Okay, now using configure solves the above problem of double compilation. Portfile again updated, but I'm making small tweaks to the variant options now so until I'm finished the current Portfile can be found at:

http://mapnik-utils.googlecode.com/svn/sandbox/ports/graphics/py26-mapnik/Portfile

Changes made to solve the above problem were: http://code.google.com/p/mapnik-utils/source/detail?r=676#

comment:12 Changed 15 years ago by jmroot (Joshua Root)

Type: enhancementsubmission

comment:13 Changed 15 years ago by (none)

Milestone: Port Submissions

Milestone Port Submissions deleted

comment:14 Changed 15 years ago by dbsgeo@…

Okay, I've found no more major changes needed since my previous comment about fixing the duplicate configure.

As far as I'm concerned this is ready for submission.

I will attach the Portfile again which should be used with the previously attached patch.

Changed 15 years ago by dbsgeo@…

Attachment: Portfile.6 added

Mapnik Portfile working with boost 1.38 and python26

comment:15 Changed 15 years ago by raimue (Rainer Müller)

Resolution: fixed
Status: newclosed

Committed in r50498.

Note: See TracTickets for help on using tickets.