Fix build with Cython 3

This commit is contained in:
Miro Hrončok 2023-07-28 11:16:57 +02:00
parent 65ff977efa
commit fae3da3392
2 changed files with 49 additions and 4 deletions

39
731.patch Normal file
View File

@ -0,0 +1,39 @@
From 17dc5b6cd96dcfe64fd71789c771ca9b96d260e5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 21 Jul 2023 09:50:00 -0400
Subject: [PATCH] Fix builds with Cython 3
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>
---
setup.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 944e7fa2..462b1e95 100644
--- a/setup.py
+++ b/setup.py
@@ -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:

View File

@ -7,7 +7,7 @@
Name: PyYAML
Version: 6.0.1
Release: 3%{?dist}
Release: 4%{?dist}
%global uversion %{version}
Summary: YAML parser and emitter for Python
@ -15,6 +15,10 @@ License: MIT
URL: https://github.com/yaml/pyyaml
Source0: https://github.com/yaml/pyyaml/archive/%{uversion}.tar.gz
# Fix build with Cython 3
# Proposed upstream but refused (upstream does not want Cython 3)
Patch: https://github.com/yaml/pyyaml/pull/731.patch
BuildRequires: gcc
BuildRequires: libyaml-devel
@ -25,8 +29,7 @@ BuildRequires: python2-setuptools
BuildRequires: python3-devel
BuildRequires: python3-setuptools
# This requires cython 0.29, see https://github.com/yaml/pyyaml/issues/601
BuildRequires: python3-cython < 3
BuildRequires: python3-cython
%global _description\
@ -68,7 +71,7 @@ Summary: %summary
%prep
%setup -q -n pyyaml-%{uversion}
%autosetup -p1 -n pyyaml-%{uversion}
chmod a-x examples/yaml-highlight/yaml_hl.py
# remove pre-generated file
@ -112,6 +115,9 @@ rm -rf ext/_yaml.c
%changelog
* Fri Jul 28 2023 Miro Hrončok <mhroncok@redhat.com> - 6.0.1-4
- Fix build with Cython 3
* Tue Jul 25 2023 Miro Hrončok <mhroncok@redhat.com> - 6.0.1-3
- Pin Cython < 3 to build this package