[python-mapnik] 01/02: Also build bindings for Python 3.

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Thu Jul 23 20:24:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository python-mapnik.

commit 2e1a243349e1be10fe14a625cd7a58c058275cc5
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Thu Jul 23 19:44:52 2015 +0200

    Also build bindings for Python 3.
    
    Add patch for Python 3 support in setup.py.
    Add patch to fix SyntaxError with Python 3.
---
 debian/changelog                   |   6 ++
 debian/control                     |  23 +++++++-
 debian/patches/python3-print.patch |  17 ++++++
 debian/patches/python3-setup.patch | 114 +++++++++++++++++++++++++++++++++++++
 debian/patches/series              |   2 +
 debian/rules                       |   2 +-
 6 files changed, 162 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2d1f290..a281f1e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-mapnik (1:0.0~20150708-c005502-2) UNRELEASED; urgency=medium
+
+  * Also build bindings for Python 3.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Thu, 23 Jul 2015 21:46:44 +0200
+
 python-mapnik (1:0.0~20150708-c005502-1) unstable; urgency=medium
 
   * Initial release. (Closes: #792539)
diff --git a/debian/control b/debian/control
index 247b762..cf0d861 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,10 @@ Build-Depends: debhelper (>= 9),
                libmapnik-dev (>= 3.0.0+ds-2),
                python-all-dev,
                python-setuptools,
-               python-nose
+               python-nose,
+               python3-all-dev,
+               python3-setuptools,
+               python3-nose
 Standards-Version: 3.9.6
 Vcs-Browser: http://anonscm.debian.org/cgit/pkg-grass/python-mapnik.git
 Vcs-Git: git://anonscm.debian.org/pkg-grass/python-mapnik.git
@@ -34,3 +37,21 @@ Description: Python 2 interface to the mapnik library
  .
  This package contains the bindings for Python 2.
 
+Package: python3-mapnik
+Architecture: any
+Depends: ${python3:Depends},
+         ${shlibs:Depends},
+         ${misc:Depends}
+Provides: ${python3:Provides}
+Description: Python 3 interface to the mapnik library
+ Mapnik is an OpenSource C++ toolkit for developing GIS
+ (Geographic Information Systems) applications. At the core is a C++
+ shared library providing algorithms/patterns for spatial data access and
+ visualization.
+ .
+ Essentially a collection of geographic objects (map, layer, datasource,
+ feature, geometry), the library doesn't rely on "windowing systems" and
+ is intended to work in multi-threaded environments
+ .
+ This package contains the bindings for Python 3.
+
diff --git a/debian/patches/python3-print.patch b/debian/patches/python3-print.patch
new file mode 100644
index 0000000..e1e1a00
--- /dev/null
+++ b/debian/patches/python3-print.patch
@@ -0,0 +1,17 @@
+Description: Add missing parentheses in call to 'print'.
+ With Python 3 the missing parentheses are a SyntaxError.
+Author: Bas Couwenberg <sebastic at debian.org>
+Bug: https://github.com/mapnik/python-mapnik/issues/36
+Forwarded: https://github.com/mapnik/python-mapnik/issues/40
+
+--- a/mapnik/printing.py
++++ b/mapnik/printing.py
+@@ -942,7 +942,7 @@ class PDFPrinter:
+                                     try:
+                                         sym.avoid_edges=False
+                                     except:
+-                                        print "**** Cant set avoid edges for rule", r.name
++                                        print("**** Cant set avoid edges for rule", r.name)
+                                 if r.min_scale <= m.scale_denominator() and m.scale_denominator() < r.max_scale:
+                                     lerule = r
+                                     lerule.min_scale = 0
diff --git a/debian/patches/python3-setup.patch b/debian/patches/python3-setup.patch
new file mode 100644
index 0000000..d3964ac
--- /dev/null
+++ b/debian/patches/python3-setup.patch
@@ -0,0 +1,114 @@
+From 9f4b6e02e88a97f217d9fa12c5cc217d47f5f415 Mon Sep 17 00:00:00 2001
+From: Yohan Boniface <yb at enix.org>
+Date: Thu, 16 Jul 2015 23:20:59 +0200
+Subject: [PATCH] python2/3 compliant setup.py
+
+---
+ setup.py | 36 ++++++++++++++++++++++++------------
+ 1 file changed, 24 insertions(+), 12 deletions(-)
+
+--- a/setup.py
++++ b/setup.py
+@@ -8,6 +8,18 @@ import sys
+ import shutil
+ import re
+ 
++P3 = sys.version_info[0] == 3
++
++
++# Utils
++def check_output(args):
++    output = subprocess.check_output(args)
++    if P3:
++        # check_output returns bytes in P3.
++        output = output.decode()
++    return output.rstrip('\n')
++
++
+ cflags = sysconfig.get_config_var('CFLAGS')
+ sysconfig._config_vars['CFLAGS'] = re.sub(' +', ' ', cflags.replace('-g', '').replace('-Os', '').replace('-arch i386', ''))
+ opt = sysconfig.get_config_var('OPT')
+@@ -35,13 +47,13 @@ boost_system_lib = os.environ.get("BOOST
+ boost_thread_lib = os.environ.get("BOOST_THREAD_LIB", 'boost_thread')
+ 
+ try:
+-    linkflags = subprocess.check_output([mapnik_config, '--libs']).rstrip('\n').split(' ')
++    linkflags = check_output([mapnik_config, '--libs']).split(' ')
+     lib_path = linkflags[0][2:]
+-    linkflags.extend(subprocess.check_output([mapnik_config, '--ldflags']).rstrip('\n').split(' '))
++    linkflags.extend(check_output([mapnik_config, '--ldflags']).split(' '))
+ except:
+-    raise Exception("Failed to find proper linking flags from mapnik config");
++    raise Exception("Failed to find proper linking flags from mapnik config")
+ 
+-## Dynamically make the mapnik/paths.py file if it doesn't exist.
++# Dynamically make the mapnik/paths.py file if it doesn't exist.
+ if os.path.isfile('mapnik/paths.py'):
+     create_paths = False
+ else:
+@@ -60,7 +72,7 @@ if mason_build:
+         shutil.copyfile(f, os.path.join('mapnik', base_f))
+     except shutil.Error:
+         pass
+-    input_plugin_path = subprocess.check_output([mapnik_config, '--input-plugins']).rstrip('\n')
++    input_plugin_path = check_output([mapnik_config, '--input-plugins'])
+     input_plugin_files = os.listdir(input_plugin_path)
+     input_plugin_files = [os.path.join(input_plugin_path, f) for f in input_plugin_files]
+     if not os.path.exists(os.path.join('mapnik','plugins','input')):
+@@ -70,7 +82,7 @@ if mason_build:
+             shutil.copyfile(f, os.path.join('mapnik', 'plugins', 'input', os.path.basename(f)))
+         except shutil.Error:
+             pass
+-    font_path = subprocess.check_output([mapnik_config, '--fonts']).rstrip('\n')
++    font_path = check_output([mapnik_config, '--fonts'])
+     font_files = os.listdir(font_path)
+     font_files = [os.path.join(font_path, f) for f in font_files]
+     if not os.path.exists(os.path.join('mapnik','plugins','fonts')):
+@@ -94,7 +106,7 @@ if create_paths:
+ 
+ 
+ if not mason_build:
+-    icu_path = subprocess.check_output([mapnik_config, '--icu-data']).rstrip('\n')
++    icu_path = check_output([mapnik_config, '--icu-data'])
+ else:
+     icu_path = 'mason_packages/.link/share/icu/'
+ if icu_path:
+@@ -109,7 +121,7 @@ if icu_path:
+             pass
+ 
+ if not mason_build:
+-    gdal_path = subprocess.check_output([mapnik_config, '--gdal-data']).rstrip('\n')
++    gdal_path = check_output([mapnik_config, '--gdal-data'])
+ else:
+     gdal_path = 'mason_packages/.link/share/gdal/'
+     if os.path.exists('mason_packages/.link/share/gdal/gdal/'):
+@@ -126,7 +138,7 @@ if gdal_path:
+             pass
+ 
+ if not mason_build:
+-    proj_path = subprocess.check_output([mapnik_config, '--proj-lib']).rstrip('\n')
++    proj_path = check_output([mapnik_config, '--proj-lib'])
+ else:
+     proj_path = 'mason_packages/.link/share/proj/'
+     if os.path.exists('mason_packages/.link/share/proj/proj/'):
+@@ -142,7 +154,7 @@ if proj_path:
+         except shutil.Error:
+             pass
+ 
+-extra_comp_args = subprocess.check_output([mapnik_config, '--cflags']).rstrip('\n').split(' ')
++extra_comp_args = check_output([mapnik_config, '--cflags']).split(' ')
+ 
+ if sys.platform == 'darwin':
+     extra_comp_args.append('-mmacosx-version-min=10.8')
+@@ -153,9 +165,9 @@ else:
+     linkflags.append('-Wl,-rpath=$ORIGIN')
+ 
+ if os.environ.get("CC",False) == False:
+-    os.environ["CC"] = subprocess.check_output([mapnik_config, '--cxx']).rstrip('\n')
++    os.environ["CC"] = check_output([mapnik_config, '--cxx'])
+ if os.environ.get("CXX",False) == False:
+-    os.environ["CXX"] = subprocess.check_output([mapnik_config, '--cxx']).rstrip('\n')
++    os.environ["CXX"] = check_output([mapnik_config, '--cxx'])
+ 
+ setup(
+     name = "mapnik",
diff --git a/debian/patches/series b/debian/patches/series
index 9df6f28..9843b63 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
 link-boost.patch
+python3-setup.patch
+python3-print.patch
diff --git a/debian/rules b/debian/rules
index 9f96e6a..8f6d403 100755
--- a/debian/rules
+++ b/debian/rules
@@ -8,7 +8,7 @@ export PYBUILD_NAME=mapnik
 
 %:
 	dh $@ \
-		--with python2 \
+		--with python2,python3 \
 		--buildsystem=pybuild \
 		--parallel
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-mapnik.git



More information about the Pkg-grass-devel mailing list