diff --git a/setup.py b/setup.py index 1de707a34..fb4d79d56 100755 --- a/setup.py +++ b/setup.py @@ -6,29 +6,21 @@ import subprocess import os -mapnik_config = 'mapnik-config' - def check_output(args): output = subprocess.check_output(args).decode() return output.rstrip('\n') linkflags = [] -lib_path = os.path.join(check_output([mapnik_config, '--prefix']),'lib') -linkflags.extend(check_output([mapnik_config, '--libs']).split(' ')) -linkflags.extend(check_output([mapnik_config, '--ldflags']).split(' ')) -linkflags.extend(check_output([mapnik_config, '--dep-libs']).split(' ')) -linkflags.extend([ - '-lmapnik-wkt', - '-lmapnik-json', -]) +lib_path = os.path.join(check_output(['pkg-config', '--variable=prefix', 'libmapnik']),'lib') +linkflags.extend(check_output(['pkg-config', '--libs', 'libmapnik']).split(' ')) # Dynamically make the mapnik/paths.py file f_paths = open('packaging/mapnik/paths.py', 'w') f_paths.write('import os\n') f_paths.write('\n') -input_plugin_path = check_output([mapnik_config, '--input-plugins']) -font_path = check_output([mapnik_config, '--fonts']) +input_plugin_path = check_output(['pkg-config', '--variable=plugins_dir', 'libmapnik']) +font_path = check_output(['pkg-config', '--variable=fonts_dir', 'libmapnik']) if os.environ.get('LIB_DIR_NAME'): mapnik_lib_path = lib_path + os.environ.get('LIB_DIR_NAME') @@ -43,7 +35,7 @@ def check_output(args): "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n") f_paths.close() -extra_comp_args = check_output([mapnik_config, '--cflags']).split(' ') +extra_comp_args = check_output(['pkg-config', '--cflags', 'libmapnik']).split(' ') extra_comp_args = list(filter(lambda arg: arg != "-fvisibility=hidden", extra_comp_args)) if sys.platform == 'darwin': @@ -53,6 +45,8 @@ def check_output(args): linkflags.append('-Wl,-z,origin') linkflags.append('-Wl,-rpath=$ORIGIN/lib') +extra_comp_args = list(filter(lambda arg: arg != "", extra_comp_args)) +linkflags = list(filter(lambda arg: arg != "", linkflags)) ext_modules = [ Pybind11Extension( @@ -112,9 +106,9 @@ def check_output(args): ] 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++' setup( name="mapnik",