diff --git a/setup-wxsvg.py b/setup-wxsvg.py index 12c2d9a2..5a1a35c3 100644 --- a/setup-wxsvg.py +++ b/setup-wxsvg.py @@ -3,7 +3,12 @@ import sys import os import textwrap from setuptools import setup, Extension -from Cython.Build import cythonize +try: + from Cython.Build import cythonize + have_cython = True +except ImportError: + have_cython = False + VERSION = "0.1.0" DESCRIPTION = '' @@ -24,14 +29,28 @@ with open(os.path.join(HERE, PACKAGEDIR, '_version.py'), 'w') as f: __version__ = '{VERSION}' """)) +if have_cython: + SOURCE = os.path.join(PACKAGEDIR, '_nanosvg.pyx') +else: + SOURCE = os.path.join(PACKAGEDIR, '_nanosvg.c') + module = Extension(name='wx.svg._nanosvg', - sources=['wx/svg/_nanosvg.pyx'], + sources=[SOURCE], include_dirs=['ext/nanosvg/src'], define_macros=[('NANOSVG_IMPLEMENTATION', '1'), ('NANOSVGRAST_IMPLEMENTATION', '1'), ('NANOSVG_ALL_COLOR_KEYWORDS', '1'), ]) +if have_cython: + modules = cythonize([module], + compiler_directives={'embedsignature': True, + 'language_level':2, + }) +else: + modules = [module] + + setup(name = 'nanosvg', version = VERSION, description = DESCRIPTION, @@ -42,9 +61,5 @@ setup(name = 'nanosvg', download_url = DOWNLOAD_URL, license = LICENSE, packages = [PACKAGE], - ext_modules = cythonize( - [module], - compiler_directives={'embedsignature': True, - 'language_level':2, - }), + ext_modules = modules, )