|
8 | 8 | import shutil |
9 | 9 | import re |
10 | 10 |
|
| 11 | +PYTHON3 = sys.version_info[0] == 3 |
| 12 | + |
| 13 | + |
| 14 | +# Utils |
| 15 | +def check_output(args): |
| 16 | + output = subprocess.check_output(args) |
| 17 | + if PYTHON3: |
| 18 | + # check_output returns bytes in PYTHON3. |
| 19 | + output = output.decode() |
| 20 | + return output.rstrip('\n') |
| 21 | + |
| 22 | + |
11 | 23 | cflags = sysconfig.get_config_var('CFLAGS') |
12 | 24 | sysconfig._config_vars['CFLAGS'] = re.sub(' +', ' ', cflags.replace('-g', '').replace('-Os', '').replace('-arch i386', '')) |
13 | 25 | opt = sysconfig.get_config_var('OPT') |
|
35 | 47 | boost_thread_lib = os.environ.get("BOOST_THREAD_LIB", 'boost_thread-mt') |
36 | 48 |
|
37 | 49 | try: |
38 | | - linkflags = subprocess.check_output([mapnik_config, '--libs']).rstrip('\n').split(' ') |
| 50 | + linkflags = check_output([mapnik_config, '--libs']).split(' ') |
39 | 51 | lib_path = linkflags[0][2:] |
40 | | - linkflags.extend(subprocess.check_output([mapnik_config, '--ldflags']).rstrip('\n').split(' ')) |
| 52 | + linkflags.extend(check_output([mapnik_config, '--ldflags']).split(' ')) |
41 | 53 | except: |
42 | | - raise Exception("Failed to find proper linking flags from mapnik config"); |
| 54 | + raise Exception("Failed to find proper linking flags from mapnik config") |
43 | 55 |
|
44 | | -## Dynamically make the mapnik/paths.py file if it doesn't exist. |
| 56 | +# Dynamically make the mapnik/paths.py file if it doesn't exist. |
45 | 57 | if os.path.isfile('mapnik/paths.py'): |
46 | 58 | create_paths = False |
47 | 59 | else: |
|
60 | 72 | shutil.copyfile(f, os.path.join('mapnik', base_f)) |
61 | 73 | except shutil.Error: |
62 | 74 | pass |
63 | | - input_plugin_path = subprocess.check_output([mapnik_config, '--input-plugins']).rstrip('\n') |
| 75 | + input_plugin_path = check_output([mapnik_config, '--input-plugins']) |
64 | 76 | input_plugin_files = os.listdir(input_plugin_path) |
65 | 77 | input_plugin_files = [os.path.join(input_plugin_path, f) for f in input_plugin_files] |
66 | 78 | if not os.path.exists(os.path.join('mapnik','plugins','input')): |
|
70 | 82 | shutil.copyfile(f, os.path.join('mapnik', 'plugins', 'input', os.path.basename(f))) |
71 | 83 | except shutil.Error: |
72 | 84 | pass |
73 | | - font_path = subprocess.check_output([mapnik_config, '--fonts']).rstrip('\n') |
| 85 | + font_path = check_output([mapnik_config, '--fonts']) |
74 | 86 | font_files = os.listdir(font_path) |
75 | 87 | font_files = [os.path.join(font_path, f) for f in font_files] |
76 | 88 | if not os.path.exists(os.path.join('mapnik','plugins','fonts')): |
|
94 | 106 |
|
95 | 107 |
|
96 | 108 | if not mason_build: |
97 | | - icu_path = subprocess.check_output([mapnik_config, '--icu-data']).rstrip('\n') |
| 109 | + icu_path = check_output([mapnik_config, '--icu-data']) |
98 | 110 | else: |
99 | 111 | icu_path = 'mason_packages/.link/share/icu/' |
100 | 112 | if icu_path: |
|
109 | 121 | pass |
110 | 122 |
|
111 | 123 | if not mason_build: |
112 | | - gdal_path = subprocess.check_output([mapnik_config, '--gdal-data']).rstrip('\n') |
| 124 | + gdal_path = check_output([mapnik_config, '--gdal-data']) |
113 | 125 | else: |
114 | 126 | gdal_path = 'mason_packages/.link/share/gdal/' |
115 | 127 | if os.path.exists('mason_packages/.link/share/gdal/gdal/'): |
|
126 | 138 | pass |
127 | 139 |
|
128 | 140 | if not mason_build: |
129 | | - proj_path = subprocess.check_output([mapnik_config, '--proj-lib']).rstrip('\n') |
| 141 | + proj_path = check_output([mapnik_config, '--proj-lib']) |
130 | 142 | else: |
131 | 143 | proj_path = 'mason_packages/.link/share/proj/' |
132 | 144 | if os.path.exists('mason_packages/.link/share/proj/proj/'): |
|
142 | 154 | except shutil.Error: |
143 | 155 | pass |
144 | 156 |
|
145 | | -extra_comp_args = subprocess.check_output([mapnik_config, '--cflags']).rstrip('\n').split(' ') |
| 157 | +extra_comp_args = check_output([mapnik_config, '--cflags']).split(' ') |
146 | 158 |
|
147 | 159 | if sys.platform == 'darwin': |
148 | 160 | extra_comp_args.append('-mmacosx-version-min=10.8') |
|
153 | 165 | linkflags.append('-Wl,-rpath=$ORIGIN') |
154 | 166 |
|
155 | 167 | if os.environ.get("CC",False) == False: |
156 | | - os.environ["CC"] = subprocess.check_output([mapnik_config, '--cxx']).rstrip('\n') |
| 168 | + os.environ["CC"] = check_output([mapnik_config, '--cxx']) |
157 | 169 | if os.environ.get("CXX",False) == False: |
158 | | - os.environ["CXX"] = subprocess.check_output([mapnik_config, '--cxx']).rstrip('\n') |
| 170 | + os.environ["CXX"] = check_output([mapnik_config, '--cxx']) |
159 | 171 |
|
160 | 172 | setup( |
161 | 173 | name = "mapnik", |
|
0 commit comments