commit: 5d3acdd44e5eca632b235f8e0b894fb17a5d47b0 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sat May 27 16:11:32 2023 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Sat May 27 17:13:07 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5d3acdd4
dev-python/pytest-shutil: Enable py3.12, fix tests Closes: https://bugs.gentoo.org/888217 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> .../files/pytest-shutil-1.7.0-py312.patch | 39 ++++++++++++++++ .../pytest-shutil/pytest-shutil-1.7.0-r4.ebuild | 54 ++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/dev-python/pytest-shutil/files/pytest-shutil-1.7.0-py312.patch b/dev-python/pytest-shutil/files/pytest-shutil-1.7.0-py312.patch new file mode 100644 index 000000000000..905550622fc1 --- /dev/null +++ b/dev-python/pytest-shutil/files/pytest-shutil-1.7.0-py312.patch @@ -0,0 +1,39 @@ +From bbb9e5c7cba84fb4665a521569d1cfcca08ee4e5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Sat, 27 May 2023 18:05:44 +0200 +Subject: [PATCH] pytest-shutil: Replace deprecated imp module + +Replace the use of the deprecated `imp` module with `importlib.util', +as the former has been removed from Python 3.12. +--- + pytest-shutil/pytest_shutil/run.py | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/pytest-shutil/pytest_shutil/run.py b/pytest-shutil/pytest_shutil/run.py +index 7d46aea..08a6a34 100644 +--- a/pytest_shutil/run.py ++++ b/pytest_shutil/run.py +@@ -3,7 +3,7 @@ + """ + import sys + import os +-import imp ++import importlib.util + import logging + from functools import update_wrapper + import inspect +@@ -112,7 +112,10 @@ def run_module_as_main(module, argv=[]): + filename = os.path.splitext(filename)[0] + ".py" + + with patch("sys.argv", new=argv): +- imp.load_source('__main__', os.path.join(where, filename)) ++ spec = importlib.util.spec_from_file_location( ++ "__main__", os.path.join(where, filename)) ++ module = importlib.util.module_from_spec(spec) ++ spec.loader.exec_module(module) + + + def _evaluate_fn_source(src, *args, **kwargs): +-- +2.40.1 + diff --git a/dev-python/pytest-shutil/pytest-shutil-1.7.0-r4.ebuild b/dev-python/pytest-shutil/pytest-shutil-1.7.0-r4.ebuild new file mode 100644 index 000000000000..964dfd2574a9 --- /dev/null +++ b/dev-python/pytest-shutil/pytest-shutil-1.7.0-r4.ebuild @@ -0,0 +1,54 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYPI_NO_NORMALIZE=1 +PYTHON_COMPAT=( python3_{10..12} pypy3 ) + +inherit distutils-r1 pypi + +DESCRIPTION="A goodie-bag of unix shell and environment tools for py.test" +HOMEPAGE=" + https://github.com/man-group/pytest-plugins/ + https://pypi.org/project/pytest-shutil/ +" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-macos" + +RDEPEND=" + dev-python/pytest[${PYTHON_USEDEP}] + dev-python/six[${PYTHON_USEDEP}] + dev-python/execnet[${PYTHON_USEDEP}] + dev-python/path[${PYTHON_USEDEP}] + dev-python/mock[${PYTHON_USEDEP}] + dev-python/termcolor[${PYTHON_USEDEP}] +" +BDEPEND=" + ${RDEPEND} + dev-python/setuptools-git[${PYTHON_USEDEP}] +" + +distutils_enable_tests pytest + +PATCHES=( + # https://github.com/man-group/pytest-plugins/pull/219 + "${FILESDIR}"/${P}-py312.patch +) + +EPYTEST_DESELECT=( + # colors no longer happen automagically to non-tty, not important + # https://github.com/man-group/pytest-plugins/pull/217 + tests/unit/test_cmdline.py::test_pretty_formatter +) + +python_prepare_all() { + # remove unnecessary deps + # (contextlib2 is not used in py3) + sed -i -e '/path\.py/d' -e '/contextlib2/d' setup.py || die + + distutils-r1_python_prepare_all +}
