Skip to content

Commit

Permalink
Fix builds with Cython 3
Browse files Browse the repository at this point in the history
This is a *de minimis* fix for building with Cython 3. Recent Cython<3
releases provided `Cython.Distutils.build_ext` as an alias to
`Cython.Distutils.old_build_ext.old_build_ext`; Cython 3 drops this
alias and instead uses a wholly new `Cython.Distutils.build_ext` that
does not provide the `cython_sources` function used in `setup.py`.

Explicitly importing `old_build_ext` preserves the existing behavior for
recent Cython<3 and uses the correct behavior for Cython 3. Should the
import fail (*e.g.*, because the version of Cython available predates
the availability of `old_build_ext`), the import falls back to just
`Cython.Distutils.build_ext`.

Signed-off-by: Andrew J. Hesford <ajh@sideband.org>
  • Loading branch information
ahesford committed Jul 21, 2023
1 parent 957ae4d commit 17dc5b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@
with_cython = True
try:
from Cython.Distutils.extension import Extension as _Extension
from Cython.Distutils import build_ext as _build_ext
try:
from Cython.Distutils.old_build_ext import old_build_ext as _build_ext
except ImportError:
from Cython.Distutils import build_ext as _build_ext

with_cython = True
except ImportError:
if with_cython:
Expand Down

0 comments on commit 17dc5b6

Please sign in to comment.