maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH] [v3][ocitysmap] Mapnik 2.1: update INSTALL and


From: Jeroen van Rijn
Subject: [Maposmatic-dev] [PATCH] [v3][ocitysmap] Mapnik 2.1: update INSTALL and get rid of DeprecationWarning
Date: Thu, 5 Apr 2012 08:39:06 +0200

As of mapnik commit 14700dba16146902ca98fdcacb72b2fba4fa596a,
using 'import mapnik2' raises a DeprecationWarning.
See https://github.com/mapnik/mapnik/issues/941 for details.

Update imports of the mapnik module to use 'import mapnik' and assert
that the installed version is new enough.

We need mapnik 2.1.0 (or at least a version newer than 2.0.0
that supports placement-type="simple") for the Printable Stylesheet,
as per David's suggestion. Thomas pointed out that having the note
in all files was overkill, this patch takes that into account.

Also update INSTALL with instructions on how to build Mapnik from Git
and which specifically tested commit to use if the latest version
doesn't work.

CC: address@hidden
CC: address@hidden
CC: address@hidden
Tested-by: Jeroen van Rijn <address@hidden>
Signed-off-by: Jeroen van Rijn <address@hidden>
---
 INSTALL                                       |   29 ++++++++++++++++---------
 ocitysmap2/coords.py                          |   14 ++++++++----
 ocitysmap2/layoutlib/abstract_renderer.py     |    8 +++----
 ocitysmap2/layoutlib/multi_page_renderer.py   |    8 +++----
 ocitysmap2/layoutlib/single_page_renderers.py |    8 +++----
 ocitysmap2/maplib/map_canvas.py               |   15 +++++++++----
 6 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/INSTALL b/INSTALL
index c82157e..620a717 100644
--- a/INSTALL
+++ b/INSTALL
@@ -145,7 +145,7 @@ are using. They have been tested on several x86_64 hosts.
 
  8. Install Mapnik
 
-    We need Mapnik 2.0.0, which is not yet available in stable
+    We need Mapnik 2.1.0, which is not yet available in stable
     Debian/Ubuntu, so we need to compile it from source.
 
     a. Install the dependencies
@@ -166,16 +166,13 @@ are using. They have been tested on several x86_64 hosts.
         libboost-regex1.46-dev libboost-serialization1.46-dev \
         libboost-system1.46-dev libboost-thread1.46-dev
 
-    b. Download Mapnik
+    b. Download the latest Mapnik from its Git repository
 
-    wget http://download.berlios.de/mapnik/mapnik-2.0.0.tar.bz2
+    git clone git://github.com/mapnik/mapnik.git
 
-    c. Compile and install Mapnik 2
+    cd mapnik
 
-    tar xvjf mapnik-2.0.0.tar.bz2
-    cd mapnik-2.0.0
-
-    (any version >= 2.0.0 should follow the same scheme)
+    c. Compile and install Mapnik
 
     python scons/scons.py configure INPUT_PLUGINS=all \
       OPTIMIZATION=3 SYSTEM_FONTS=/usr/share/fonts/
@@ -187,9 +184,21 @@ are using. They have been tested on several x86_64 hosts.
 
     python scons/scons.py install
 
-    d. Check the installation
+    d. If building Mapnik failed
+
+    Cloning the repository (step 8b) implicitly runs 'git checkout HEAD',
+    giving you the latest version. Should you run into trouble either 
installing
+    or running this latest version, you can use the version we know to work:
+
+    git checkout c88fcc8f # Note: replace this with commit hash of version on 
dev.m.o
+
+    python scons/scons.py -c # Clean up failed build
+
+    Repeat step 8c.
+
+    e. Check the installation
 
-    Run a Python interpreter, and run "import mapnik2". If it doesn't
+    Run a Python interpreter, and run "import mapnik". If it doesn't
     work and you didn't do a system-wide installation of Mapnik, don't
     forget to set the PYTHONPATH and LD_LIBRARY_PATH environment
     variables.
diff --git a/ocitysmap2/coords.py b/ocitysmap2/coords.py
index 3050c71..32c1426 100644
--- a/ocitysmap2/coords.py
+++ b/ocitysmap2/coords.py
@@ -25,10 +25,16 @@
 import math
 
 import shapely.wkt
-try:
-    import mapnik2 as mapnik
-except ImportError:
-    import mapnik
+
+# Importing mapnik2 raises a DeprecationWarning as of mapnik
+# commit 14700dba. As mapnik 2.1 (or git version with support for
+# placement-type="simple") is required for OCitySMap (see INSTALL),
+# instead of importing mapnik2, we import mapnik and assert it isn't
+# an old version.
+import mapnik
+assert mapnik.mapnik_version >= 200100, \
+    "Mapnik module version %s is too old, see ocitysmap's INSTALL " \
+    "for more details." % mapnik.mapnik_version_string()
 
 _MAPNIK_PROJECTION = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 " \
                      "+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m   " \
diff --git a/ocitysmap2/layoutlib/abstract_renderer.py 
b/ocitysmap2/layoutlib/abstract_renderer.py
index 5517ab9..6a71f75 100644
--- a/ocitysmap2/layoutlib/abstract_renderer.py
+++ b/ocitysmap2/layoutlib/abstract_renderer.py
@@ -27,10 +27,10 @@ import math
 import os
 import sys
 import cairo
-try:
-    import mapnik2 as mapnik
-except ImportError:
-    import mapnik
+import mapnik
+assert mapnik.mapnik_version >= 200100, \
+    "Mapnik module version %s is too old, see ocitysmap's INSTALL " \
+    "for more details." % mapnik.mapnik_version_string()
 import pango
 import re
 
diff --git a/ocitysmap2/layoutlib/multi_page_renderer.py 
b/ocitysmap2/layoutlib/multi_page_renderer.py
index e41af24..9ec1808 100644
--- a/ocitysmap2/layoutlib/multi_page_renderer.py
+++ b/ocitysmap2/layoutlib/multi_page_renderer.py
@@ -25,10 +25,10 @@ import tempfile
 import math
 import sys
 import cairo
-try:
-    import mapnik2 as mapnik
-except ImportError:
-    import mapnik
+import mapnik
+assert mapnik.mapnik_version >= 200100, \
+    "Mapnik module version %s is too old, see ocitysmap's INSTALL " \
+    "for more details." % mapnik.mapnik_version_string()
 import coords
 import locale
 import pangocairo
diff --git a/ocitysmap2/layoutlib/single_page_renderers.py 
b/ocitysmap2/layoutlib/single_page_renderers.py
index 172f8bf..1f7aa05 100644
--- a/ocitysmap2/layoutlib/single_page_renderers.py
+++ b/ocitysmap2/layoutlib/single_page_renderers.py
@@ -26,10 +26,10 @@ import math
 import datetime
 import cairo
 import locale
-try:
-    import mapnik2 as mapnik
-except ImportError:
-    import mapnik
+import mapnik
+assert mapnik.mapnik_version >= 200100, \
+    "Mapnik module version %s is too old, see ocitysmap's INSTALL " \
+    "for more details." % mapnik.mapnik_version_string()
 import pango
 import pangocairo
 
diff --git a/ocitysmap2/maplib/map_canvas.py b/ocitysmap2/maplib/map_canvas.py
index 444a5ff..0db3db4 100644
--- a/ocitysmap2/maplib/map_canvas.py
+++ b/ocitysmap2/maplib/map_canvas.py
@@ -23,10 +23,17 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import logging
-try:
-    import mapnik2 as mapnik
-except ImportError:
-    import mapnik
+
+# Importing mapnik2 raises a DeprecationWarning as of mapnik
+# commit 14700dba. As mapnik 2.1 (or git version with support for
+# placement-type="simple") is required for OCitySMap (see INSTALL),
+# instead of importing mapnik2, we import mapnik and assert it isn't
+# an old version.
+import mapnik
+assert mapnik.mapnik_version >= 200100, \
+    "Mapnik module version %s is too old, see ocitysmap's INSTALL " \
+    "for more details." % mapnik.mapnik_version_string()
+
 import os
 
 from ocitysmap2 import coords
-- 
1.7.10.rc1.22.gf5241




reply via email to

[Prev in Thread] Current Thread [Next in Thread]