summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-01-26 11:10:50 +0100
committerMichał Górny <mgorny@gentoo.org>2023-01-26 11:10:50 +0100
commit53f7551e696b3fb8e03626855e9ed0f302a50ba0 (patch)
treec2d179f4dec96a9f4483413a5ce138b548d65e94
parentdev-python/bandit: Backport tomllib/tomli port (diff)
downloadgentoo-53f7551e696b3fb8e03626855e9ed0f302a50ba0.tar.gz
gentoo-53f7551e696b3fb8e03626855e9ed0f302a50ba0.tar.bz2
gentoo-53f7551e696b3fb8e03626855e9ed0f302a50ba0.zip
dev-python/podman-py: Backport tomli/tomllib port
Closes: https://bugs.gentoo.org/878665 Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--dev-python/podman-py/files/podman-py-4.3.0-tomli.patch89
-rw-r--r--dev-python/podman-py/podman-py-4.3.0-r1.ebuild (renamed from dev-python/podman-py/podman-py-4.3.0.ebuild)8
2 files changed, 96 insertions, 1 deletions
diff --git a/dev-python/podman-py/files/podman-py-4.3.0-tomli.patch b/dev-python/podman-py/files/podman-py-4.3.0-tomli.patch
new file mode 100644
index 000000000000..0be9ab796217
--- /dev/null
+++ b/dev-python/podman-py/files/podman-py-4.3.0-tomli.patch
@@ -0,0 +1,89 @@
+From c5a356fb4ea8a6fb66a6d20bdc2c9cffe615028b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Fri, 14 Oct 2022 13:54:31 +0200
+Subject: [PATCH] Use modern tomllib/tomli modules for reading TOML files
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Replace the unmaintained `toml`/`pytoml` dependencies with the modern
+alternatives: the built-in `tomllib` module in Python 3.11, and `tomli`
+in older Python versions. Preserving backwards compatibility does not
+seem necessary, as podman-py no longer supports Python versions older
+than 3.6.
+
+Signed-off-by: Michał Górny <mgorny@gentoo.org>
+---
+ podman/domain/config.py | 16 ++++++++++------
+ pyproject.toml | 2 +-
+ python-podman.spec.rpkg | 8 ++++----
+ requirements.txt | 2 +-
+ setup.cfg | 2 +-
+ 5 files changed, 17 insertions(+), 13 deletions(-)
+
+diff --git a/podman/domain/config.py b/podman/domain/config.py
+index 555ed9d..6ea8eb6 100644
+--- a/podman/domain/config.py
++++ b/podman/domain/config.py
+@@ -1,17 +1,21 @@
+ """Read containers.conf file."""
++import sys
+ import urllib
+ from pathlib import Path
+ from typing import Dict, Optional
+
+ import xdg.BaseDirectory
+
+-try:
+- import toml
+-except ImportError:
+- import pytoml as toml
+-
+ from podman.api import cached_property
+
++if sys.version_info >= (3, 11):
++ from tomllib import loads as toml_loads
++else:
++ try:
++ from tomli import loads as toml_loads
++ except ImportError:
++ from toml import loads as toml_loads
++
+
+ class ServiceConnection:
+ """ServiceConnection defines a connection to the Podman service."""
+@@ -64,7 +68,7 @@ def __init__(self, path: Optional[str] = None):
+ if self.path.exists():
+ with self.path.open(encoding='utf-8') as file:
+ buffer = file.read()
+- self.attrs = toml.loads(buffer)
++ self.attrs = toml_loads(buffer)
+
+ def __hash__(self) -> int:
+ return hash(tuple(self.path.name))
+diff --git a/pyproject.toml b/pyproject.toml
+index f3cdfb9..3b29ecb 100644
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -25,7 +25,7 @@ requires = [
+ "requests>=2.24",
+ "setuptools>=46.4",
+ "sphinx",
+- "toml>=0.10.2",
++ "tomli>=1.2.3; python_version<'3.11'",
+ "urllib3>=1.24.2",
+ "wheel",
+ ]
+diff --git a/setup.cfg b/setup.cfg
+index f8d1b6f..2066951 100644
+--- a/setup.cfg
++++ b/setup.cfg
+@@ -36,7 +36,7 @@ test_suite =
+ install_requires =
+ pyxdg>=0.26
+ requests>=2.24
+- toml>=0.10.2
++ tomli>=1.2.3; python_version<'3.11'
+ urllib3>=1.24.2
+
+ # typing_extensions are included for RHEL 8.5
diff --git a/dev-python/podman-py/podman-py-4.3.0.ebuild b/dev-python/podman-py/podman-py-4.3.0-r1.ebuild
index d52abd69e9e2..e223cbf3882a 100644
--- a/dev-python/podman-py/podman-py-4.3.0.ebuild
+++ b/dev-python/podman-py/podman-py-4.3.0-r1.ebuild
@@ -25,8 +25,10 @@ KEYWORDS="~amd64"
RDEPEND="
>=dev-python/pyxdg-0.26[${PYTHON_USEDEP}]
>=dev-python/requests-2.24[${PYTHON_USEDEP}]
- >=dev-python/toml-0.10.2[${PYTHON_USEDEP}]
>=dev-python/urllib3-1.24.2[${PYTHON_USEDEP}]
+ $(python_gen_cond_dep '
+ >=dev-python/tomli-1.2.3[${PYTHON_USEDEP}]
+ ' 3.{8..10})
"
BDEPEND="
test? (
@@ -36,6 +38,10 @@ BDEPEND="
distutils_enable_tests pytest
+PATCHES=(
+ "${FILESDIR}"/${P}-tomli.patch
+)
+
python_test() {
local EPYTEST_DESELECT=(
# TODO