osx: start work on seamless support for multiple python versions
This commit is contained in:
parent
890524b207
commit
67efa6e18f
5 changed files with 132 additions and 17 deletions
|
@ -312,7 +312,6 @@ opts.AddVariables(
|
|||
# Variables for required dependencies
|
||||
('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'),
|
||||
('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'),
|
||||
('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'),
|
||||
PathVariable('ICU_INCLUDES', 'Search path for ICU include files', '/usr/include', PathVariable.PathAccept),
|
||||
PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
|
||||
('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc'),
|
||||
|
@ -333,6 +332,7 @@ opts.AddVariables(
|
|||
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
|
||||
|
||||
# Variables for optional dependencies
|
||||
('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'),
|
||||
# Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config
|
||||
# Therefore, we use a single boolean for whether to attempt to build cairo support.
|
||||
BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'False'),
|
||||
|
|
41
osx/scripts/build_boost_pythons.py
Normal file
41
osx/scripts/build_boost_pythons.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# script to build boost python versions
|
||||
# this should be run with the boost source directory as the cwd
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
USER_JAM = """
|
||||
import option ;
|
||||
import feature ;
|
||||
if ! darwin in [ feature.values <toolset> ]
|
||||
{
|
||||
using darwin ;
|
||||
}
|
||||
project : default-build <toolset>darwin ;
|
||||
using python
|
||||
: %(ver)s # version
|
||||
: %(system)s/Library/Frameworks/Python.framework/Versions/%(ver)s/bin/python%(ver)s # cmd-or-prefix
|
||||
: %(system)s/Library/Frameworks/Python.framework/Versions/%(ver)s/include/python%(ver)s # includes
|
||||
: %(system)s/Library/Frameworks/Python.framework/Versions/%(ver)s/lib/python%(ver)s/config # a lib actually symlink
|
||||
: <toolset>darwin # condition
|
||||
;
|
||||
libraries = --with-python ;
|
||||
"""
|
||||
|
||||
def compile_lib(ver,arch='32_64'):
|
||||
if ver in ('2.5','2.6'):
|
||||
# build against system pythons so we can reliably link against FAT binaries
|
||||
open('user-config.jam','w').write(USER_JAM % {'ver':ver,'system':'/System'})
|
||||
else:
|
||||
# for 2.7 and above hope that python.org provides 64 bit ready binaries...
|
||||
open('user-config.jam','w').write(USER_JAM % {'ver':ver,'system':''})
|
||||
cmd = "./bjam -q --with-python -a -j2 --ignore-site-config --user-config=user-config.jam link=shared toolset=darwin -d2 address-model=%s architecture=x86 release stage" % arch#linkflags=-search_paths_first
|
||||
print cmd
|
||||
os.system(cmd)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if not len(sys.argv) > 2:
|
||||
sys.exit('usage: %s <ver> <arch>' % os.path.basename(sys.argv[0]))
|
||||
compile_lib(sys.argv[1],sys.argv[2])
|
||||
|
||||
|
18
osx/scripts/fetch_py_releases.sh
Executable file
18
osx/scripts/fetch_py_releases.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
# http://www.python.org/download/releases/
|
||||
# http://www.python.org/ftp/python/
|
||||
|
||||
# 2.5.4 (2.5.5 did not provide binaries)
|
||||
wget http://www.python.org/ftp/python/2.5.4/python-2.5.4-macosx.dmg
|
||||
|
||||
# 2.6.6
|
||||
wget http://www.python.org/ftp/python/2.6.6/python-2.6.6-macosx10.3.dmg
|
||||
|
||||
# 2.7
|
||||
wget http://www.python.org/ftp/python/2.7.1/python-2.7.1-macosx10.6.dmg
|
||||
#wget http://www.python.org/ftp/python/2.7/python-2.7-macosx10.5.dmg
|
||||
|
||||
# 3.1.3 32 bit
|
||||
wget http://www.python.org/ftp/python/3.1.3/python-3.1.3-macosx10.3.dmg
|
||||
|
||||
# 3.1.2 sources
|
||||
wget http://www.python.org/ftp/python/3.1.2/Python-3.1.2.tar.bz2
|
|
@ -4,6 +4,8 @@
|
|||
# local install location
|
||||
PREFIX=/Users/dane/projects/mapnik-dev/trunk-build/osx/sources
|
||||
mkdir /Users/dane/projects/mapnik-dev/trunk-build/osx/sources
|
||||
export DYLD_LIBRARY_PATH=$PREFIX/lib
|
||||
|
||||
|
||||
# final resting place
|
||||
INSTALL=/Library/Frameworks/Mapnik.framework/unix/lib
|
||||
|
@ -80,20 +82,38 @@ cd boost_1_45_0
|
|||
architecture=x86 \
|
||||
install
|
||||
|
||||
# boost python for various versions are done in python script
|
||||
python ../../scripts/build_boost_pythons.py 2.5 32_64
|
||||
cp stage/lib/libboost_python.dylib ../../sources/lib/libboost_python25.dylib
|
||||
|
||||
python ../../scripts/build_boost_pythons.py 2.6 32_64
|
||||
cp stage/lib/libboost_python.dylib ../../sources/lib/libboost_python26.dylib
|
||||
|
||||
python ../../scripts/build_boost_pythons.py 2.7 32_64
|
||||
cp stage/lib/libboost_python.dylib ../../sources/lib/libboost_python27.dylib
|
||||
|
||||
python ../../scripts/build_boost_pythons.py 3.1 32_64
|
||||
cp stage/lib/libboost_python3.dylib ../../sources/lib/libboost_python31.dylib
|
||||
|
||||
|
||||
#cp stage/lib/libboost_*dylib ../../sources/lib/
|
||||
|
||||
cd ../../sources/lib
|
||||
|
||||
install_name_tool -id $INSTALL/libboost_python.dylib libboost_python.dylib
|
||||
# fix boost pythons
|
||||
install_name_tool -id $INSTALL/libboost_python25.dylib libboost_python25.dylib
|
||||
install_name_tool -id $INSTALL/libboost_python26.dylib libboost_python26.dylib
|
||||
install_name_tool -id $INSTALL/libboost_python27.dylib libboost_python27.dylib
|
||||
install_name_tool -id $INSTALL/libboost_python31.dylib libboost_python31.dylib
|
||||
|
||||
# fix boost libs
|
||||
install_name_tool -id $INSTALL/libboost_system.dylib libboost_system.dylib
|
||||
install_name_tool -id $INSTALL/libboost_filesystem.dylib libboost_filesystem.dylib
|
||||
install_name_tool -id $INSTALL/libboost_regex.dylib libboost_regex.dylib
|
||||
install_name_tool -id $INSTALL/libboost_program_options.dylib libboost_program_options.dylib
|
||||
install_name_tool -id $INSTALL/libboost_iostreams.dylib libboost_iostreams.dylib
|
||||
install_name_tool -id $INSTALL/libboost_thread.dylib libboost_thread.dylib
|
||||
|
||||
install_name_tool -change libboost_system.dylib $INSTALL/libboost_system.dylib libboost_filesystem.dylib
|
||||
|
||||
#install_name_tool -change libicui18n.46.dylib $INSTALL/libicui18n.46.dylib libboost_regex.dylib
|
||||
|
||||
|
||||
|
@ -125,3 +145,32 @@ make -j4
|
|||
make install
|
||||
cd ../../sources/lib
|
||||
install_name_tool -id $INSTALL/libfreetype.6.dylib libfreetype.6.dylib
|
||||
|
||||
### MAPNIK ###
|
||||
|
||||
# make sure we set DYLD path so we can link to libs without installing
|
||||
export DYLD_LIBRARY_PATH=$PREFIX/lib
|
||||
|
||||
# compile mapnik using osx/config.py
|
||||
|
||||
|
||||
# then compile each python version..
|
||||
|
||||
# 2.5
|
||||
rm bindings/python/*os
|
||||
rm bindings/python/mapnik/_mapnik2.so
|
||||
scons install PYTHON=/usr/bin/python2.5 BOOST_PYTHON_LIB=boost_python25
|
||||
|
||||
# 2.6
|
||||
rm bindings/python/*os
|
||||
rm bindings/python/mapnik/_mapnik2.so
|
||||
scons install PYTHON=/usr/bin/python2.6 BOOST_PYTHON_LIB=boost_python26
|
||||
|
||||
# 2.7
|
||||
rm bindings/python/*os
|
||||
rm bindings/python/mapnik/_mapnik2.so
|
||||
scons install PYTHON=/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 BOOST_PYTHON_LIB=boost_python27
|
||||
|
||||
# 3.1
|
||||
# needs patch: http://trac.mapnik.org/wiki/Python3k
|
||||
PYTHON=/usr/local/bin/python3 BOOST_PYTHON_LIB=boost_python31
|
||||
|
|
31
osx/wrap.py
31
osx/wrap.py
|
@ -122,8 +122,13 @@ if __name__ == "__main__":
|
|||
sym(join(active,'Mapnik'),join(framework,'Mapnik'))
|
||||
|
||||
# Python
|
||||
py_dir = join(active,'unix/lib/python2.6/site-packages')
|
||||
sym(py_dir,join(active,'Python'))
|
||||
#python_versions = glob.glob('unix/lib/python*')
|
||||
#for py in python_versions:
|
||||
# py_dir = join(active,'%s/site-packages' % py)
|
||||
os.mkdir(join(active,'Python'))
|
||||
os.mkdir(join(active,'Python/mapnik2'))
|
||||
shutil.copy('python/__init__.py',join(active,'Python/mapnik2/'))
|
||||
#sym(py_dir,join(active,'Python'))
|
||||
sym(join(active,'Python'),join(framework,'Python'))
|
||||
|
||||
# try to start using relative paths..
|
||||
|
@ -133,23 +138,25 @@ if __name__ == "__main__":
|
|||
#fontscollectionpath = os.path.normpath(os.path.join(os.path.dirname(__file__),'../../../../Fonts'))
|
||||
#'''
|
||||
|
||||
paths_py = '''
|
||||
inputpluginspath = '%(install_path)s/Mapnik.framework/Datasources'
|
||||
fontscollectionpath = '%(install_path)s/Mapnik.framework/Fonts'
|
||||
'''
|
||||
#paths_py = '''
|
||||
#inputpluginspath = '%(install_path)s/Mapnik.framework/Datasources'
|
||||
#fontscollectionpath = '%(install_path)s/Mapnik.framework/Fonts'
|
||||
#'''
|
||||
|
||||
# TODO - consider making _mapnik.so import dependent on version
|
||||
# so we can simplify install..
|
||||
# py26
|
||||
mapnik_module = join(py_dir,'mapnik2')
|
||||
open(mapnik_module+'/paths.py','w').write(paths_py % locals())
|
||||
shutil.copy('../bindings/python/mapnik/__init__.py',mapnik_module)
|
||||
|
||||
# write pth
|
||||
# done via scons install...
|
||||
#mapnik_module = join(py_dir,'mapnik2')
|
||||
#open(mapnik_module+'/paths.py','w').write(paths_py % locals())
|
||||
#shutil.copy('../bindings/python/mapnik/__init__.py',mapnik_module)
|
||||
|
||||
# pth file
|
||||
pth ='''import sys; sys.path.insert(0,'%(install_path)s/Mapnik.framework/Python')
|
||||
''' % locals()
|
||||
|
||||
# TODO - testing hack, will add this local python binding to sys path for snow leopard
|
||||
open('/Library/Python/2.6/site-packages/mapnik.pth','w').write(pth)
|
||||
#open('/Library/Python/2.6/site-packages/mapnik.pth','w').write(pth)
|
||||
|
||||
# Stash in resources as well
|
||||
open(join(active,'Resources/mapnik.pth'),'w').write(pth)
|
||||
|
|
Loading…
Reference in a new issue