Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/tqdm/, dev-python/tqdm/files/
Date: Tue, 26 May 2020 20:03:05
Message-Id: 1590523378.f4aab29c1ef358c5c1ceb97fb2fce7f34e4b9179.mgorny@gentoo
1 commit: f4aab29c1ef358c5c1ceb97fb2fce7f34e4b9179
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue May 26 19:52:01 2020 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue May 26 20:02:58 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f4aab29c
7
8 dev-python/tqdm: Port to py39
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-python/tqdm/files/tqdm-4.46.0-py39.patch | 42 ++++++++++++++++++++++++++++
13 dev-python/tqdm/tqdm-4.46.0.ebuild | 6 +++-
14 2 files changed, 47 insertions(+), 1 deletion(-)
15
16 diff --git a/dev-python/tqdm/files/tqdm-4.46.0-py39.patch b/dev-python/tqdm/files/tqdm-4.46.0-py39.patch
17 new file mode 100644
18 index 00000000000..0734aa83b96
19 --- /dev/null
20 +++ b/dev-python/tqdm/files/tqdm-4.46.0-py39.patch
21 @@ -0,0 +1,42 @@
22 +From aeb52044ca29f37f1f98ee5a4f9ad774d557771e Mon Sep 17 00:00:00 2001
23 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
24 +Date: Tue, 26 May 2020 21:43:05 +0200
25 +Subject: [PATCH] Fix error due to missing sys.setcheckinterval in py3.9
26 +
27 +Python 3.9 finally removed sys.setcheckinterval(). While the package
28 +apparently tried to account for that, the logic is flawed and the second
29 +getattr() raises an AttributeError even if its result is never used.
30 +This caused tests to fail:
31 +
32 + File "/tmp/tqdm/tqdm/tests/tests_tqdm.py", line 126, in pretest
33 + getattr(sys, 'setswitchinterval', getattr(sys, 'setcheckinterval'))(100)
34 + AttributeError: module 'sys' has no attribute 'setcheckinterval'
35 +
36 +Refactor the code into a try/except construct that does not execute
37 +the setcheckinterval() branch unless setswitchinterval() is actually
38 +missing. While at it, scale the arguments a bit -- the current version
39 +used either 100 instructions or 100 seconds that were rather of very
40 +different magnitudes.
41 +---
42 + tqdm/tests/tests_tqdm.py | 5 ++++-
43 + 1 file changed, 4 insertions(+), 1 deletion(-)
44 +
45 +diff --git a/tqdm/tests/tests_tqdm.py b/tqdm/tests/tests_tqdm.py
46 +index a2dac52..5f322e6 100644
47 +--- a/tqdm/tests/tests_tqdm.py
48 ++++ b/tqdm/tests/tests_tqdm.py
49 +@@ -123,7 +123,10 @@ def cpu_timify(t, timer=None):
50 +
51 + def pretest():
52 + # setcheckinterval is deprecated
53 +- getattr(sys, 'setswitchinterval', getattr(sys, 'setcheckinterval'))(100)
54 ++ try:
55 ++ sys.setswitchinterval(1)
56 ++ except AttributeError:
57 ++ sys.setcheckinterval(100)
58 +
59 + if getattr(tqdm, "_instances", False):
60 + n = len(tqdm._instances)
61 +--
62 +2.26.2
63 +
64
65 diff --git a/dev-python/tqdm/tqdm-4.46.0.ebuild b/dev-python/tqdm/tqdm-4.46.0.ebuild
66 index 4bafe9ec336..2273ba0de86 100644
67 --- a/dev-python/tqdm/tqdm-4.46.0.ebuild
68 +++ b/dev-python/tqdm/tqdm-4.46.0.ebuild
69 @@ -4,7 +4,7 @@
70 EAPI=7
71
72 DISTUTILS_USE_SETUPTOOLS=rdepend
73 -PYTHON_COMPAT=( pypy3 python{2_7,3_{6,7,8}} )
74 +PYTHON_COMPAT=( pypy3 python{2_7,3_{6,7,8,9}} )
75
76 inherit distutils-r1
77
78 @@ -25,6 +25,10 @@ IUSE="examples"
79
80 distutils_enable_tests nose
81
82 +PATCHES=(
83 + "${FILESDIR}"/${P}-py39.patch
84 +)
85 +
86 python_prepare_all() {
87 sed -r \
88 -e "s:'nose'(,[[:space:]]*|)::" \