From 0c4bbad3c326e77c8d32f62d2fa707adc00ff99a Mon Sep 17 00:00:00 2001 From: Joel Capitao Date: Nov 06 2024 13:55:02 +0000 Subject: Import python-tox-4.21.2-1.el10~bootstrap in CloudSIG Epoxy --- diff --git a/.python-tox.metadata b/.python-tox.metadata new file mode 100644 index 0000000..2c48a01 --- /dev/null +++ b/.python-tox.metadata @@ -0,0 +1 @@ +bcbbcd7530006f657a911b80ec8ecfb3d11d0ed1 SOURCES/tox-4.21.2.tar.gz diff --git a/SOURCES/fix-tests.patch b/SOURCES/fix-tests.patch new file mode 100644 index 0000000..b901b9d --- /dev/null +++ b/SOURCES/fix-tests.patch @@ -0,0 +1,124 @@ +From 2c5dce5c027de2662d81944f1ba129d8a860b0a7 Mon Sep 17 00:00:00 2001 +From: Lumir Balhar +Date: Tue, 10 Jan 2023 08:34:25 +0100 +Subject: [PATCH] fix tests + +--- + pyproject.toml | 8 -------- + src/tox/pytest.py | 16 +++------------- + tests/test_provision.py | 18 ++---------------- + 3 files changed, 5 insertions(+), 37 deletions(-) + +diff --git a/pyproject.toml b/pyproject.toml +index 50142c5..66f8b5a 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -74,17 +74,12 @@ optional-dependencies.docs = [ + ] + optional-dependencies.testing = [ + "build[virtualenv]>=1.2.2", +- "covdefaults>=2.3", +- "detect-test-pollution>=1.2", +- "devpi-process>=1.0.2", +- "diff-cover>=9.2", + "distlib>=0.3.8", + "flaky>=3.8.1", + "hatch-vcs>=0.4", + "hatchling>=1.25", + "psutil>=6", + "pytest>=8.3.3", +- "pytest-cov>=5", + "pytest-mock>=3.14", + "pytest-xdist>=3.6.1", + "re-assert>=1.1", +@@ -192,9 +187,6 @@ report.omit = [ + "tests/type_check/*", + ] + run.parallel = true +-run.plugins = [ +- "covdefaults", +-] + + [tool.towncrier] + name = "tox" +diff --git a/src/tox/pytest.py b/src/tox/pytest.py +index 13072fd..80bf266 100644 +--- a/src/tox/pytest.py ++++ b/src/tox/pytest.py +@@ -17,7 +17,6 @@ from typing import TYPE_CHECKING, Any, Callable, Iterator, Protocol, Sequence, c + + import pytest + from _pytest.fixtures import SubRequest # noqa: PLC2701 +-from devpi_process import IndexServer + from virtualenv.info import fs_supports_symlink + + import tox.run +@@ -280,9 +279,9 @@ class ToxProject: + m.setattr(sys, "argv", [sys.executable, "-m", "tox", *list(args)]) + m.setenv("VIRTUALENV_SYMLINK_APP_DATA", "1") + m.setenv("VIRTUALENV_SYMLINKS", "1") +- m.setenv("VIRTUALENV_PIP", "embed") +- m.setenv("VIRTUALENV_WHEEL", "embed") +- m.setenv("VIRTUALENV_SETUPTOOLS", "embed") ++ m.setenv("VIRTUALENV_PIP", "bundle") ++ m.setenv("VIRTUALENV_WHEEL", "bundle") ++ m.setenv("VIRTUALENV_SETUPTOOLS", "bundle") + try: + tox_run(args) + except SystemExit as exception: +@@ -475,15 +474,6 @@ def enable_pypi_server(monkeypatch: pytest.MonkeyPatch, url: str | None) -> None + monkeypatch.setenv("PIP_TIMEOUT", str(2)) + + +-@pytest.fixture(scope="session") +-def pypi_server(tmp_path_factory: pytest.TempPathFactory) -> Iterator[IndexServer]: +- # takes around 2.5s +- path = tmp_path_factory.mktemp("pypi") +- with IndexServer(path) as server: +- server.create_index("empty", "volatile=False") +- yield server +- +- + @pytest.fixture(scope="session") + def _invalid_index_fake_port() -> int: + with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as socket_handler: +diff --git a/tests/test_provision.py b/tests/test_provision.py +index 5b2b652..7657c2e 100644 +--- a/tests/test_provision.py ++++ b/tests/test_provision.py +@@ -98,22 +98,9 @@ def tox_wheels(tox_wheel: Path, tmp_path_factory: TempPathFactory) -> list[Path] + return result + + +-@pytest.fixture(scope="session") +-def pypi_index_self(pypi_server: IndexServer, tox_wheels: list[Path], demo_pkg_inline_wheel: Path) -> Index: +- with elapsed("start devpi and create index"): # takes around 1s +- self_index = pypi_server.create_index("self", "volatile=False") +- with elapsed("upload tox and its wheels to devpi"): # takes around 3.2s on build +- self_index.upload(*tox_wheels, demo_pkg_inline_wheel) +- return self_index +- +- + @pytest.fixture +-def _pypi_index_self(pypi_index_self: Index, monkeypatch: MonkeyPatch) -> None: +- pypi_index_self.use() +- monkeypatch.setenv("PIP_INDEX_URL", pypi_index_self.url) +- monkeypatch.setenv("PIP_RETRIES", str(2)) +- monkeypatch.setenv("PIP_TIMEOUT", str(5)) +- ++def _pypi_index_self(): ++ pytest.skip("needs devpi-process") + + def test_provision_requires_nok(tox_project: ToxProjectCreator) -> None: + ini = "[tox]\nrequires = pkg-does-not-exist\n setuptools==1\nskipsdist=true\n" +@@ -161,7 +148,6 @@ def test_provision_requires_ok(tox_project: ToxProjectCreator, tmp_path: Path) - + + + @pytest.mark.integration +-@pytest.mark.usefixtures("_pypi_index_self") + def test_provision_platform_check(tox_project: ToxProjectCreator) -> None: + ini = "[tox]\nrequires=demo-pkg-inline\n[testenv]\npackage=skip\n[testenv:.tox]\nplatform=wrong_platform" + proj = tox_project({"tox.ini": ini}) +-- +2.46.2 + diff --git a/SPECS/python-tox.spec b/SPECS/python-tox.spec new file mode 100644 index 0000000..05d6a8b --- /dev/null +++ b/SPECS/python-tox.spec @@ -0,0 +1,165 @@ +%bcond bootstrap 1 +# Many tests are enabled by default, unless bootstrapping +%bcond tests %{without bootstrap} +# However, some tests are disabled by default, becasue they require: +# a) tested tox to be installed and/or +# b) internet connection +# To run them, do the following: +# 1) Build --without ci_tests (the default) and optionally --without tests +# (e.g. fedpkg mockbuild --without tests) +# 2) Install the built package +# (e.g. mock install ./results_python-tox/.../tox-...rpm) +# 3) Build again --with ci_tests (and internet connection) +# (e.g. fedpkg mockbuild --no-clean-all --enable-network --with ci_tests) +# The Fedora CI tests do this. +%bcond ci_tests 0 + +# Unset -s on python shebang - ensure that extensions installed with pip +# to user locations are seen and properly loaded +# Fixes https://bugzilla.redhat.com/2057015 +%undefine _py3_shebang_s + +Name: python-tox +Version: 4.21.2 +Release: %autorelease +Summary: Virtualenv-based automation of test activities + +License: MIT +URL: https://tox.readthedocs.io/ +Source: %{pypi_source tox} + +# Remove dependency on devpi-process. +# Remove dependency on detect-test-pollution. +# Remove coverage-related dependencies. +# Adjust virtualenv environment variables to make it work with our patched virtualenv. +Patch: fix-tests.patch + +BuildArch: noarch + +BuildRequires: python3-devel +BuildRequires: pyproject-rpm-macros + +%if %{with tests} +BuildRequires: /usr/bin/gcc +BuildRequires: /usr/bin/git +BuildRequires: /usr/bin/pip +BuildRequires: /usr/bin/pytest +BuildRequires: /usr/bin/python +BuildRequires: libffi-devel +# xdist is not used upstream, but we use it to speed up the %%check +BuildRequires: python3-pytest-xdist +%if %{with ci_tests} +# The CI tests only work if the tested tox is installed :( +# This should technically be the same V-R, but the CI does not handle %%autorelease well +BuildRequires: tox = %{version} +%endif +%endif + +%global _description %{expand: +Tox as is a generic virtualenv management and test command line tool you +can use for: + + - checking your package installs correctly with different Python versions + and interpreters + - running your tests in each of the environments, configuring your test tool + of choice + - acting as a frontend to Continuous Integration servers, greatly reducing + boilerplate and merging CI and shell-based testing.} + +%description %_description + + +%package -n tox +Summary: %{summary} + +# Recommend "all the Pythons" +# Why? Tox exists to enable developers to test libraries against various Python +# versions, with just "dnf install tox" and a config file. +# See: https://developer.fedoraproject.org/tech/languages/python/python-installation.html#using-virtualenv +# Tox itself runs on the system python3 (i.e. %%{python3_version}, +# however it launches other Python versions as subprocesses. +# It recommends all Python versions it supports. (This is an exception to +# the rule that Fedora packages may not require the alternative interpreters.) +Recommends: python3.8 +Recommends: python3.9 +Recommends: python3.10 +Recommends: pypy3-devel +Recommends: python3-devel +# Instead of adding new Pythons here, add `Supplements: tox` to them, see: +# https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/NVVUXSVSPFQOWIGBE2JNI67HEO7R63ZQ/ + +%py_provides python3-tox + +%description -n tox %_description + + +%prep +%autosetup -p1 -n tox-%{version} + +# Upstream updates dependencies too aggressively +# see https://github.com/tox-dev/tox/pull/2843#discussion_r1065028356 +sed -ri -e 's/"(packaging|filelock|platformdirs|psutil|pyproject-api|pytest|pytest-mock|pytest-xdist|wheel|pluggy|distlib|cachetools|build\[virtualenv\]|setuptools|flaky)>=.*/"\1",/g' \ + -e 's/"(time-machine)>=[^;"]+/"\1/' \ + -e 's/"(virtualenv)>=.*/"\1>=20",/g' \ + -e 's/"(hatchling)>=.*/"\1>=1.13",/g' \ + pyproject.toml + +%generate_buildrequires +export SETUPTOOLS_SCM_PRETEND_VERSION="%{version}" +%pyproject_buildrequires -r %{?with_tests:-x testing} + + +%build +export SETUPTOOLS_SCM_PRETEND_VERSION="%{version}" +%pyproject_wheel + + +%install +%pyproject_install +%pyproject_save_files tox + + +%if %{with tests} +%check +# Skipped tests use internal virtualenv functionality to +# download wheels which does not work with "bundled" version of wheel in +# the Fedora's virtualenv patch. +k="${k-}${k+ and }not test_virtualenv_flipped_settings" +k="${k-}${k+ and }not test_virtualenv_env_ignored_if_set" +k="${k-}${k+ and }not test_virtualenv_env_used_if_not_set" + +# https://github.com/tox-dev/tox/issues/3290 +%if v"0%{?python3_version}" >= v"3.13" +k="${k-}${k+ and }not test_str_convert_ok_py39" +%endif + +# https://github.com/tox-dev/tox/commit/698f1dd663 +# Until we have setuptools 70.1+ we skip those +k="${k-}${k+ and }not test_result_json_sequential" +k="${k-}${k+ and }not test_setuptools_package" +k="${k-}${k+ and }not test_skip_develop_mode" +k="${k-}${k+ and }not test_tox_install_pkg_sdist" + +# The following tests either need internet connection or installed tox +# so we only run them on the CI. +%if %{without ci_tests} +k="${k-}${k+ and }not test_virtualenv_flipped_settings" +k="${k-}${k+ and }not test_virtualenv_env_ignored_if_set" +k="${k-}${k+ and }not test_virtualenv_env_used_if_not_set" +k="${k-}${k+ and }not test_build_wheel_external" +k="${k-}${k+ and }not keyboard_interrupt" +k="${k-}${k+ and }not test_call_as_module" +k="${k-}${k+ and }not test_call_as_exe" +k="${k-}${k+ and }not test_run_installpkg_targz" +%endif + +%pytest -v -n auto -k "${k-}" --run-integration +%endif + + +%files -n tox -f %{pyproject_files} +%{_bindir}/tox + + +%changelog +%autochangelog