Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building for Python 3.8 #765

Merged
merged 2 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ env['python_cmd_esc'] = quoted(env['python_cmd'])

# Python Package Settings
python_min_version = LooseVersion('3.5')
# Note: cython_min_version is redefined below if the Python version is 3.8 or higher
cython_min_version = LooseVersion('0.23')
numpy_min_test_version = LooseVersion('1.8.1')

Expand Down Expand Up @@ -1293,6 +1294,15 @@ if env['python_package'] != 'none':
"Found {0} but {1} or newer is required".format(
python_version, python_min_version))
warn_no_full_package = True
elif python_version >= LooseVersion("3.8"):
# Reset the minimum Cython version if the Python version is 3.8 or higher
# Due to internal changes in the CPython API, more recent versions of
# Cython are necessary to build for Python 3.8. There is nothing Cantera
# can do about this, the changes in CPython are handled by Cython. This
# version bump is used to produce a more useful/actionable error message
# for users than the compilation errors that result from using
# Cython < 0.29.12.
cython_min_version = LooseVersion("0.29.12")

if numpy_version == LooseVersion('0.0.0'):
print("NumPy not found.")
Expand Down
9 changes: 9 additions & 0 deletions interfaces/cython/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ localenv.Prepend(CPPPATH=[Dir('#include'), inc, numpy_include])
localenv.Prepend(LIBS=localenv['cantera_libs'])
if localenv['OS'] == 'Darwin':
localenv.Append(LINKFLAGS='-undefined dynamic_lookup')

# Don't print deprecation warnings for internal Python changes.
# It seems that only clang on macOS prints these deprecation warnings.
# Only applies to Python 3.8. The field that is deprecated in Python 3.8
# and causes the warnings to appear will be removed in Python 3.9 so no
# further warnings should be issued. Cython has already implemented a fix
# in versions higher than 0.29.14.
if py_version == LooseVersion("3.8"):
localenv.Append(CXXFLAGS='-Wno-deprecated-declarations')
elif localenv['OS'] == 'Windows':
localenv.Append(LIBPATH=prefix+'/libs')
if localenv['toolchain'] == 'mingw':
Expand Down