Skip to content

Commit

Permalink
Merge pull request #95 from NextThought/issue94
Browse files Browse the repository at this point in the history
Build with Cython 0.29 using '3str' as the language level.
  • Loading branch information
jamadden committed Oct 16, 2018
2 parents 944cb8c + ba5e264 commit 964cd85
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
1.0.0a14 (unreleased)
=====================

- Nothing changed yet.
- Build with Cython 0.29 using '3str' as the language level.


1.0.0a13 (2018-09-20)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cython >= 0.28.4
cython >= 0.29
.[test,docs,benchmarks]
59 changes: 37 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@ def _read(fname):

# Cython

# Based on code from
# http://cython.readthedocs.io/en/latest/src/reference/compilation.html#distributing-cython-modules
def _dummy_cythonize(extensions, **_kwargs):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in ('.pyx', '.py'):
ext = '.c'
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions

try:
from Cython.Build import cythonize
except ImportError:
# The .c files had better already exist, as they should in
# an sdist. Based on code from
# http://cython.readthedocs.io/en/latest/src/reference/compilation.html#distributing-cython-modules
def cythonize(extensions, **_kwargs):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in ('.pyx', '.py'):
ext = '.c'
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions

# an sdist.
cythonize = _dummy_cythonize

ext_modules = []

Expand Down Expand Up @@ -119,14 +121,27 @@ def _c(m):
define_macros=[('CYTHON_TRACE', '1')],
))

ext_modules = cythonize(
ext_modules,
annotate=True,
compiler_directives={
#'linetrace': True,
'infer_types': True,
},
)
try:
ext_modules = cythonize(
ext_modules,
annotate=True,
compiler_directives={
#'linetrace': True,
'infer_types': True,
'language_level': '3str',
'always_allow_keywords': False,
'nonecheck': False,
},
)
except ValueError:
# 'invalid literal for int() with base 10: '3str'
# This is seen when an older version of Cython is installed.
# It's a bit of a chicken-and-egg, though, because installing
# from dev-requirements first scans this egg for its requirements
# before doing any updates.
import traceback
traceback.print_exc()
ext_modules = _dummy_cythonize(ext_modules)

setup(
name='nti.externalization',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ envlist =
commands =
zope-testrunner --test-path=src []
deps =
Cython >= 0.28.4
Cython >= 0.29
.[test]

[testenv:py27-pure]
Expand Down

0 comments on commit 964cd85

Please sign in to comment.