summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-05-09 11:02:52 +0200
committerMichał Górny <mgorny@gentoo.org>2021-05-09 11:13:19 +0200
commit20f30c3568750f4a818ef653be4036b0dca927f5 (patch)
tree87984a102e94789701c84811c5674f88b52d4bfd /dev-util/pkgcheck
parentsys-fs/lvm2: Bump to version 2.03.12. Removed old (diff)
downloadgentoo-20f30c3568750f4a818ef653be4036b0dca927f5.tar.gz
gentoo-20f30c3568750f4a818ef653be4036b0dca927f5.tar.bz2
gentoo-20f30c3568750f4a818ef653be4036b0dca927f5.zip
dev-util/pkgcheck: Fix PythonCompatUpdate handling of py3.10
Fix PythonCompatUpdate check to treat python3.10 as newer than 3.9. Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-util/pkgcheck')
-rw-r--r--dev-util/pkgcheck/files/pkgcheck-0.9.7-py310-update.patch170
-rw-r--r--dev-util/pkgcheck/pkgcheck-0.9.7-r1.ebuild63
2 files changed, 233 insertions, 0 deletions
diff --git a/dev-util/pkgcheck/files/pkgcheck-0.9.7-py310-update.patch b/dev-util/pkgcheck/files/pkgcheck-0.9.7-py310-update.patch
new file mode 100644
index 000000000000..8bee592b228e
--- /dev/null
+++ b/dev-util/pkgcheck/files/pkgcheck-0.9.7-py310-update.patch
@@ -0,0 +1,170 @@
+From 443c0aab158e34196399073e801ae19ae0dce4dc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sun, 9 May 2021 10:59:18 +0200
+Subject: [PATCH] python: Fix treating python3.10 as newer than python3.9
+
+Fix the sorting logic to use a combined lexical-numerical sort, in order
+to sort python3.10 as newer than python3.9. This fixes
+PythonCompatUpdate check.
+---
+ src/pkgcheck/checks/python.py | 25 +++++++++++++++----
+ .../PythonCompatUpdate/expected.json | 6 ++---
+ .../PythonCompatUpdate/fix.patch | 6 ++---
+ .../profiles/desc/python_single_target.desc | 1 +
+ .../python/profiles/desc/python_targets.desc | 1 +
+ .../stub/python-dep1/python-dep1-0.ebuild | 2 +-
+ .../stub/python-dep2/python-dep2-0.ebuild | 2 +-
+ 7 files changed, 30 insertions(+), 13 deletions(-)
+
+diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
+index ed922215..7f0e9be4 100644
+--- a/src/pkgcheck/checks/python.py
++++ b/src/pkgcheck/checks/python.py
+@@ -1,4 +1,5 @@
+ import itertools
++import re
+
+ from pkgcore.ebuild.atom import atom
+ from pkgcore.restrictions import packages, values
+@@ -28,6 +29,18 @@ CHECK_EXCLUDE = frozenset(['virtual/pypy', 'virtual/pypy3'])
+ IUSE_PREFIX = 'python_targets_'
+ IUSE_PREFIX_S = 'python_single_target_'
+
++TARGET_SPLIT_RE = re.compile(r'([0-9]+)')
++
++
++def target_sort_key(target):
++ def iter():
++ for x in TARGET_SPLIT_RE.split(target):
++ try:
++ yield int(x)
++ except ValueError:
++ yield x
++ return tuple(iter())
++
+
+ def get_python_eclass(pkg):
+ eclasses = ECLASSES.intersection(pkg.inherited)
+@@ -281,14 +294,14 @@ class PythonCompatCheck(Check):
+ for target, _desc in repo.config.use_expand_desc.get(IUSE_PREFIX[:-1], ()):
+ if target[len(IUSE_PREFIX):].startswith('python'):
+ targets.append(target[len(IUSE_PREFIX):])
+- multi_targets = tuple(sorted(targets))
++ multi_targets = tuple(sorted(targets, key=target_sort_key))
+
+ # determine available PYTHON_SINGLE_TARGET use flags
+ targets = []
+ for target, _desc in repo.config.use_expand_desc.get(IUSE_PREFIX_S[:-1], ()):
+ if target[len(IUSE_PREFIX_S):].startswith('python'):
+ targets.append(target[len(IUSE_PREFIX_S):])
+- single_targets = tuple(sorted(targets))
++ single_targets = tuple(sorted(targets, key=target_sort_key))
+
+ self.params = {
+ 'python-r1': (multi_targets, IUSE_PREFIX, None),
+@@ -327,8 +340,9 @@ class PythonCompatCheck(Check):
+ try:
+ # determine the latest supported python version
+ latest_target = sorted(
+- f"python{x.slot.replace('.', '_')}" for x in deps
+- if x.key == 'dev-lang/python' and x.slot is not None)[-1]
++ (f"python{x.slot.replace('.', '_')}" for x in deps
++ if x.key == 'dev-lang/python' and x.slot is not None),
++ key=target_sort_key)[-1]
+ except IndexError:
+ # should be flagged by PythonMissingDeps
+ return
+@@ -355,4 +369,5 @@ class PythonCompatCheck(Check):
+ except IndexError:
+ return
+
+- yield PythonCompatUpdate(sorted(targets), pkg=pkg)
++ yield PythonCompatUpdate(sorted(targets, key=target_sort_key),
++ pkg=pkg)
+diff --git a/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/expected.json b/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/expected.json
+index ab7d9b01..f3476eac 100644
+--- a/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/expected.json
++++ b/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/expected.json
+@@ -1,3 +1,3 @@
+-{"__class__": "PythonCompatUpdate", "category": "PythonCompatCheck", "package": "PythonCompatUpdate", "version": "0", "updates": ["python3_8", "python3_9"]}
+-{"__class__": "PythonCompatUpdate", "category": "PythonCompatCheck", "package": "PythonCompatUpdate", "version": "1", "updates": ["python3_9"]}
+-{"__class__": "PythonCompatUpdate", "category": "PythonCompatCheck", "package": "PythonCompatUpdate", "version": "2", "updates": ["python3_9"]}
++{"__class__": "PythonCompatUpdate", "category": "PythonCompatCheck", "package": "PythonCompatUpdate", "version": "0", "updates": ["python3_8", "python3_9", "python3_10"]}
++{"__class__": "PythonCompatUpdate", "category": "PythonCompatCheck", "package": "PythonCompatUpdate", "version": "1", "updates": ["python3_9", "python3_10"]}
++{"__class__": "PythonCompatUpdate", "category": "PythonCompatCheck", "package": "PythonCompatUpdate", "version": "2", "updates": ["python3_9", "python3_10"]}
+diff --git a/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/fix.patch b/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/fix.patch
+index c63184e9..9be4952a 100644
+--- a/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/fix.patch
++++ b/testdata/data/repos/python/PythonCompatCheck/PythonCompatUpdate/fix.patch
+@@ -4,7 +4,7 @@ diff -Naur python/PythonCompatCheck/PythonCompatUpdate/PythonCompatUpdate-0.ebui
+ @@ -1,5 +1,5 @@
+ EAPI=7
+ -PYTHON_COMPAT=( python3_7 )
+-+PYTHON_COMPAT=( python3_{7..9} )
+++PYTHON_COMPAT=( python3_{7..10} )
+
+ inherit python-r1
+
+@@ -14,7 +14,7 @@ diff -Naur python/PythonCompatCheck/PythonCompatUpdate/PythonCompatUpdate-1.ebui
+ @@ -1,5 +1,5 @@
+ EAPI=7
+ -PYTHON_COMPAT=( python3_{7,8} )
+-+PYTHON_COMPAT=( python3_{7..9} )
+++PYTHON_COMPAT=( python3_{7..10} )
+
+ inherit python-single-r1
+
+@@ -24,7 +24,7 @@ diff -Naur python/PythonCompatCheck/PythonCompatUpdate/PythonCompatUpdate-2.ebui
+ @@ -1,5 +1,5 @@
+ EAPI=7
+ -PYTHON_COMPAT=( python3_{7,8} )
+-+PYTHON_COMPAT=( python3_{7..9} )
+++PYTHON_COMPAT=( python3_{7..10} )
+
+ inherit python-any-r1
+
+diff --git a/testdata/repos/python/profiles/desc/python_single_target.desc b/testdata/repos/python/profiles/desc/python_single_target.desc
+index da5be2fd..3c39a224 100644
+--- a/testdata/repos/python/profiles/desc/python_single_target.desc
++++ b/testdata/repos/python/profiles/desc/python_single_target.desc
+@@ -3,4 +3,5 @@ python2_7 - Build with Python 2.7
+ python3_7 - Build with Python 3.7
+ python3_8 - Build with Python 3.8
+ python3_9 - Build with Python 3.9
++python3_10 - Build with Python 3.10
+ pypy3 - Build for PyPy3 only
+diff --git a/testdata/repos/python/profiles/desc/python_targets.desc b/testdata/repos/python/profiles/desc/python_targets.desc
+index b2be59ca..8e55f2da 100644
+--- a/testdata/repos/python/profiles/desc/python_targets.desc
++++ b/testdata/repos/python/profiles/desc/python_targets.desc
+@@ -3,4 +3,5 @@ python2_7 - Build with Python 2.7
+ python3_7 - Build with Python 3.7
+ python3_8 - Build with Python 3.8
+ python3_9 - Build with Python 3.9
++python3_10 - Build with Python 3.10
+ pypy3 - Build for PyPy3 only
+diff --git a/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild b/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild
+index 9eebedfd..55c455d9 100644
+--- a/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild
++++ b/testdata/repos/python/stub/python-dep1/python-dep1-0.ebuild
+@@ -1,5 +1,5 @@
+ EAPI=7
+-PYTHON_COMPAT=( python2_7 python3_{7,8,9} )
++PYTHON_COMPAT=( python2_7 python3_{7,8,9,10} )
+
+ inherit python-r1
+
+diff --git a/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild b/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild
+index 9eebedfd..55c455d9 100644
+--- a/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild
++++ b/testdata/repos/python/stub/python-dep2/python-dep2-0.ebuild
+@@ -1,5 +1,5 @@
+ EAPI=7
+-PYTHON_COMPAT=( python2_7 python3_{7,8,9} )
++PYTHON_COMPAT=( python2_7 python3_{7,8,9,10} )
+
+ inherit python-r1
+
+--
+2.31.1
+
diff --git a/dev-util/pkgcheck/pkgcheck-0.9.7-r1.ebuild b/dev-util/pkgcheck/pkgcheck-0.9.7-r1.ebuild
new file mode 100644
index 000000000000..1859af4de531
--- /dev/null
+++ b/dev-util/pkgcheck/pkgcheck-0.9.7-r1.ebuild
@@ -0,0 +1,63 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+PYTHON_COMPAT=( python3_{8..9} )
+DISTUTILS_IN_SOURCE_BUILD=1
+inherit distutils-r1 optfeature
+
+if [[ ${PV} == *9999 ]] ; then
+ EGIT_REPO_URI="https://github.com/pkgcore/pkgcheck.git"
+ inherit git-r3
+else
+ KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x64-macos"
+ SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+fi
+
+DESCRIPTION="pkgcore-based QA utility for ebuild repos"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+
+LICENSE="BSD MIT"
+SLOT="0"
+
+if [[ ${PV} == *9999 ]]; then
+ RDEPEND="
+ ~dev-python/snakeoil-9999[${PYTHON_USEDEP}]
+ ~sys-apps/pkgcore-9999[${PYTHON_USEDEP}]"
+else
+ RDEPEND="
+ >=dev-python/snakeoil-0.9.6[${PYTHON_USEDEP}]
+ >=sys-apps/pkgcore-0.11.6[${PYTHON_USEDEP}]"
+fi
+RDEPEND+="
+ dev-python/chardet[${PYTHON_USEDEP}]
+ dev-python/lazy-object-proxy[${PYTHON_USEDEP}]
+ dev-python/lxml[${PYTHON_USEDEP}]
+ dev-python/pathspec[${PYTHON_USEDEP}]
+ >=dev-python/tree-sitter-0.19.0[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ test? ( dev-python/pytest[${PYTHON_USEDEP}] )
+"
+
+distutils_enable_tests setup.py
+
+PATCHES=(
+ "${FILESDIR}"/${P}-py310-update.patch
+)
+
+src_test() {
+ local -x PYTHONDONTWRITEBYTECODE=
+ distutils-r1_src_test
+}
+
+python_install_all() {
+ local DOCS=( NEWS.rst )
+ [[ ${PV} == *9999 ]] || doman man/*
+ distutils-r1_python_install_all
+}
+
+pkg_postinst() {
+ optfeature "Network check support" dev-python/requests
+ optfeature "Perl module version check support" dev-perl/Gentoo-PerlMod-Version
+}