serialize relative path to fonts/plugins in python paths.py and re-assemble absolute path dynamically at load time to provide greatest portability

This commit is contained in:
Dane Springmeyer 2011-12-13 17:53:31 -08:00
parent 5a2da87aa8
commit acb726ce63

View file

@ -43,7 +43,8 @@ prefix = env['PREFIX']
target_path = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik') target_path = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik')
target_path_deprecated = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik2') target_path_deprecated = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik2')
libraries = ['mapnik','png'] libraries = ['mapnik']
libraries.append('png')
if env['JPEG']: if env['JPEG']:
libraries.append('jpeg') libraries.append('jpeg')
@ -122,22 +123,24 @@ else:
paths = ''' paths = '''
"""Configuration paths of Mapnik fonts and input plugins (auto-generated by SCons).""" """Configuration paths of Mapnik fonts and input plugins (auto-generated by SCons)."""
import os from os.path import normpath,join,dirname
mapniklibpath = '%s' mapniklibpath = '%s'
mapniklibpath = normpath(join(dirname(__file__),mapniklibpath))
''' '''
paths += "inputpluginspath = os.path.normpath(mapniklibpath + '/input')\n" paths += "inputpluginspath = join(mapniklibpath,'input')\n"
if env['SYSTEM_FONTS']: if env['SYSTEM_FONTS']:
paths += "fontscollectionpath = os.path.normpath('%s')" % env['SYSTEM_FONTS'] paths += "fontscollectionpath = normpath('%s')\n" % env['SYSTEM_FONTS']
else: else:
paths += "fontscollectionpath = os.path.normpath(mapniklibpath + '/fonts')" paths += "fontscollectionpath = join(mapniklibpath,'fonts')\n"
paths += "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n"
if not os.path.exists('mapnik'): if not os.path.exists('mapnik'):
os.mkdir('mapnik') os.mkdir('mapnik')
file('mapnik/paths.py','w').write(paths % (env['MAPNIK_LIB_DIR'])) file('mapnik/paths.py','w').write(paths % (os.path.relpath(env['MAPNIK_LIB_DIR'],target_path)))
# force open perms temporarily so that `sudo scons install` # force open perms temporarily so that `sudo scons install`
# does not later break simple non-install non-sudo rebuild # does not later break simple non-install non-sudo rebuild