From ad85ed15f0f4dbbea0b29d6e6e1c06b97799a423 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 28 Feb 2013 19:07:05 +0100 Subject: [PATCH] detect if we could use cython-2.7 prior to cython. closes #28 --- tools/build-lxml.sh | 2 +- tools/cythonize.py | 15 ++++++++++++++- tools/environment.sh | 13 +++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/build-lxml.sh b/tools/build-lxml.sh index 61f922f..581a83e 100755 --- a/tools/build-lxml.sh +++ b/tools/build-lxml.sh @@ -104,7 +104,7 @@ XSLT_CONFIG=$PREFIX/bin/xslt-config #pushd src #find . -name *.pyx -exec $KIVYIOSROOT/tools/cythonize.py {} \; #popd -find . -name *.pyx -exec cython {} \; +find . -name *.pyx -exec $CYTHON {} \; try $HOSTPYTHON setup.py build_ext try $HOSTPYTHON setup.py install -O2 --root iosbuild diff --git a/tools/cythonize.py b/tools/cythonize.py index 4e79136..466d169 100755 --- a/tools/cythonize.py +++ b/tools/cythonize.py @@ -1,8 +1,20 @@ #!/usr/bin/env python +import os import sys import subprocess +# resolve cython executable +cython = None + +def resolve_cython(): + global cython + for executable in ('cython', 'cython-2.7'): + for path in os.environ['PATH'].split(':'): + if executable in os.listdir(path): + cython = os.path.join(path, executable) + return + def do(fn): print 'cythonize:', fn parts = fn.split('/') @@ -13,7 +25,7 @@ def do(fn): package = '_'.join(parts[:-1]) # cythonize - subprocess.Popen(['cython', fn]).communicate() + subprocess.Popen([cython, fn]).communicate() if not package: print 'no need to rewrite', fn @@ -43,5 +55,6 @@ def do(fn): if __name__ == '__main__': print '-- cythonize', sys.argv + resolve_cython() for fn in sys.argv[1:]: do(fn) diff --git a/tools/environment.sh b/tools/environment.sh index 97561e4..31848eb 100755 --- a/tools/environment.sh +++ b/tools/environment.sh @@ -44,6 +44,19 @@ export PKG_CONFIG_PATH="$BUILDROOT/pkgconfig:$PKG_CONFIG_PATH" # some tools export CCACHE=$(which ccache) +for fn in cython-2.7 cython; do + export CYTHON=$(which $fn) + if [ "X$CYTHON" != "X" ]; then + echo "Cython found at $CYTHON" + break + fi +done +if [ "X$CYTHON" == "X" ]; then + print "Cython is not installed, aborting." + exit 1 +fi + + # flags for arm compilation export ARM_CC="$CCACHE $DEVROOT/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"