# HG changeset patch # User Tero Marttila # Date 1264531745 -7200 # Node ID 2da34e3aa88540ec408e26a4659cfcd3f2424676 # Parent 6841b56e128be9a2b44bb9b8e44c5f9ed37cd289 setup.py: fallback to .c if we don't have Cython diff -r 6841b56e128b -r 2da34e3aa885 setup.py --- a/setup.py Tue Jan 26 20:42:55 2010 +0200 +++ b/setup.py Tue Jan 26 20:49:05 2010 +0200 @@ -1,12 +1,37 @@ from distutils.core import setup from distutils.extension import Extension -from Cython.Distutils import build_ext + +import os.path + +build_root = os.path.abspath(os.path.dirname(__file__)) + +pypngtile_c = "python/pypngtile.c" +pypngtile_name = "python/pypngtile.pyx" + +cmdclass = dict() + +try : + from Cython.Distutils import build_ext + + cmdclass['build_ext'] = build_ext + +except ImportError : + path = os.path.join(build_root, pypngtile_c) + + if os.path.exists(path) : + print "Warning: falling back from .pyx -> .c due to missing Cython" + # just use the .c + pypngtile_name = pypngtile_c + + else : + # fail + raise setup( name = 'pngtiles', - cmdclass = {'build_ext': build_ext}, + cmdclass = cmdclass, ext_modules = [ - Extension("pypngtile", ["python/pypngtile.pyx"], + Extension("pypngtile", [pypngtile_name], include_dirs = ['include'], library_dirs = ['lib'], libraries = ['pngtile'],