From 4cb5c4c178a251b74206543cc4c4da4b4dda5329 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 22 Sep 2021 12:57:30 +0100 Subject: [PATCH] Match used pip and setuptools constraints --- .pre-commit-config.yaml | 6 ++++++ noxfile.py | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e3447ffde1..5cbe5728f10 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1426,6 +1426,9 @@ repos: - -e - lint-salt-pre-commit - -- + additional_dependencies: + - setuptools<58.0 + - pip>=20.2.4,<21.2 - repo: https://github.com/saltstack/mirrors-nox rev: v2020.8.22 @@ -1438,4 +1441,7 @@ repos: - -e - lint-tests-pre-commit - -- + additional_dependencies: + - setuptools<58.0 + - pip>=20.2.4,<21.2 # <---- Pre-Commit ------------------------------------------------------------------------------------------------- diff --git a/noxfile.py b/noxfile.py index 1262389fa08..a23e762205b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -276,7 +276,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): +def _upgrade_pip_setuptools_and_wheel(session, upgrade=True): if SKIP_REQUIREMENTS_INSTALL: session.log( "Skipping Python Requirements because SKIP_REQUIREMENTS_INSTALL was found in the environ" @@ -289,11 +289,16 @@ def _upgrade_pip_setuptools_and_wheel(session): "pip", "install", "--progress-bar=off", - "-U", - "pip>=20.2.4,<21.2", - "setuptools!=50.*,!=51.*,!=52.*", - "wheel", ] + if upgrade: + install_command.append("-U") + install_command.extend( + [ + "pip>=20.2.4,<21.2", + "setuptools!=50.*,!=51.*,!=52.*", + "wheel", + ] + ) session.run(*install_command, silent=PIP_INSTALL_SILENT) return True @@ -849,8 +854,10 @@ class Tee: return self._first.fileno() -def _lint(session, rcfile, flags, paths, tee_output=True): - if _upgrade_pip_setuptools_and_wheel(session): +def _lint( + session, rcfile, flags, paths, tee_output=True, upgrade_setuptools_and_pip=True +): + if _upgrade_pip_setuptools_and_wheel(session, upgrade=upgrade_setuptools_and_pip): requirements_file = os.path.join( "requirements", "static", "ci", _get_pydir(session), "lint.txt" ) @@ -924,7 +931,14 @@ def _lint_pre_commit(session, rcfile, flags, paths): interpreter=session._runner.func.python, reuse_existing=True, ) - _lint(session, rcfile, flags, paths, tee_output=False) + _lint( + session, + rcfile, + flags, + paths, + tee_output=False, + upgrade_setuptools_and_pip=False, + ) @nox.session(python="3")