From 43ae6cc3fe5bc0db2ee28a8292543a7be80a75f3 Mon Sep 17 00:00:00 2001 From: Bas Couwenberg Date: Tue, 17 Feb 2026 19:28:14 +0000 Subject: [PATCH] Use pkg-config instead of mapnik-config mapnik-config is no longer installed when CMake is used with mapnik. --- setup.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index a72565629..d4b4b0929 100755 --- a/setup.py +++ b/setup.py @@ -6,22 +6,14 @@ import subprocess import os -mapnik_config = 'mapnik-config' - def check_output(args): output = subprocess.check_output(args).decode() 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') -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', -]) +bin_path = os.path.join(check_output(['pkg-config', '--variable=prefix', 'libmapnik']),'bin') +lib_path = check_output(['pkg-config', '--variable=libdir', 'libmapnik']) +linkflags.extend(check_output(['pkg-config', '--libs', 'libmapnik']).split(' ')) # Remove symlinks if os.path.islink('packaging/mapnik/bin') : @@ -34,8 +26,8 @@ def check_output(args): 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']) + input_plugin_path = check_output(['pkg-config', '--variable=plugins_dir', 'libmapnik']) + font_path = check_output(['pkg-config', '--variable=fonts_dir', 'libmapnik']) 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)) @@ -59,7 +51,7 @@ def check_output(args): f_paths.write("__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': @@ -69,6 +61,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( @@ -128,9 +122,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",