Skip to content

Commit

Permalink
Merge pull request #1820 from dib-lab/fix/cythonization
Browse files Browse the repository at this point in the history
Cythonization Improvements
  • Loading branch information
standage committed Dec 12, 2017
2 parents 586e79c + 0b34852 commit d565f34
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@

try:
import Cython
from Cython.Build import cythonize
from Cython.Distutils import Extension as CyExtension
HAS_CYTHON = True
cy_ext = 'pyx'
print('*** NOTE: Found Cython, extension files will be '
'transpiled if this is an install invocation.',
file=sys.stderr)
except ImportError:
from setuptools import Extension as CyExtension
HAS_CYTHON = False
cy_ext = 'cpp'
print('*** WARNING: Cython not found, assuming cythonized '
'files available for compilation.', file=sys.stderr)

# strip out -Wstrict-prototypes; a hack suggested by
# http://stackoverflow.com/a/9740721
Expand Down Expand Up @@ -223,13 +229,13 @@ def build_dir():
"define_macros": [("VERSION", versioneer.get_version()), ]
}

if HAS_CYTHON:
CY_EXTENSION_MOD_DICT['cython_directives'] = CY_OPTS

ext_name = "khmer._oxli.{0}".format(
splitext(os.path.basename(cython_ext))[0]
)
EXTENSION_MODS.append(Extension(ext_name, ** CY_EXTENSION_MOD_DICT))

if HAS_CYTHON:
EXTENSION_MODS = cythonize(EXTENSION_MODS, compiler_directives=CY_OPTS)
EXTENSION_MODS.append(CyExtension(ext_name, ** CY_EXTENSION_MOD_DICT))

SCRIPTS = []
SCRIPTS.extend([path_join("scripts", script)
Expand Down

0 comments on commit d565f34

Please sign in to comment.