From f5fb4fa3cc03aa0efb12a32e902b42834647433e4b5a388d8c61f29b8af81a5e Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 27 Feb 2023 19:16:16 +0000 Subject: [PATCH] - add fix-python-3.11.patch from upstream PR #65 to fix the build on Python 3.11. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-exrex?expand=0&rev=15 --- fix-python-3.11.patch | 46 +++++++++++++++++++++++++++++++++++++++++++ python-exrex.changes | 5 +++++ python-exrex.spec | 12 +++++++---- 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 fix-python-3.11.patch diff --git a/fix-python-3.11.patch b/fix-python-3.11.patch new file mode 100644 index 0000000..4303d50 --- /dev/null +++ b/fix-python-3.11.patch @@ -0,0 +1,46 @@ +From 44712bfb1350a509581a5834d9fa8aebcd9434db Mon Sep 17 00:00:00 2001 +From: Michael Souza <119819695+sumslogs@users.noreply.github.com> +Date: Sat, 10 Dec 2022 21:52:13 -0800 +Subject: [PATCH] Fix: Import error sre_parse + +sre_parse module was moved in py3.11 +--- + exrex.py | 6 +++++- + tests.py | 6 +++++- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/exrex.py b/exrex.py +index 24c0de9..be74f92 100644 +--- a/exrex.py ++++ b/exrex.py +@@ -22,7 +22,11 @@ + from future_builtins import map, range + except: + pass +-from re import match, sre_parse, U ++from re import match, U ++try: ++ import re._parser as sre_parse ++except ImportError: # Python < 3.11 ++ from re import sre_parse + from itertools import tee + from random import choice, randint + from types import GeneratorType +diff --git a/tests.py b/tests.py +index 8a8a63e..ef0d42c 100644 +--- a/tests.py ++++ b/tests.py +@@ -20,8 +20,12 @@ + + from exrex import generate, count, getone, CATEGORIES, simplify + import re +-import sre_parse ++try: ++ import re._parser as sre_parse ++except ImportError: # Python < 3.11 ++ from re import sre_parse + from sys import exit, version_info ++ + IS_PY3 = version_info[0] == 3 + + RS = { diff --git a/python-exrex.changes b/python-exrex.changes index 8e51e83..a470f7c 100644 --- a/python-exrex.changes +++ b/python-exrex.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Feb 27 19:06:55 UTC 2023 - Sebastian Wagner + +- add fix-python-3.11.patch from upstream PR #65 to fix the build on Python 3.11. + ------------------------------------------------------------------- Thu Feb 25 19:25:16 UTC 2021 - Sebastian Wagner diff --git a/python-exrex.spec b/python-exrex.spec index ffb0aaf..d4ceaf5 100644 --- a/python-exrex.spec +++ b/python-exrex.spec @@ -1,7 +1,7 @@ # # spec file for package python-exrex # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,7 +16,6 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} %define revision fd1e21ffc7c16fd5637a5c440224766417e840f9 %define skip_python2 1 Name: python-exrex @@ -30,12 +29,14 @@ URL: https://github.com/asciimoo/exrex Source: https://github.com/asciimoo/exrex/archive/%{revision}.tar.gz#/exrex-%{version}.tar.gz # PATCH-FIX-UPSTREAM fix-setup-encoding.patch Patch0: https://github.com/asciimoo/exrex/pull/53.patch#/fix-setup-encoding.patch +# PATCH-FIX-UPSTREAM fix-python-3.11.patch +Patch1: https://github.com/asciimoo/exrex/pull/65.patch#/fix-python-3.11.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-setuptools Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives BuildArch: noarch %python_subpackages @@ -46,6 +47,7 @@ A command line tool and python module that generates all or random matching stri %setup -q -n exrex-%{revision} sed -i '1s/^#!.*//' exrex.py %patch0 -p1 +%patch1 -p1 %build %python_build @@ -67,7 +69,9 @@ LANG=C.UTF-8 PYTHONPATH=%{buildroot}%{$python_sitelib} $python ./tests.py} %python_uninstall_alternative exrex %files %{python_files} -%{python_sitelib}/* +%{python_sitelib}/exrex* +%{python_sitelib}/__pycache__/exrex.* +%{python_sitelib}/exrex-0.10.6*-info %license COPYING %doc README.md doc/ %python_alternative %{_bindir}/exrex