Bug#1067163: mapnik: Fails to build with Python 3.12
Benjamin Drung
bdrung at debian.org
Tue Mar 19 15:52:05 GMT 2024
Source: mapnik
Version: 3.1.0+ds-7
Severity: normal
Tags: patch
X-Debbugs-Cc: bdrung at debian.org
Dear Maintainer,
mapnik fails to build on Ubuntu with Python 3.12 due to the Scons
version in the package. I applied the attached patch to Ubuntu to use
the scons Debian package.
--
Benjamin Drung
Debian & Ubuntu Developer
-------------- next part --------------
diff -Nru mapnik-3.1.0+ds/debian/changelog mapnik-3.1.0+ds/debian/changelog
--- mapnik-3.1.0+ds/debian/changelog 2024-03-02 13:14:12.000000000 +0100
+++ mapnik-3.1.0+ds/debian/changelog 2024-03-19 16:40:34.000000000 +0100
@@ -1,3 +1,10 @@
+mapnik (3.1.0+ds-7ubuntu1) noble; urgency=medium
+
+ * Use scons from the Debian package (for Python 3.12 support)
+ * Cherry-pick SConstruct upstream changes for Scons >= 4.1.0
+
+ -- Benjamin Drung <bdrung at ubuntu.com> Tue, 19 Mar 2024 16:40:34 +0100
+
mapnik (3.1.0+ds-7) unstable; urgency=medium
* Add dpkg-dev (>= 1.22.5) to build dependencies for t64 changes.
diff -Nru mapnik-3.1.0+ds/debian/control mapnik-3.1.0+ds/debian/control
--- mapnik-3.1.0+ds/debian/control 2024-03-02 13:14:02.000000000 +0100
+++ mapnik-3.1.0+ds/debian/control 2024-03-19 16:39:54.000000000 +0100
@@ -31,6 +31,7 @@
libxml2-dev,
pkgconf,
python3,
+ scons,
zlib1g-dev
Standards-Version: 4.6.2
Vcs-Browser: https://salsa.debian.org/debian-gis-team/mapnik
diff -Nru mapnik-3.1.0+ds/debian/patches/series mapnik-3.1.0+ds/debian/patches/series
--- mapnik-3.1.0+ds/debian/patches/series 2023-11-16 19:00:05.000000000 +0100
+++ mapnik-3.1.0+ds/debian/patches/series 2024-03-19 16:40:34.000000000 +0100
@@ -1,7 +1,7 @@
libxml2.patch
-Stop-using-custom-OrderedDict.patch
proj.patch
gcc-13.patch
boost-1.81.patch
boost-1.83-1.patch
boost-1.83-2.patch
+Upgrade-to-Scons-4.1.0.patch
diff -Nru mapnik-3.1.0+ds/debian/patches/Stop-using-custom-OrderedDict.patch mapnik-3.1.0+ds/debian/patches/Stop-using-custom-OrderedDict.patch
--- mapnik-3.1.0+ds/debian/patches/Stop-using-custom-OrderedDict.patch 2022-02-08 15:30:11.000000000 +0100
+++ mapnik-3.1.0+ds/debian/patches/Stop-using-custom-OrderedDict.patch 1970-01-01 01:00:00.000000000 +0100
@@ -1,156 +0,0 @@
-Description: Stop using custom OrderedDict
- OrdredDict is in the standard library for all supported Python versions
- (2.7 and 3.5+) and has improvements over the ActiveState recipe version
- of OrderedDict we have been using. Switch to importing from collections
- instead of getting it from SCons.Util (tests already did this).
- .
- At the same time, reorganize the Util.py imports - import Iterable
- from collections.abc if possible (it is deprecated to import
- it from collections, will stop working in 3.8); try getting the
- User{Dict,List,String} from collections if possible - that is, try the
- 3.x way first.
-Author: Mats Wichmann <mats at linux.com>
-Origin: https://github.com/SCons/scons/commit/3fa7141ec7b39
-Forwarded: https://github.com/mapnik/mapnik/pull/4294
-Applied-Upstream: https://github.com/mapnik/mapnik/commit/7da9009e7ffffb0b9429890f6f13fee837ac320f
-
---- a/scons/scons-local-3.0.1/SCons/Action.py
-+++ b/scons/scons-local-3.0.1/SCons/Action.py
-@@ -107,6 +107,7 @@ import sys
- import subprocess
- import itertools
- import inspect
-+from collections import OrderedDict
-
- import SCons.Debug
- from SCons.Debug import logInstanceCreation
-@@ -1289,7 +1290,7 @@ class ListAction(ActionBase):
- return result
-
- def get_varlist(self, target, source, env, executor=None):
-- result = SCons.Util.OrderedDict()
-+ result = OrderedDict()
- for act in self.list:
- for var in act.get_varlist(target, source, env, executor):
- result[var] = True
---- a/scons/scons-local-3.0.1/SCons/Tool/javac.py
-+++ b/scons/scons-local-3.0.1/SCons/Tool/javac.py
-@@ -34,6 +34,7 @@ __revision__ = "src/engine/SCons/Tool/ja
-
- import os
- import os.path
-+from collections import OrderedDict
-
- import SCons.Action
- import SCons.Builder
-@@ -70,7 +71,7 @@ def emit_java_classes(target, source, en
- if isinstance(entry, SCons.Node.FS.File):
- slist.append(entry)
- elif isinstance(entry, SCons.Node.FS.Dir):
-- result = SCons.Util.OrderedDict()
-+ result = OrderedDict()
- dirnode = entry.rdir()
- def find_java_files(arg, dirpath, filenames):
- java_files = sorted([n for n in filenames
---- a/scons/scons-local-3.0.1/SCons/Util.py
-+++ b/scons/scons-local-3.0.1/SCons/Util.py
-@@ -37,21 +37,18 @@ import pprint
- PY3 = sys.version_info[0] == 3
-
- try:
-+ from collections import UserDict, UserList, UserString
-+except ImportError:
- from UserDict import UserDict
--except ImportError as e:
-- from collections import UserDict
--
--try:
- from UserList import UserList
--except ImportError as e:
-- from collections import UserList
--
--from collections import Iterable
-+ from UserString import UserString
-
- try:
-- from UserString import UserString
--except ImportError as e:
-- from collections import UserString
-+ from collections.abc import Iterable
-+except ImportError:
-+ from collections import Iterable
-+
-+from collections import OrderedDict
-
- # Don't "from types import ..." these because we need to get at the
- # types module later to look for UnicodeType.
-@@ -63,7 +60,7 @@ MethodType = types.MethodType
- FunctionType = types.FunctionType
-
- try:
-- unicode
-+ _ = type(unicode)
- except NameError:
- UnicodeType = str
- else:
-@@ -1034,60 +1031,6 @@ class CLVar(UserList):
- def __str__(self):
- return ' '.join(self.data)
-
--# A dictionary that preserves the order in which items are added.
--# Submitted by David Benjamin to ActiveState's Python Cookbook web site:
--# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
--# Including fixes/enhancements from the follow-on discussions.
--class OrderedDict(UserDict):
-- def __init__(self, dict = None):
-- self._keys = []
-- UserDict.__init__(self, dict)
--
-- def __delitem__(self, key):
-- UserDict.__delitem__(self, key)
-- self._keys.remove(key)
--
-- def __setitem__(self, key, item):
-- UserDict.__setitem__(self, key, item)
-- if key not in self._keys: self._keys.append(key)
--
-- def clear(self):
-- UserDict.clear(self)
-- self._keys = []
--
-- def copy(self):
-- dict = OrderedDict()
-- dict.update(self)
-- return dict
--
-- def items(self):
-- return list(zip(self._keys, list(self.values())))
--
-- def keys(self):
-- return self._keys[:]
--
-- def popitem(self):
-- try:
-- key = self._keys[-1]
-- except IndexError:
-- raise KeyError('dictionary is empty')
--
-- val = self[key]
-- del self[key]
--
-- return (key, val)
--
-- def setdefault(self, key, failobj = None):
-- UserDict.setdefault(self, key, failobj)
-- if key not in self._keys: self._keys.append(key)
--
-- def update(self, dict):
-- for (key, val) in dict.items():
-- self.__setitem__(key, val)
--
-- def values(self):
-- return list(map(self.get, self._keys))
--
- class Selector(OrderedDict):
- """A callable ordered dictionary that maps file suffixes to
- dictionary values. We preserve the order in which items are added
diff -Nru mapnik-3.1.0+ds/debian/patches/Upgrade-to-Scons-4.1.0.patch mapnik-3.1.0+ds/debian/patches/Upgrade-to-Scons-4.1.0.patch
--- mapnik-3.1.0+ds/debian/patches/Upgrade-to-Scons-4.1.0.patch 1970-01-01 01:00:00.000000000 +0100
+++ mapnik-3.1.0+ds/debian/patches/Upgrade-to-Scons-4.1.0.patch 2024-03-19 16:39:54.000000000 +0100
@@ -0,0 +1,56 @@
+From: Artem Pavlenko <artem at mapnik.org>
+Date: Fri, 5 Mar 2021 10:18:26 +0000
+Subject: Upgrade to Scons 4.1.0
+
+Origin: upstream, https://github.com/mapnik/mapnik/commit/84a05a6597a941acfad220dae3fbfe5d20bfeb26
+---
+ SConstruct | 14 --------------
+ 1 file changed, 14 deletions(-)
+
+diff --git a/SConstruct b/SConstruct
+index b48c4d1..357ec05 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -128,7 +128,6 @@ PLUGINS = { # plugins with external dependencies
+
+ def init_environment(env):
+ env.Decider('MD5-timestamp')
+- env.SourceCode(".", None)
+ if os.environ.get('RANLIB'):
+ env['RANLIB'] = os.environ['RANLIB']
+ if os.environ.get('AR'):
+@@ -317,7 +316,6 @@ opts.AddVariables(
+ BoolVariable('ENABLE_GLIBC_WORKAROUND', "Workaround known GLIBC symbol exports to allow building against libstdc++-4.8 without binaries needing throw_out_of_range_fmt", 'False'),
+ # http://www.scons.org/wiki/GoFastButton
+ # http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script
+- BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'),
+ BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'),
+ ('LINK_PRIORITY','Priority list in which to sort library and include paths (default order is internal, other, frameworks, user, then system - see source of `sort_paths` function for more detail)',','.join(DEFAULT_LINK_PRIORITY)),
+
+@@ -1249,12 +1247,7 @@ def GetMapnikLibVersion():
+ return version_string
+
+ if not preconfigured:
+-
+ color_print(4,'Configuring build environment...')
+-
+- if not env['FAST']:
+- SetCacheMode('force')
+-
+ if env['USE_CONFIG']:
+ if not env['CONFIG'].endswith('.py'):
+ color_print(1,'SCons CONFIG file specified is not a python file, will not be read...')
+@@ -2109,13 +2102,6 @@ if not HELP_REQUESTED:
+
+ Export('plugin_base')
+
+- if env['FAST']:
+- # caching is 'auto' by default in SCons
+- # But let's also cache implicit deps...
+- EnsureSConsVersion(0,98)
+- SetOption('implicit_cache', 1)
+- SetOption('max_drift', 1)
+-
+ # Build agg first, doesn't need anything special
+ if env['RUNTIME_LINK'] == 'shared':
+ SConscript('deps/agg/build.py')
diff -Nru mapnik-3.1.0+ds/debian/rules mapnik-3.1.0+ds/debian/rules
--- mapnik-3.1.0+ds/debian/rules 2023-08-12 21:20:52.000000000 +0200
+++ mapnik-3.1.0+ds/debian/rules 2024-03-19 16:39:54.000000000 +0100
@@ -29,7 +29,7 @@
endif
# scons flags
-SCONS = python3 $(CURDIR)/scons/scons.py
+SCONS = /usr/bin/scons
SCONS_FLAGS := $(NJOBS)
# -O2
SCONS_FLAGS += OPTIMIZATION=2
More information about the Pkg-grass-devel
mailing list