66import subprocess
77import os
88
9- mapnik_config = 'mapnik-config'
10-
119def check_output (args ):
1210 output = subprocess .check_output (args ).decode ()
1311 return output .rstrip ('\n ' )
1412
1513linkflags = []
16- lib_path = os .path .join (check_output ([mapnik_config , '--prefix' ]),'lib' )
17- linkflags .extend (check_output ([mapnik_config , '--libs' ]).split (' ' ))
18- linkflags .extend (check_output ([mapnik_config , '--ldflags' ]).split (' ' ))
19- linkflags .extend (check_output ([mapnik_config , '--dep-libs' ]).split (' ' ))
20- linkflags .extend ([
21- '-lmapnik-wkt' ,
22- '-lmapnik-json' ,
23- ])
14+ lib_path = os .path .join (check_output (['pkg-config' , '--variable=prefix' , 'libmapnik' ]),'lib' )
15+ linkflags .extend (check_output (['pkg-config' , '--libs' , 'libmapnik' ]).split (' ' ))
2416
2517# Dynamically make the mapnik/paths.py file
2618f_paths = open ('packaging/mapnik/paths.py' , 'w' )
2719f_paths .write ('import os\n ' )
2820f_paths .write ('\n ' )
2921
30- input_plugin_path = check_output ([mapnik_config , '--input-plugins ' ])
31- font_path = check_output ([mapnik_config , '--fonts ' ])
22+ input_plugin_path = check_output (['pkg-config' , '--variable=plugins_dir' , 'libmapnik ' ])
23+ font_path = check_output (['pkg-config' , '--variable=fonts_dir' , 'libmapnik ' ])
3224
3325if os .environ .get ('LIB_DIR_NAME' ):
3426 mapnik_lib_path = lib_path + os .environ .get ('LIB_DIR_NAME' )
@@ -43,7 +35,7 @@ def check_output(args):
4335 "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n " )
4436 f_paths .close ()
4537
46- extra_comp_args = check_output ([mapnik_config , '--cflags' ]).split (' ' )
38+ extra_comp_args = check_output (['pkg-config' , '--cflags' , 'libmapnik ' ]).split (' ' )
4739extra_comp_args = list (filter (lambda arg : arg != "-fvisibility=hidden" , extra_comp_args ))
4840
4941if sys .platform == 'darwin' :
@@ -53,6 +45,8 @@ def check_output(args):
5345 linkflags .append ('-Wl,-z,origin' )
5446 linkflags .append ('-Wl,-rpath=$ORIGIN/lib' )
5547
48+ extra_comp_args = list (filter (lambda arg : arg != "" , extra_comp_args ))
49+ linkflags = list (filter (lambda arg : arg != "" , linkflags ))
5650
5751ext_modules = [
5852 Pybind11Extension (
@@ -112,9 +106,9 @@ def check_output(args):
112106]
113107
114108if os .environ .get ("CC" , False ) == False :
115- os .environ ["CC" ] = check_output ([ mapnik_config , '--cxx' ])
109+ os .environ ["CC" ] = 'c++'
116110if os .environ .get ("CXX" , False ) == False :
117- os .environ ["CXX" ] = check_output ([ mapnik_config , '--cxx' ])
111+ os .environ ["CXX" ] = 'c++'
118112
119113setup (
120114 name = "mapnik" ,
0 commit comments