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

Restore compatibility with expected minimum Cython version #1798

Merged
merged 2 commits into from
Oct 21, 2024
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
14 changes: 11 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,27 @@ jobs:
select-by-folder: /home/runner/work/cantera/cantera/test/matlab_experimental

ubuntu-multiple-pythons:
name: ${{ matrix.os }} with Python ${{ matrix.python-version }}, Numpy ${{ matrix.numpy || 'latest' }}
name: ${{ matrix.os }} with Python ${{ matrix.python-version }}, Numpy ${{ matrix.numpy || 'latest' }}, Cython ${{ matrix.cython || 'latest' }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
python-version: ['3.8', '3.10', '3.11', '3.12']
os: ['ubuntu-20.04', 'ubuntu-22.04']
numpy: ['']
cython: ['']
include:
# Keep some test cases with NumPy 1.x until we drop support
- python-version: '3.12'
os: 'ubuntu-24.04'
numpy: "'<2.0'"
# Keep some test cases with older Cython versions
- python-version: '3.10'
os: 'ubuntu-24.04'
cython: "==0.29.31" # minimum supported version
- python-version: '3.11'
os: 'ubuntu-24.04'
cython: "==3.0.8" # System version for Ubuntu 24.04

fail-fast: false
steps:
Expand All @@ -95,8 +103,8 @@ jobs:
- name: Install Python dependencies
run: |
python3 -m pip install ruamel.yaml scons==3.1.2 numpy${{ matrix.numpy }} \
cython pandas pytest pytest-github-actions-annotate-failures pytest-xdist \
pint graphviz
cython${{ matrix.cython }} pandas pytest \
pytest-github-actions-annotate-failures pytest-xdist pint graphviz
- name: Build Cantera
run: |
python3 `which scons` build env_vars=all -j4 debug=n --debug=time \
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/func1.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ cdef class Func1:
cdef object exception
cpdef void _set_callback(self, object) except *
@staticmethod
cdef shared_ptr[CxxFunc1] _make_cxx_func1(string, tuple)
cdef shared_ptr[CxxFunc1] _make_cxx_func1(string, tuple) except *
@staticmethod
cdef Func1 _make_func1(shared_ptr[CxxFunc1])
40 changes: 35 additions & 5 deletions interfaces/cython/cantera/func1.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
return pystr(self.func.type())

@staticmethod
cdef shared_ptr[CxxFunc1] _make_cxx_func1(string cxx_string, tuple args):
cdef shared_ptr[CxxFunc1] _make_cxx_func1(string cxx_string, tuple args) except *:
"""Create C++ functor from type specifier and arguments."""
cdef shared_ptr[CxxFunc1] func
cdef Func1 f0
Expand Down Expand Up @@ -244,7 +244,15 @@
if not isinstance(other, Func1):
other = Func1(other)
cdef Func1 f1 = other
return Func1._make_func1(CxxNewSumFunction(self._func, f1._func))

# @todo: When dropping support for Cython < 3.0.0, 'f0' can be removed and
# 'self._func' can be used directly in the C++ call
cdef Func1 f0
if isinstance(self, Func1):
f0 = self
else:
f0 = Func1(self)

Check warning on line 254 in interfaces/cython/cantera/func1.pyx

View check run for this annotation

Codecov / codecov/patch

interfaces/cython/cantera/func1.pyx#L254

Added line #L254 was not covered by tests
return Func1._make_func1(CxxNewSumFunction(f0._func, f1._func))

def __radd__(self, other):
if not isinstance(other, Func1):
Expand All @@ -256,7 +264,15 @@
if not isinstance(other, Func1):
other = Func1(other)
cdef Func1 f1 = other
return Func1._make_func1(CxxNewDiffFunction(self._func, f1._func))

# @todo: When dropping support for Cython < 3.0.0, 'f0' can be removed and
# 'self._func' can be used directly in the C++ call
cdef Func1 f0
if isinstance(self, Func1):
f0 = self
else:
f0 = Func1(self)

Check warning on line 274 in interfaces/cython/cantera/func1.pyx

View check run for this annotation

Codecov / codecov/patch

interfaces/cython/cantera/func1.pyx#L274

Added line #L274 was not covered by tests
return Func1._make_func1(CxxNewDiffFunction(f0._func, f1._func))

def __rsub__(self, other):
if not isinstance(other, Func1):
Expand All @@ -268,7 +284,14 @@
if not isinstance(other, Func1):
other = Func1(other)
cdef Func1 f1 = other
return Func1._make_func1(CxxNewProdFunction(self._func, f1._func))
# @todo: When dropping support for Cython < 3.0.0, 'f0' can be removed and
# 'self._func' can be used directly in the C++ call
cdef Func1 f0
if isinstance(self, Func1):
f0 = self
else:
f0 = Func1(self)

Check warning on line 293 in interfaces/cython/cantera/func1.pyx

View check run for this annotation

Codecov / codecov/patch

interfaces/cython/cantera/func1.pyx#L293

Added line #L293 was not covered by tests
return Func1._make_func1(CxxNewProdFunction(f0._func, f1._func))

def __rmul__(self, other):
if not isinstance(other, Func1):
Expand All @@ -280,7 +303,14 @@
if not isinstance(other, Func1):
other = Func1(other)
cdef Func1 f1 = other
return Func1._make_func1(CxxNewRatioFunction(self._func, f1._func))
# @todo: When dropping support for Cython < 3.0.0, 'f0' can be removed and
# 'self._func' can be used directly in the C++ call
cdef Func1 f0
if isinstance(self, Func1):
f0 = self
else:
f0 = Func1(self)

Check warning on line 312 in interfaces/cython/cantera/func1.pyx

View check run for this annotation

Codecov / codecov/patch

interfaces/cython/cantera/func1.pyx#L312

Added line #L312 was not covered by tests
return Func1._make_func1(CxxNewRatioFunction(f0._func, f1._func))

def __rtruediv__(self, other):
if not isinstance(other, Func1):
Expand Down
Loading