#2 Fix Python 3.12 compatibility
Merged 9 months ago by ankursinha. Opened 10 months ago by music.
rpms/ music/python-ansiwrap py3.12  into  rawhide

file removed
-25
@@ -1,25 +0,0 @@ 

- From b7f0149d6063c095da5ccb74afc6262682a9ff92 Mon Sep 17 00:00:00 2001

- From: "Benjamin A. Beasley" <code@musicinmybrain.net>

- Date: Mon, 20 Jun 2022 09:27:40 -0400

- Subject: [PATCH] Fix tests on Python 3.11 (fix #18)

- 

- random.sample() population must be a sequence

- ---

-  test/test_ansiwrap.py | 4 ++--

-  1 file changed, 2 insertions(+), 2 deletions(-)

- 

- diff --git a/test/test_ansiwrap.py b/test/test_ansiwrap.py

- index 13e7149..da97f0e 100644

- --- a/test/test_ansiwrap.py

- +++ b/test/test_ansiwrap.py

- @@ -20,8 +20,8 @@

-  

-  # as an alternative to testing all lengths at all times, which is slow,

-  # choose a few other lengths at random

- -other_lengths = (random.sample(set(range(20, 120)).difference(LINE_LENGTHS), 2) +

- -                 random.sample(set(range(120, 400)).difference(LINE_LENGTHS), 1))

- +other_lengths = (random.sample(sorted(set(range(20, 120)).difference(LINE_LENGTHS)), 2) +

- +                 random.sample(sorted(set(range(120, 400)).difference(LINE_LENGTHS)), 1))

-  LINE_LENGTHS.extend(other_lengths)

-  

-  

file added
+54
@@ -0,0 +1,54 @@ 

+ From ab7b86c9c8a90206f969a006d9297a60ca931496 Mon Sep 17 00:00:00 2001

+ From: "Benjamin A. Beasley" <code@musicinmybrain.net>

+ Date: Mon, 20 Jun 2022 09:27:40 -0400

+ Subject: [PATCH 1/2] Fix tests on Python 3.11 (fix #18)

+ 

+ random.sample() population must be a sequence

+ ---

+  test/test_ansiwrap.py | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/test/test_ansiwrap.py b/test/test_ansiwrap.py

+ index 13e7149..bf7456e 100644

+ --- a/test/test_ansiwrap.py

+ +++ b/test/test_ansiwrap.py

+ @@ -20,8 +20,8 @@

+  

+  # as an alternative to testing all lengths at all times, which is slow,

+  # choose a few other lengths at random

+ -other_lengths = (random.sample(set(range(20, 120)).difference(LINE_LENGTHS), 2) +

+ -                 random.sample(set(range(120, 400)).difference(LINE_LENGTHS), 1))

+ +other_lengths = (random.sample(list(set(range(20, 120)).difference(LINE_LENGTHS)), 2) +

+ +                 random.sample(list(set(range(120, 400)).difference(LINE_LENGTHS)), 1))

+  LINE_LENGTHS.extend(other_lengths)

+  

+  

+ 

+ From f6393a1e96b2d904f1a0d860930eacb5440c49fb Mon Sep 17 00:00:00 2001

+ From: "Benjamin A. Beasley" <code@musicinmybrain.net>

+ Date: Thu, 29 Jun 2023 16:29:52 -0400

+ Subject: [PATCH 2/2] Work around imp module removal in Python 3.12

+ 

+ ---

+  ansiwrap/core.py | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/ansiwrap/core.py b/ansiwrap/core.py

+ index 88ff453..99d0f44 100644

+ --- a/ansiwrap/core.py

+ +++ b/ansiwrap/core.py

+ @@ -3,12 +3,12 @@

+  from ansiwrap.ansistate import ANSIState

+  import re

+  import sys

+ -import imp

+ +import importlib

+  

+  # import a copy of textwrap3 which we will viciously monkey-patch

+  # to use our version of len, not the built-in

+  import os

+ -a_textwrap = imp.load_module('a_textwrap', *imp.find_module('textwrap3'))

+ +a_textwrap = importlib.import_module('textwrap3')

+  

+  

+  __all__ = 'wrap fill shorten strip_color ansilen ansi_terminate_lines'.split()

file modified
+12 -2
@@ -2,7 +2,7 @@ 

  

  Name:           python-%{pypi_name}

  Version:        0.8.4

- Release:        12%{?dist}

+ Release:        13%{?dist}

  Summary:        Text wrapper with ANSI colors and styles support

  

  License:        ASL 2.0
@@ -10,7 +10,14 @@ 

  Source0:        %{pypi_source %{pypi_name} %{version} zip}

  BuildArch:      noarch

  

- Patch:          %{url}/pull/19.patch

+ # Fix Python 3.12 compatibility

+ # https://github.com/jonathaneunice/ansiwrap/pull/20

+ #

+ # Builds on and includes:

+ #

+ # Fix tests on Python 3.11

+ # https://github.com/jonathaneunice/ansiwrap/pull/19

+ Patch:          %{url}/pull/20.patch

  

  %description

  ansiwrap wraps text, like the standard textwrap module. But it also correctly
@@ -59,6 +66,9 @@ 

  %{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info

  

  %changelog

+ * Fri Jul 21 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.8.4-13

+ - Patch for Python 3.12

+ 

  * Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.4-12

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

  

Please have a look at this; python-ansiwrap is a dependency for jrnl. If merged while the f39-python (Python 3.12 mass rebuild) side tag is still open, please build there instead of directly in Rawhide (fedpkg build --target=f39-python).

This looks good to me. @music : could you please rebase this to remove conflicts?

@fab : this has already been open for 3 weeks now. Could you please take a look? Otherwise I hope you won't mind if one of the neuro-sig/python-sig proven packagers proceed here? It's holding up quite a few packages.

rebased onto 7de57d7

9 months ago

Pull-Request has been merged by ankursinha

9 months ago