From 4dd5d53f1f3d75f5af2a4f9280c335a85c549c8c Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 13 Jan 2023 16:37:09 +0000 Subject: [PATCH] Non onedir builds might be able to user the newer pip and setuptools requirements Signed-off-by: Pedro Algarvio --- noxfile.py | 15 ++++++++++----- tests/support/helpers.py | 21 +++++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/noxfile.py b/noxfile.py index 9d230e2c821..1d94c59a557 100644 --- a/noxfile.py +++ b/noxfile.py @@ -280,7 +280,7 @@ def _get_pip_requirements_file(session, transport, crypto=None, requirements_typ session.error("Could not find a linux requirements file for {}".format(pydir)) -def _upgrade_pip_setuptools_and_wheel(session, upgrade=True): +def _upgrade_pip_setuptools_and_wheel(session, upgrade=True, onedir=False): if SKIP_REQUIREMENTS_INSTALL: session.log( "Skipping Python Requirements because SKIP_REQUIREMENTS_INSTALL was found in the environ" @@ -296,14 +296,19 @@ def _upgrade_pip_setuptools_and_wheel(session, upgrade=True): ] if upgrade: install_command.append("-U") - install_command.extend( - [ + if onedir: + requirements = [ "pip>=22.3.1,<23.0", # https://github.com/pypa/setuptools/commit/137ab9d684075f772c322f455b0dd1f992ddcd8f "setuptools>=65.6.3,<66", "wheel", ] - ) + else: + requirements = [ + "pip>=20.2.4,<21.2", + "setuptools!=50.*,!=51.*,!=52.*,<59", + ] + install_command.extend(requirements) session_run_always(session, *install_command, silent=PIP_INSTALL_SILENT) return True @@ -318,7 +323,7 @@ def _install_requirements( if onedir and IS_LINUX: session_run_always(session, "python3", "-m", "relenv", "toolchain", "fetch") - if not _upgrade_pip_setuptools_and_wheel(session): + if not _upgrade_pip_setuptools_and_wheel(session, onedir=onedir): return False # Install requirements diff --git a/tests/support/helpers.py b/tests/support/helpers.py index 833c0a5b1ae..3556e08853b 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -1601,17 +1601,26 @@ class VirtualEnv: venv_dir = attr.ib(converter=_cast_to_pathlib_path) env = attr.ib(default=None) system_site_packages = attr.ib(default=False) - pip_requirement = attr.ib(default="pip>=22.3.1,<23.0", repr=False) - setuptools_requirement = attr.ib( - # https://github.com/pypa/setuptools/commit/137ab9d684075f772c322f455b0dd1f992ddcd8f - default="setuptools>=65.6.3,<66", - repr=False, - ) + pip_requirement = attr.ib(repr=False) + setuptools_requirement = attr.ib(repr=False) # TBD build_requirement = attr.ib(default="build!=0.6.*", repr=False) # add build when implement pyproject.toml environ = attr.ib(init=False, repr=False) venv_python = attr.ib(init=False, repr=False) venv_bin_dir = attr.ib(init=False, repr=False) + @pip_requirement.default + def _default_pip_requiremnt(self): + if os.environ.get("ONEDIR_TESTRUN", "0") == "1": + return "pip>=22.3.1,<23.0" + return "pip>=20.2.4,<21.2" + + @setuptools_requirement.default + def _default_setuptools_requirement(self): + if os.environ.get("ONEDIR_TESTRUN", "0") == "1": + # https://github.com/pypa/setuptools/commit/137ab9d684075f772c322f455b0dd1f992ddcd8f + return "setuptools>=65.6.3,<66" + return "setuptools!=50.*,!=51.*,!=52.*,<59" + @venv_dir.default def _default_venv_dir(self): return pathlib.Path(tempfile.mkdtemp(dir=RUNTIME_VARS.TMP))