diff --git a/python-biopython-fix_compatibility_with_reportlab4.patch b/python-biopython-fix_compatibility_with_reportlab4.patch
new file mode 100644
index 0000000..ef19945
--- /dev/null
+++ b/python-biopython-fix_compatibility_with_reportlab4.patch
@@ -0,0 +1,29 @@
+From 74fdf49ade95157c3c4b23a95831925be4899223 Mon Sep 17 00:00:00 2001
+From: Peter Cock
+Date: Mon, 5 Jun 2023 12:39:59 +0100
+Subject: [PATCH] Skip if ReportLab bitmap output module missing
+
+Would like to skip this earlier, but not so
+easy in ReportLab v4 with a choice of backends
+---
+ Tests/test_GraphicsBitmaps.py | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/Tests/test_GraphicsBitmaps.py b/Tests/test_GraphicsBitmaps.py
+index 2ffdfb3dd71..76615a2fd1d 100644
+--- a/Tests/test_GraphicsBitmaps.py
++++ b/Tests/test_GraphicsBitmaps.py
+@@ -111,9 +111,12 @@ def real_test():
+ "Check the fonts needed by ReportLab if you want "
+ "bitmaps from Bio.Graphics\n" + str(err)
+ ) from None
++ elif str(err).startswith("cannot import desired renderPM backend rlPyCairo"):
++ raise MissingExternalDependencyError(
++ "Reportlab module rlPyCairo unavailable\n" + str(err)
++ ) from None
+ else:
+ raise
+-
+ return True
+
+
diff --git a/python-biopython-fix_for_python312.patch b/python-biopython-fix_for_python312.patch
new file mode 100644
index 0000000..8f903a4
--- /dev/null
+++ b/python-biopython-fix_for_python312.patch
@@ -0,0 +1,11 @@
+--- a/Tests/test_Entrez.orig.py 2023-02-13 04:07:42.000000000 +0100
++++ b/Tests/test_Entrez.py 2023-06-30 14:42:58.177365639 +0200
+@@ -126,7 +126,7 @@
+ :type params: dict
+ :param expected: Expected set of IDs, as colleciton of strings.
+ """
+- testcase.assertEquals(len(params["id"]), 1)
++ testcase.assertEqual(len(params["id"]), 1)
+ ids_str = params["id"][0]
+ # Compare up to ordering
+ testcase.assertCountEqual(ids_str.split(","), expected)
diff --git a/python-biopython.spec b/python-biopython.spec
index 8c4bf08..4b45100 100644
--- a/python-biopython.spec
+++ b/python-biopython.spec
@@ -4,9 +4,11 @@
Name: python-%{pypi_name}
Version: 1.81
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Python tools for computational molecular biology
Source0: %{pypi_source}
+Patch0: %{name}-fix_for_python312.patch
+Patch1: %{name}-fix_compatibility_with_reportlab4.patch
# Starting from biopython-1.69, BioPython is released under the
# "Biopython License Agreement"; it looks like a MIT variant
@@ -56,6 +58,10 @@ PDF/HTML documentation of %{module}.
%setup -qc
pushd %{module}-%{version}
+
+%patch -P 0 -p1 -b .backup
+%patch -P 1 -p1 -b .backup
+
# remove all execute bits from documentation and fix line endings
find Scripts -type f -exec chmod -x {} 2>/dev/null ';'
find Doc -type f -exec chmod -x {} 2>/dev/null ';'
@@ -116,6 +122,9 @@ popd
%license %{module}-%{version}/LICENSE.rst
%changelog
+* Fri Jun 30 2023 Antonio Trande - 1.81-3
+- Patched for Python-3.12
+
* Fri Jun 16 2023 Python Maint - 1.81-2
- Rebuilt for Python 3.12