-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmapnik_setup.py.patch
More file actions
132 lines (122 loc) · 6.07 KB
/
mapnik_setup.py.patch
File metadata and controls
132 lines (122 loc) · 6.07 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
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},
)