improve reliability of default python linking on os x - closes #380
This commit is contained in:
parent
51569ce9fc
commit
3c9655b721
2 changed files with 41 additions and 2 deletions
|
@ -175,7 +175,7 @@ opts.AddVariables(
|
||||||
('LIB_DIR_NAME','Name to use for the "lib" folder where fonts and plugins are installed','/mapnik/'),
|
('LIB_DIR_NAME','Name to use for the "lib" folder where fonts and plugins are installed','/mapnik/'),
|
||||||
PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable),
|
PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable),
|
||||||
BoolVariable('FRAMEWORK_PYTHON', 'Link against Framework Python on Mac OS X', 'True'),
|
BoolVariable('FRAMEWORK_PYTHON', 'Link against Framework Python on Mac OS X', 'True'),
|
||||||
PathVariable('FRAMEWORK_SEARCH_PATH','Top framework search path on Mac OS X', '/'),
|
('FRAMEWORK_SEARCH_PATH','Custom framework search path on Mac OS X', ''),
|
||||||
BoolVariable('FULL_LIB_PATH', 'Use the full path for the libmapnik.dylib "install_name" when linking on Mac OS X', 'True'),
|
BoolVariable('FULL_LIB_PATH', 'Use the full path for the libmapnik.dylib "install_name" when linking on Mac OS X', 'True'),
|
||||||
ListVariable('BINDINGS','Language bindings to build','all',['python']),
|
ListVariable('BINDINGS','Language bindings to build','all',['python']),
|
||||||
EnumVariable('THREADING','Set threading support','multi', ['multi','single']),
|
EnumVariable('THREADING','Set threading support','multi', ['multi','single']),
|
||||||
|
@ -211,6 +211,7 @@ pickle_store = [# Scons internal variables
|
||||||
'PYTHON_VERSION',
|
'PYTHON_VERSION',
|
||||||
'PYTHON_INCLUDES',
|
'PYTHON_INCLUDES',
|
||||||
'PYTHON_INSTALL_LOCATION',
|
'PYTHON_INSTALL_LOCATION',
|
||||||
|
'PYTHON_SYS_PREFIX',
|
||||||
'COLOR_PRINT',
|
'COLOR_PRINT',
|
||||||
'BOOST_SYSTEM_REQUIRED',
|
'BOOST_SYSTEM_REQUIRED',
|
||||||
]
|
]
|
||||||
|
|
|
@ -39,8 +39,46 @@ if env['PLATFORM'] == 'Darwin':
|
||||||
libraries.append('boost_thread%s' % env['BOOST_APPEND'])
|
libraries.append('boost_thread%s' % env['BOOST_APPEND'])
|
||||||
if '-DHAVE_CAIRO' in env['CXXFLAGS']:
|
if '-DHAVE_CAIRO' in env['CXXFLAGS']:
|
||||||
libraries.append([lib for lib in env['LIBS'] if lib.startswith('cairo')])
|
libraries.append([lib for lib in env['LIBS'] if lib.startswith('cairo')])
|
||||||
|
|
||||||
|
##### Python linking on OS X is tricky ###
|
||||||
|
# Confounding problems are:
|
||||||
|
# 1) likelyhood of multiple python installs of the same major.minor version
|
||||||
|
# because apple supplies python built-in and many users may have installed
|
||||||
|
# further versions using macports
|
||||||
|
# 2) boost python directly links to a python version
|
||||||
|
# 3) the below will directly link _mapnik.so to a python version
|
||||||
|
# 4) _mapnik.so must link to the same python lib as boost_python.dylib otherwise
|
||||||
|
# python will Abort with a Verion Mismatch error.
|
||||||
|
# See http://trac.mapnik.org/ticket/453 for the seeds of a better approach
|
||||||
|
# for now we offer control over method of direct linking...
|
||||||
|
# The default below is to link against the python dylib in the form of
|
||||||
|
#/path/to/Python.framework/Python instead of -lpython
|
||||||
|
|
||||||
|
# http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man1/ld.1.html
|
||||||
|
|
||||||
if env['FRAMEWORK_PYTHON']:
|
if env['FRAMEWORK_PYTHON']:
|
||||||
linkflags = '-F%s -framework Python' % env['FRAMEWORK_SEARCH_PATH']
|
if env['FRAMEWORK_SEARCH_PATH']:
|
||||||
|
# if the user has supplied a custom root path to search for
|
||||||
|
# a given Python framework, then use that to direct the linker
|
||||||
|
linkflags = '-F%s -framework Python -Z' % env['FRAMEWORK_SEARCH_PATH']
|
||||||
|
else:
|
||||||
|
# otherwise be as explicit as possible for linking to the same Framework
|
||||||
|
# as the executable we are building with (or is pointed to by the PYTHON variable)
|
||||||
|
# otherwise we may accidentally link against either:
|
||||||
|
# /System/Library/Frameworks/Python.framework/Python/Versions/
|
||||||
|
# or
|
||||||
|
# /Library/Frameworks/Python.framework/Python/Versions/
|
||||||
|
# See: http://trac.mapnik.org/ticket/380
|
||||||
|
prefix = env['PYTHON_SYS_PREFIX']
|
||||||
|
if '.framework' in prefix:
|
||||||
|
linkflags = '-F%s -framework Python -Z' % os.path.dirname(prefix.split('.')[0])
|
||||||
|
elif '/System' in prefix:
|
||||||
|
linkflags = '-F/System/Library/Frameworks/ -framework Python -Z'
|
||||||
|
else:
|
||||||
|
# should we fall back to -lpython here?
|
||||||
|
linkflags = '-F/ -framework Python'
|
||||||
|
|
||||||
|
# if we are not linking to a framework then use the *nix standard approach
|
||||||
else:
|
else:
|
||||||
linkflags = '-lpython%s' % env['PYTHON_VERSION']
|
linkflags = '-lpython%s' % env['PYTHON_VERSION']
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue