Repository navigation
Expand file tree
/
Copy pathpython-mapnik.patch
More file actions
241 lines (227 loc) · 10.3 KB
/
Copy pathpython-mapnik.patch
File metadata and controls
241 lines (227 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
From 32d87a612e91bc04a406669e58d511c91a940336 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: Wed, 22 Jul 2026 12:16:40 +0000
Subject: [PATCH] Various fixes for wheel builds
---
packaging/mapnik/__init__.py | 17 ++++++++
setup.py | 85 ++++++++++++------------------------
src/create_datasource.hpp | 2 +-
src/mapnik_datasource.cpp | 2 +-
src/mapnik_font_engine.cpp | 2 +-
src/mapnik_image.cpp | 2 +-
src/mapnik_rule.cpp | 2 +-
7 files changed, 49 insertions(+), 63 deletions(-)
diff --git a/packaging/mapnik/__init__.py b/packaging/mapnik/__init__.py
index 1fb21c7..64cea4f 100644
--- a/packaging/mapnik/__init__.py
+++ b/packaging/mapnik/__init__.py
@@ -39,6 +39,23 @@ Several things happen when you do:
import itertools
import os
import warnings
+import ctypes.util
+try:
+ ctypes.CDLL(ctypes.util.find_library("stdc++"), mode=ctypes.RTLD_GLOBAL)
+except Exception:
+ pass
+libpath = os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(
+ __file__))), 'mapnik.libs'))
+if os.path.exists(libpath):
+ libs = os.listdir(libpath)
+ libgdalpath = [lib for lib in libs if lib.startswith('libgdal')][0]
+ ctypes.cdll.LoadLibrary(os.path.join(libpath, libgdalpath))
+
+
+
+localpath = os.path.dirname(os.path.abspath( __file__ ))
+os.environ.setdefault("PROJ_DATA", os.path.join(localpath, "proj"))
+os.environ.setdefault("GDAL_DATA", os.path.join(localpath, "gdal"))
def bootstrap_env():
"""
diff --git a/setup.py b/setup.py
index 7afa9e5..780ba70 100755
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
#! /usr/bin/env python3
-from pybind11.setup_helpers import Pybind11Extension, build_ext, ParallelCompile, naive_recompile
+from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup, find_namespace_packages
import sys, subprocess, os, glob
@@ -12,17 +12,8 @@ def check_output(args):
return output.rstrip('\n')
linkflags = []
-bin_path = os.path.join(check_output([mapnik_config, '--prefix']),'bin')
-lib_path = os.path.join(check_output([mapnik_config, '--prefix']),'lib')
-icu_data = check_output([mapnik_config, '--icu-data'])
-proj_lib = check_output([mapnik_config, '--proj-lib'])
-gdal_data = check_output([mapnik_config, '--gdal-data'])
-
-linkflags.extend(check_output([mapnik_config, '--libs']).split(' '))
-linkflags.extend([
- '-lmapnik-wkt',
- '-lmapnik-json',
-])
+lib_path = check_output(['pkg-config', 'libmapnik', '--variable', 'libdir'])
+linkflags.extend(check_output(['pkg-config', 'libmapnik', '--libs']).split(' '))
# Remove symlinks
if os.path.islink('packaging/mapnik/bin') :
@@ -34,50 +25,28 @@ f_paths = open('packaging/mapnik/paths.py', 'w')
f_paths.write('import os\n')
f_paths.write('\n')
-if os.environ.get('SYSTEM_MAPNIK'):
- input_plugin_path = check_output([mapnik_config, '--input-plugins'])
- font_path = check_output([mapnik_config, '--fonts'])
- f_paths.write("mapniklibpath = '{path}'\n".format(path=lib_path))
- f_paths.write("inputpluginspath = '{path}'\n".format(path=input_plugin_path))
- f_paths.write("fontscollectionpath = '{path}'\n".format(path=font_path))
-else:
- if not os.path.exists('packaging/mapnik/bin'):
- os.symlink(bin_path, 'packaging/mapnik/bin')
- if not os.path.exists('packaging/mapnik/lib'):
- os.symlink(lib_path, 'packaging/mapnik/lib')
- else:
- names = (name for name in os.listdir(lib_path) if os.path.isfile(os.path.join(lib_path, name)))
- for name in names:
- if not os.path.exists(os.path.join('packaging/mapnik/lib', name)):
- os.symlink(os.path.join(lib_path, name), os.path.join('packaging/mapnik/lib', name))
- input_plugin_path = check_output([mapnik_config, '--input-plugins'])
- if not os.path.exists('packaging/mapnik/lib/mapnik/input'):
- os.symlink(input_plugin_path, 'packaging/mapnik/lib/mapnik/input')
- if not os.path.exists('packaging/mapnik/share'):
- os.mkdir('packaging/mapnik/share')
- if not os.path.exists('packaging/mapnik/share/icu'):
- os.mkdir('packaging/mapnik/share/icu')
- result = glob.glob(os.path.join(icu_data,'*.dat'))
- if len(result) == 1:
- icu_dat_file = os.path.basename(result[0])
- if not os.path.exists(os.path.join('packaging/mapnik/share/icu',icu_dat_file)):
- os.symlink(result[0], os.path.join('packaging/mapnik/share/icu',icu_dat_file))
- else:
- print("Error: can't locate ICU data file")
- sys.exit(1)
- if not os.path.exists('packaging/mapnik/share/gdal'):
- os.symlink(gdal_data, 'packaging/mapnik/share/gdal')
- if not os.path.exists('packaging/mapnik/share/proj'):
- os.symlink(gdal_data, 'packaging/mapnik/share/proj')
- f_paths.write("mapniklibpath = os.path.join(os.path.dirname(__file__), 'lib')\n")
- f_paths.write("inputpluginspath = os.path.join(os.path.dirname(__file__), 'lib/mapnik/input')\n")
- f_paths.write("fontscollectionpath = os.path.join(os.path.dirname(__file__), 'lib/mapnik/fonts')\n")
+input_plugin_path = os.path.join(lib_path, 'mapnik', 'input')
+font_path = os.path.join(lib_path, 'mapnik', 'fonts')
-f_paths.write("__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n")
-f_paths.close()
+if os.environ.get('LIB_DIR_NAME'):
+ mapnik_lib_path = lib_path + os.environ.get('LIB_DIR_NAME')
+else:
+ mapnik_lib_path = lib_path + "/mapnik"
+ f_paths.write("mapniklibpath = '{path}'\n".format(path=mapnik_lib_path))
+ f_paths.write(
+ "inputpluginspath = '{path}'\n".format(path=input_plugin_path))
+ f_paths.write(
+ "fontscollectionpath = '{path}'\n".format(path=font_path))
+ f_paths.write("localpath = os.path.dirname(os.path.abspath( __file__ ))\n")
+ f_paths.write("mapniklibpath = os.path.join(localpath, 'mapnik.libs')\n")
+ f_paths.write("mapniklibpath = os.path.normpath(mapniklibpath)\n")
+ f_paths.write("inputpluginspath = os.path.join(localpath, 'input')\n")
+ f_paths.write("fontscollectionpath = os.path.join(localpath, 'fonts')\n")
+ f_paths.write(
+ "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n")
+ f_paths.close()
-extra_comp_args = check_output([mapnik_config, '--cflags']).split(' ')
-extra_comp_args = list(filter(lambda arg: arg != "-fvisibility=hidden", extra_comp_args))
+extra_comp_args = check_output(['pkg-config', 'libmapnik', '--cflags']).split(' ')
if sys.platform == 'darwin':
pass
@@ -145,18 +114,17 @@ ext_modules = [
]
if os.environ.get("CC", False) == False:
- os.environ["CC"] = check_output([mapnik_config, '--cxx'])
+ os.environ["CC"] = 'c++'
if os.environ.get("CXX", False) == False:
- os.environ["CXX"] = check_output([mapnik_config, '--cxx'])
+ os.environ["CXX"] = 'c++'
-ParallelCompile("NUM_JOBS", needs_recompile=naive_recompile).install()
setup(
name="mapnik",
include_package_data=True,
packages=find_namespace_packages(where="packaging"),
package_dir={"": "packaging"},
package_data={
- "mapnik.include": ["*.hpp"],
+ 'mapnik': ['lib/*.*', 'lib/*/*/*', 'share/*/*', 'input/*', 'fonts/*', 'proj/*', 'gdal/*', 'bin/*'],
"mapnik.bin": ["*"],
"mapnik.lib": ["libmapnik*"],
"mapnik.lib.mapnik.fonts":["*"],
@@ -170,5 +138,6 @@ setup(
"mapnik.lib": ["*.a"]
},
ext_modules=ext_modules,
+ entry_points={'console_scripts': ['%s=mapnik.bin:program' % name for name in os.listdir('packaging/mapnik/bin') if not name.endswith('.py')]},
cmdclass={"build_ext": build_ext},
)
diff --git a/src/create_datasource.hpp b/src/create_datasource.hpp
index b6b5bfc..d3f2c02 100644
--- a/src/create_datasource.hpp
+++ b/src/create_datasource.hpp
@@ -54,7 +54,7 @@ inline std::shared_ptr<mapnik::datasource> create_datasource(py::kwargs const& k
}
else if (py::isinstance<py::int_>(handle))
{
- params[key] = handle.cast<mapnik::value_integer>();
+ params[key] = handle.cast<mapnik::value_integer>();}else if (py::isinstance<py::none>(handle)) {
}
else
{
diff --git a/src/mapnik_datasource.cpp b/src/mapnik_datasource.cpp
index 8d614a2..80a1174 100644
--- a/src/mapnik_datasource.cpp
+++ b/src/mapnik_datasource.cpp
@@ -155,7 +155,7 @@ void export_datasource(py::module& m)
.def("parameters", ¶meters_impl,
"The configuration parameters of the data source. "
"These vary depending on the type of data source.")
- .def(py::self == py::self)
+ // .def(py::self == py::self)
.def("__iter__",
[](datasource const& ds) {
mapnik::query q(ds.envelope());
diff --git a/src/mapnik_font_engine.cpp b/src/mapnik_font_engine.cpp
index 5fdcfed..9a78122 100644
--- a/src/mapnik_font_engine.cpp
+++ b/src/mapnik_font_engine.cpp
@@ -36,6 +36,6 @@ void export_font_engine(py::module const& m)
py::class_<freetype_engine>(m, "FontEngine")
.def_static("register_font", &freetype_engine::register_font)
.def_static("register_fonts", &freetype_engine::register_fonts)
- .def_static("face_names", &freetype_engine::face_names)
+ // .def_static("face_names", &freetype_engine::face_names)
;
}
diff --git a/src/mapnik_image.cpp b/src/mapnik_image.cpp
index b66f29f..3c69271 100644
--- a/src/mapnik_image.cpp
+++ b/src/mapnik_image.cpp
@@ -432,7 +432,7 @@ void export_image(py::module const& m)
.def("clear",&clear)
.def("to_string",&to_string1)
.def("to_string",&to_string2)
- .def("to_string",&to_string3)
+ .def("to_string",&to_string3).def("tostring",&to_string1).def("tostring",&to_string2).def("tostring",&to_string3)
.def("save", &save_to_file1)
.def("save", &save_to_file2)
.def("save", &save_to_file3)
diff --git a/src/mapnik_rule.cpp b/src/mapnik_rule.cpp
index 16407b5..bd8d3e8 100644
--- a/src/mapnik_rule.cpp
+++ b/src/mapnik_rule.cpp
@@ -78,6 +78,6 @@ void export_rule(py::module const& m)
.def("set_also", &rule::set_also)
.def("has_also", &rule::has_also_filter)
.def("active", &rule::active)
- .def_property_readonly("symbolizers", &rule::get_symbolizers)
+ .def_property_readonly("symbolizers", &rule::get_symbolizers).def_property_readonly("symbols", &rule::get_symbolizers)
;
}
--
2.55.0