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') py_bytes = py_uni.encode('utf-16')
# skip byte-order mark # skip byte-order mark
buff = (<char *>py_bytes) + sizeof(jchar) 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) j_str = j_env[0].NewString(j_env, <jchar *>buff, j_strlen)
if j_str == NULL: if j_str == NULL:

View File

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