Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions setup.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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') :
Expand All@@ -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))
Expand All@@ -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':
Expand All@@ -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(
Expand DownExpand Up@@ -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",
Expand Down