actually use cython language_level=3 + fix issue!

This commit is contained in:
Gabriel Pettier 2020-05-10 15:48:08 +02:00
parent 06d96a4d88
commit afcc535afc
2 changed files with 17 additions and 16 deletions

View File

@ -525,7 +525,7 @@ cdef jstring convert_pystr_to_java(JNIEnv *j_env, unicode py_uni) except NULL:
py_bytes = py_uni.encode('utf-16')
# skip byte-order mark
buff = (<char *>py_bytes) + sizeof(jchar)
j_strlen = len(py_bytes) / sizeof(jchar) - 1
j_strlen = int(len(py_bytes) / sizeof(jchar) - 1)
j_str = j_env[0].NewString(j_env, <jchar *>buff, j_strlen)
if j_str == NULL:

View File

@ -98,22 +98,12 @@ compile_native_invocation_handler(*get_possible_homes(PLATFORM))
# generate the config.pxi
with open(join(dirname(__file__), 'jnius', 'config.pxi'), 'w') as fd:
fd.write('DEF JNIUS_PLATFORM = {0!r}\n\n'.format(PLATFORM))
if not PY2:
fd.write('# cython: language_level=3\n\n')
fd.write('DEF JNIUS_PYTHON3 = True\n\n')
else:
fd.write('# cython: language_level=2\n\n')
fd.write('DEF JNIUS_PYTHON3 = False\n\n')
# pop setup.py from included files in the installed package
SETUP_KWARGS['py_modules'].remove('setup')
# create the extension
setup(
cmdclass={'build_ext': build_ext},
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
ext_modules=[
ext_modules = [
Extension(
'jnius', [join('jnius', x) for x in FILES],
libraries=get_libraries(PLATFORM),
@ -121,7 +111,18 @@ setup(
include_dirs=get_include_dirs(PLATFORM),
extra_link_args=EXTRA_LINK_ARGS,
)
],
]
for ext_mod in ext_modules:
ext_mod.cython_directives = {'language_level': 3}
# create the extension
setup(
cmdclass={'build_ext': build_ext},
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
ext_modules=ext_modules,
extras_require={
'dev': ['pytest', 'wheel', 'pytest-cov', 'pycodestyle'],
'ci': ['coveralls', 'pytest-rerunfailures', 'setuptools>=34.4.0'],