Enable building without cython

This commit is contained in:
Robin Dunn
2019-07-24 20:11:05 -07:00
parent 32f1e4219e
commit ff7f9c7fcc

View File

@@ -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,
)