|
1 | 1 | #!/usr/bin/env python |
| 2 | +import os |
2 | 3 | from setuptools import setup, find_packages |
3 | 4 | from setuptools.extension import Extension |
4 | | -from Cython.Build import cythonize |
5 | 5 | import numpy as np |
6 | 6 |
|
| 7 | + |
| 8 | +USE_CYTHON = 'CYTHONIZE' in os.environ |
| 9 | +ext = '.pyx' if USE_CYTHON else '.c' |
7 | 10 | extensions = [ |
8 | 11 | Extension("scrapely._htmlpage", |
9 | | - ["scrapely/_htmlpage.pyx"], |
| 12 | + ["scrapely/_htmlpage%s" % ext], |
10 | 13 | include_dirs=[np.get_include()]), |
11 | 14 | Extension("scrapely.extraction._similarity", |
12 | | - ["scrapely/extraction/_similarity.pyx"], |
| 15 | + ["scrapely/extraction/_similarity%s" % ext], |
13 | 16 | include_dirs=[np.get_include()]), |
14 | 17 | ] |
| 18 | +if USE_CYTHON: |
| 19 | + from Cython.Build import cythonize |
| 20 | + extensions = cythonize(extensions) |
15 | 21 |
|
16 | 22 |
|
17 | 23 | setup( |
|
38 | 44 | 'Topic :: Internet :: WWW/HTTP', |
39 | 45 | 'Topic :: Text Processing :: Markup :: HTML', |
40 | 46 | ], |
41 | | - install_requires=['numpy', 'w3lib', 'six', 'cython'], |
42 | | - ext_modules=cythonize(extensions), |
| 47 | + install_requires=['numpy', 'w3lib', 'six'], |
| 48 | + ext_modules=extensions, |
43 | 49 | ) |
0 commit comments