From 47d30b0d0aa42494602bd1f9aefae761c2043a11 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 19:26:38 -0500 Subject: [PATCH 01/13] initial attempt at removing distutils --- Makefile | 2 + .../runners/action_chain_runner/dist_utils.py | 39 ------------------- .../runners/announcement_runner/dist_utils.py | 39 ------------------- contrib/runners/http_runner/dist_utils.py | 39 ------------------- contrib/runners/inquirer_runner/dist_utils.py | 39 ------------------- contrib/runners/local_runner/dist_utils.py | 39 ------------------- contrib/runners/noop_runner/dist_utils.py | 39 ------------------- contrib/runners/orquesta_runner/dist_utils.py | 39 ------------------- contrib/runners/python_runner/dist_utils.py | 39 ------------------- .../python_runner/python_action_wrapper.py | 4 +- .../test_python_action_process_wrapper.py | 4 +- contrib/runners/remote_runner/dist_utils.py | 39 ------------------- contrib/runners/winrm_runner/dist_utils.py | 39 ------------------- scripts/dist_utils.py | 39 ------------------- scripts/dist_utils_old.py | 17 -------- scripts/fixate-requirements.py | 4 +- st2actions/dist_utils.py | 39 ------------------- st2api/dist_utils.py | 39 ------------------- st2auth/dist_utils.py | 39 ------------------- st2client/dist_utils.py | 39 ------------------- st2client/setup.py | 3 -- st2common/dist_utils.py | 39 ------------------- st2common/st2common/util/pack_management.py | 4 +- st2common/st2common/util/sandboxing.py | 4 +- st2common/st2common/util/virtualenvs.py | 4 +- st2common/tests/unit/test_dist_utils.py | 35 ----------------- st2reactor/dist_utils.py | 39 ------------------- st2stream/dist_utils.py | 39 ------------------- st2tests/dist_utils.py | 39 ------------------- 29 files changed, 14 insertions(+), 808 deletions(-) diff --git a/Makefile b/Makefile index 7cdf9c60fc..34458d0377 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,7 @@ REQUIREMENTS := test-requirements.txt requirements.txt PIP_VERSION ?= 20.3.3 SETUPTOOLS_VERSION ?= 51.3.3 PIP_OPTIONS := $(ST2_PIP_OPTIONS) +PACKAGING_VERSION ?= 23.1 ifndef PYLINT_CONCURRENCY PYLINT_CONCURRENCY := 1 @@ -662,6 +663,7 @@ distclean: clean .PHONY: .requirements .requirements: virtualenv $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)" + $(VIRTUALENV_DIR)/bin/pip install --upgrade "PACKAGING_VERSION==$(PACKAGING_VERSION)" # Print out pip version $(VIRTUALENV_DIR)/bin/pip --version # Generate all requirements to support current CI pipeline. diff --git a/contrib/runners/action_chain_runner/dist_utils.py b/contrib/runners/action_chain_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/action_chain_runner/dist_utils.py +++ b/contrib/runners/action_chain_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/announcement_runner/dist_utils.py b/contrib/runners/announcement_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/announcement_runner/dist_utils.py +++ b/contrib/runners/announcement_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/http_runner/dist_utils.py b/contrib/runners/http_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/http_runner/dist_utils.py +++ b/contrib/runners/http_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/inquirer_runner/dist_utils.py b/contrib/runners/inquirer_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/inquirer_runner/dist_utils.py +++ b/contrib/runners/inquirer_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/local_runner/dist_utils.py b/contrib/runners/local_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/local_runner/dist_utils.py +++ b/contrib/runners/local_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/noop_runner/dist_utils.py b/contrib/runners/noop_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/noop_runner/dist_utils.py +++ b/contrib/runners/noop_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/orquesta_runner/dist_utils.py b/contrib/runners/orquesta_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/orquesta_runner/dist_utils.py +++ b/contrib/runners/orquesta_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/python_runner/dist_utils.py b/contrib/runners/python_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/python_runner/dist_utils.py +++ b/contrib/runners/python_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/python_runner/python_runner/python_action_wrapper.py b/contrib/runners/python_runner/python_runner/python_action_wrapper.py index 795b0114a8..50dddad2ff 100644 --- a/contrib/runners/python_runner/python_runner/python_action_wrapper.py +++ b/contrib/runners/python_runner/python_runner/python_action_wrapper.py @@ -26,7 +26,7 @@ import select import traceback -import distutils.sysconfig +import sysconfig # NOTE: We intentionally use orjson directly here instead of json_encode - orjson.dumps relies # on config option which we don't parse for the action wrapper since it speeds things down - action @@ -49,7 +49,7 @@ # This puts priority on loading virtualenv library in the pack's action. This is necessary # for the situation that both st2 and pack require to load same name libraries with different # version. Without this statement, action may call library method with unexpected dependencies. - sys.path.insert(0, distutils.sysconfig.get_python_lib()) + sys.path.insert(0, sysconfig.get_path('platlib')) import sys import argparse diff --git a/contrib/runners/python_runner/tests/integration/test_python_action_process_wrapper.py b/contrib/runners/python_runner/tests/integration/test_python_action_process_wrapper.py index c97a380fb2..da939f4aae 100644 --- a/contrib/runners/python_runner/tests/integration/test_python_action_process_wrapper.py +++ b/contrib/runners/python_runner/tests/integration/test_python_action_process_wrapper.py @@ -37,7 +37,7 @@ import json import unittest2 -from distutils.spawn import find_executable +from shutil import which as shutil_which from st2common.util.shell import run_command from six.moves import range @@ -61,7 +61,7 @@ BASE_DIR, "../../../python_runner/python_runner/python_action_wrapper.py" ) WRAPPER_SCRIPT_PATH = os.path.abspath(WRAPPER_SCRIPT_PATH) -TIME_BINARY_PATH = find_executable("time") +TIME_BINARY_PATH = shutil_which("time") TIME_BINARY_AVAILABLE = TIME_BINARY_PATH is not None diff --git a/contrib/runners/remote_runner/dist_utils.py b/contrib/runners/remote_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/remote_runner/dist_utils.py +++ b/contrib/runners/remote_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/contrib/runners/winrm_runner/dist_utils.py b/contrib/runners/winrm_runner/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/contrib/runners/winrm_runner/dist_utils.py +++ b/contrib/runners/winrm_runner/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/scripts/dist_utils.py b/scripts/dist_utils.py index 297efe1689..9c27f683ca 100644 --- a/scripts/dist_utils.py +++ b/scripts/dist_utils.py @@ -20,8 +20,6 @@ import re import sys -from distutils.version import StrictVersion - # // NOTE: After you update this script, please run: # // # // make .sdist-requirements @@ -52,8 +50,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -61,41 +57,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/scripts/dist_utils_old.py b/scripts/dist_utils_old.py index da38f6edbf..05fdb6b92e 100644 --- a/scripts/dist_utils_old.py +++ b/scripts/dist_utils_old.py @@ -27,8 +27,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here PY3 = sys.version_info[0] == 3 @@ -62,7 +60,6 @@ sys.exit(1) __all__ = [ - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -70,20 +67,6 @@ ] -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/scripts/fixate-requirements.py b/scripts/fixate-requirements.py index a60f43b4aa..bf5f9c898b 100755 --- a/scripts/fixate-requirements.py +++ b/scripts/fixate-requirements.py @@ -34,7 +34,7 @@ import os.path import sys -from distutils.version import StrictVersion +from packaging.version import Version # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here PY2 = sys.version_info[0] == 2 @@ -116,7 +116,7 @@ def parse_args(): def check_pip_version(): - if StrictVersion(pip.__version__) < StrictVersion("6.1.0"): + if Version(pip.__version__) < Version("6.1.0"): print( "Upgrade pip, your version `{0}' " "is outdated:\n".format(pip.__version__), GET_PIP, diff --git a/st2actions/dist_utils.py b/st2actions/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2actions/dist_utils.py +++ b/st2actions/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/st2api/dist_utils.py b/st2api/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2api/dist_utils.py +++ b/st2api/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/st2auth/dist_utils.py b/st2auth/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2auth/dist_utils.py +++ b/st2auth/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/st2client/dist_utils.py b/st2client/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2client/dist_utils.py +++ b/st2client/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/st2client/setup.py b/st2client/setup.py index 2404072522..decfaf9237 100644 --- a/st2client/setup.py +++ b/st2client/setup.py @@ -18,14 +18,11 @@ from setuptools import setup, find_packages -from dist_utils import check_pip_version from dist_utils import fetch_requirements from dist_utils import apply_vagrant_workaround from st2client import __version__ -check_pip_version() - ST2_COMPONENT = "st2client" BASE_DIR = os.path.dirname(os.path.abspath(__file__)) REQUIREMENTS_FILE = os.path.join(BASE_DIR, "requirements.txt") diff --git a/st2common/dist_utils.py b/st2common/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2common/dist_utils.py +++ b/st2common/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/st2common/st2common/util/pack_management.py b/st2common/st2common/util/pack_management.py index ae3c256184..c9576f6fcc 100644 --- a/st2common/st2common/util/pack_management.py +++ b/st2common/st2common/util/pack_management.py @@ -35,7 +35,7 @@ from git.repo import Repo from gitdb.exc import BadName, BadObject from lockfile import LockFile -from distutils.spawn import find_executable +from shutil import which as shutil_which from st2common import log as logging from st2common.content import utils @@ -67,7 +67,7 @@ CURRENT_STACKSTORM_VERSION = get_stackstorm_version() CURRENT_PYTHON_VERSION = get_python_version() -SUDO_BINARY = find_executable("sudo") +SUDO_BINARY = shutil_which("sudo") def download_pack( diff --git a/st2common/st2common/util/sandboxing.py b/st2common/st2common/util/sandboxing.py index 791607471f..89c5b5f7c7 100644 --- a/st2common/st2common/util/sandboxing.py +++ b/st2common/st2common/util/sandboxing.py @@ -23,7 +23,7 @@ import fnmatch import os import sys -from distutils.sysconfig import get_python_lib +import sysconfig from oslo_config import cfg @@ -108,7 +108,7 @@ def get_sandbox_python_path(inherit_from_parent=True, inherit_parent_virtualenv= if inherit_parent_virtualenv and is_in_virtualenv(): # We are running inside virtualenv - site_packages_dir = get_python_lib() + site_packages_dir = sysconfig.get_path('platlib') sys_prefix = os.path.abspath(sys.prefix) if sys_prefix not in site_packages_dir: diff --git a/st2common/st2common/util/virtualenvs.py b/st2common/st2common/util/virtualenvs.py index 20100369b0..188733e85c 100644 --- a/st2common/st2common/util/virtualenvs.py +++ b/st2common/st2common/util/virtualenvs.py @@ -67,7 +67,7 @@ def setup_pack_virtualenv( level logger. :param no_download: Do not download and install latest version of pre-installed packages such - as pip and distutils. + as pip and setuptools. :type no_download: ``bool`` """ logger = logger or LOG @@ -170,7 +170,7 @@ def create_virtualenv( :type include_wheel : ``bool`` :param no_download: Do not download and install latest version of pre-installed packages such - as pip and distutils. + as pip and setuptools. :type no_download: ``bool`` """ diff --git a/st2common/tests/unit/test_dist_utils.py b/st2common/tests/unit/test_dist_utils.py index 1b01d4ff48..3faaf03bec 100644 --- a/st2common/tests/unit/test_dist_utils.py +++ b/st2common/tests/unit/test_dist_utils.py @@ -26,8 +26,6 @@ # Add scripts/ which contain main dist_utils.py to PYTHONPATH sys.path.insert(0, SCRIPTS_PATH) -from dist_utils import check_pip_is_installed -from dist_utils import check_pip_version from dist_utils import fetch_requirements from dist_utils import apply_vagrant_workaround from dist_utils import get_version_string @@ -51,39 +49,6 @@ def setUp(self): def tearDown(self): super(DistUtilsTestCase, self).tearDown() - def test_check_pip_is_installed_success(self): - self.assertTrue(check_pip_is_installed()) - - @mock.patch("sys.exit") - def test_check_pip_is_installed_failure(self, mock_sys_exit): - if six.PY3: - module_name = "builtins.__import__" - else: - module_name = "__builtin__.__import__" - - with mock.patch(module_name) as mock_import: - mock_import.side_effect = ImportError("not found") - - self.assertEqual(mock_sys_exit.call_count, 0) - check_pip_is_installed() - self.assertEqual(mock_sys_exit.call_count, 1) - self.assertEqual(mock_sys_exit.call_args_list[0][0], (1,)) - - def test_check_pip_version_success(self): - self.assertTrue(check_pip_version()) - - @mock.patch("sys.exit") - def test_check_pip_version_failure(self, mock_sys_exit): - - mock_pip = mock.Mock() - mock_pip.__version__ = "0.0.0" - sys.modules["pip"] = mock_pip - - self.assertEqual(mock_sys_exit.call_count, 0) - check_pip_version() - self.assertEqual(mock_sys_exit.call_count, 1) - self.assertEqual(mock_sys_exit.call_args_list[0][0], (1,)) - def test_get_version_string(self): version = get_version_string(VERSION_FILE_PATH) self.assertEqual(version, "1.2.3") diff --git a/st2reactor/dist_utils.py b/st2reactor/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2reactor/dist_utils.py +++ b/st2reactor/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/st2stream/dist_utils.py b/st2stream/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2stream/dist_utils.py +++ b/st2stream/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. diff --git a/st2tests/dist_utils.py b/st2tests/dist_utils.py index a4e9862d2b..fa752580a2 100644 --- a/st2tests/dist_utils.py +++ b/st2tests/dist_utils.py @@ -24,8 +24,6 @@ import re import sys -from distutils.version import StrictVersion - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here # # TODO: Why can't this script rely on 3rd party dependencies? Is it because it has to import @@ -48,8 +46,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" __all__ = [ - "check_pip_is_installed", - "check_pip_version", "fetch_requirements", "apply_vagrant_workaround", "get_version_string", @@ -57,41 +53,6 @@ ] -def check_pip_is_installed(): - """ - Ensure that pip is installed. - """ - try: - import pip # NOQA - except ImportError as e: - print("Failed to import pip: %s" % (text_type(e))) - print("") - print("Download pip:\n%s" % (GET_PIP)) - sys.exit(1) - - return True - - -def check_pip_version(min_version="6.0.0"): - """ - Ensure that a minimum supported version of pip is installed. - """ - check_pip_is_installed() - - import pip - - if StrictVersion(pip.__version__) < StrictVersion(min_version): - print( - "Upgrade pip, your version '{0}' " - "is outdated. Minimum required version is '{1}':\n{2}".format( - pip.__version__, min_version, GET_PIP - ) - ) - sys.exit(1) - - return True - - def fetch_requirements(requirements_file_path): """ Return a list of requirements and links by parsing the provided requirements file. From 7f9d7bda74494d56cf086b2eb23c78648b977163 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 20:04:21 -0500 Subject: [PATCH 02/13] updating changelog --- .gitignore | 2 ++ CHANGELOG.rst | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 555d276e69..090159801f 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,5 @@ benchmark_histograms/ [._]sw[a-px] [._]*.sw[a-p]x [._]sw[a-p]x + +**/build/lib/** \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 96941c1401..7ca9abb237 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,9 @@ in development Added ~~~~~ +* Remove `distutils` dependencies across the project. #5992 + Contributed by @AndroxxTraxxon + * Move `git clone` to `user_home/.st2packs` #5845 * Error on `st2ctl status` when running in Kubernetes. #5851 From 32d492f4cb277308e069affd5627c9e50be2d4c4 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 20:12:14 -0500 Subject: [PATCH 03/13] fixing PACKAGING typo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 34458d0377..45ba71a2d5 100644 --- a/Makefile +++ b/Makefile @@ -663,7 +663,7 @@ distclean: clean .PHONY: .requirements .requirements: virtualenv $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)" - $(VIRTUALENV_DIR)/bin/pip install --upgrade "PACKAGING_VERSION==$(PACKAGING_VERSION)" + $(VIRTUALENV_DIR)/bin/pip install --upgrade "packaging==$(PACKAGING_VERSION)" # Print out pip version $(VIRTUALENV_DIR)/bin/pip --version # Generate all requirements to support current CI pipeline. From dd160fb2dd584453d0feb966da61d2afa6776ad7 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 20:19:34 -0500 Subject: [PATCH 04/13] removing pip version check altogether for python 3.6 compatibility --- Makefile | 2 -- scripts/fixate-requirements.py | 11 ----------- 2 files changed, 13 deletions(-) diff --git a/Makefile b/Makefile index 45ba71a2d5..7cdf9c60fc 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,6 @@ REQUIREMENTS := test-requirements.txt requirements.txt PIP_VERSION ?= 20.3.3 SETUPTOOLS_VERSION ?= 51.3.3 PIP_OPTIONS := $(ST2_PIP_OPTIONS) -PACKAGING_VERSION ?= 23.1 ifndef PYLINT_CONCURRENCY PYLINT_CONCURRENCY := 1 @@ -663,7 +662,6 @@ distclean: clean .PHONY: .requirements .requirements: virtualenv $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)" - $(VIRTUALENV_DIR)/bin/pip install --upgrade "packaging==$(PACKAGING_VERSION)" # Print out pip version $(VIRTUALENV_DIR)/bin/pip --version # Generate all requirements to support current CI pipeline. diff --git a/scripts/fixate-requirements.py b/scripts/fixate-requirements.py index bf5f9c898b..b330a74bb0 100755 --- a/scripts/fixate-requirements.py +++ b/scripts/fixate-requirements.py @@ -34,8 +34,6 @@ import os.path import sys -from packaging.version import Version - # NOTE: This script can't rely on any 3rd party dependency so we need to use this code here PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 @@ -115,15 +113,6 @@ def parse_args(): return vars(parser.parse_args()) -def check_pip_version(): - if Version(pip.__version__) < Version("6.1.0"): - print( - "Upgrade pip, your version `{0}' " "is outdated:\n".format(pip.__version__), - GET_PIP, - ) - sys.exit(1) - - def load_requirements(file_path): return tuple((r for r in parse_requirements(file_path, session=False))) From bf2ad68d9842bf1aba8ff61b3cc991e86b6f88a4 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 20:27:38 -0500 Subject: [PATCH 05/13] trigger another validation run --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7cdf9c60fc..be309e4abe 100644 --- a/Makefile +++ b/Makefile @@ -661,7 +661,7 @@ distclean: clean .PHONY: .requirements .requirements: virtualenv - $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)" + $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)" # Print out pip version $(VIRTUALENV_DIR)/bin/pip --version # Generate all requirements to support current CI pipeline. From 947a8751f58b56d9d1c16d5e9b100fdef504e65b Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 20:30:33 -0500 Subject: [PATCH 06/13] actually removing the pip version check --- scripts/fixate-requirements.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/fixate-requirements.py b/scripts/fixate-requirements.py index b330a74bb0..445bc6a5ec 100755 --- a/scripts/fixate-requirements.py +++ b/scripts/fixate-requirements.py @@ -271,7 +271,6 @@ def write_requirements( if __name__ == "__main__": - check_pip_version() args = parse_args() if args["skip"]: From a76313cac0db785b0af22cb380f1bb1669bdab02 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 20:47:01 -0500 Subject: [PATCH 07/13] shaping sandbox.py for minimal test changes. --- st2common/st2common/util/sandboxing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/st2common/st2common/util/sandboxing.py b/st2common/st2common/util/sandboxing.py index 89c5b5f7c7..a089ee33fe 100644 --- a/st2common/st2common/util/sandboxing.py +++ b/st2common/st2common/util/sandboxing.py @@ -23,7 +23,7 @@ import fnmatch import os import sys -import sysconfig +from sysconfig import get_path from oslo_config import cfg @@ -31,6 +31,10 @@ from st2common.constants.pack import SYSTEM_PACK_NAMES from st2common.content.utils import get_pack_base_path +def get_python_lib(): + """Replacement for distutil.sysconfig.get_python_lib, returns a string with the python platform lib path (to site-packages)""" + return get_path('platlib') + __all__ = [ "get_sandbox_python_binary_path", "get_sandbox_python_path", @@ -108,7 +112,7 @@ def get_sandbox_python_path(inherit_from_parent=True, inherit_parent_virtualenv= if inherit_parent_virtualenv and is_in_virtualenv(): # We are running inside virtualenv - site_packages_dir = sysconfig.get_path('platlib') + site_packages_dir = get_python_lib() sys_prefix = os.path.abspath(sys.prefix) if sys_prefix not in site_packages_dir: From d888893f23ed9f92bc2d9a1f6440613b084bd4d2 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Mon, 19 Jun 2023 20:53:03 -0500 Subject: [PATCH 08/13] found the formatter --- .../python_runner/python_runner/python_action_wrapper.py | 2 +- st2common/st2common/util/sandboxing.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/runners/python_runner/python_runner/python_action_wrapper.py b/contrib/runners/python_runner/python_runner/python_action_wrapper.py index 50dddad2ff..0453f7019b 100644 --- a/contrib/runners/python_runner/python_runner/python_action_wrapper.py +++ b/contrib/runners/python_runner/python_runner/python_action_wrapper.py @@ -49,7 +49,7 @@ # This puts priority on loading virtualenv library in the pack's action. This is necessary # for the situation that both st2 and pack require to load same name libraries with different # version. Without this statement, action may call library method with unexpected dependencies. - sys.path.insert(0, sysconfig.get_path('platlib')) + sys.path.insert(0, sysconfig.get_path("platlib")) import sys import argparse diff --git a/st2common/st2common/util/sandboxing.py b/st2common/st2common/util/sandboxing.py index a089ee33fe..8640985362 100644 --- a/st2common/st2common/util/sandboxing.py +++ b/st2common/st2common/util/sandboxing.py @@ -23,7 +23,7 @@ import fnmatch import os import sys -from sysconfig import get_path +from sysconfig import get_path from oslo_config import cfg @@ -31,9 +31,11 @@ from st2common.constants.pack import SYSTEM_PACK_NAMES from st2common.content.utils import get_pack_base_path + def get_python_lib(): """Replacement for distutil.sysconfig.get_python_lib, returns a string with the python platform lib path (to site-packages)""" - return get_path('platlib') + return get_path("platlib") + __all__ = [ "get_sandbox_python_binary_path", From a4545f60d77cc6c1e2f106ed817315fadb72d23c Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Tue, 12 Sep 2023 21:52:02 -0500 Subject: [PATCH 09/13] Update Makefile: revert addition of accidental trailing space --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index be309e4abe..7cdf9c60fc 100644 --- a/Makefile +++ b/Makefile @@ -661,7 +661,7 @@ distclean: clean .PHONY: .requirements .requirements: virtualenv - $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)" + $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==$(PIP_VERSION)" # Print out pip version $(VIRTUALENV_DIR)/bin/pip --version # Generate all requirements to support current CI pipeline. From 9fd3454f04a34c9464e1f36da3abaea3167ac5e2 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Tue, 12 Sep 2023 21:58:21 -0500 Subject: [PATCH 10/13] Update CHANGELOG.rst to meet linting requirements --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 00b9d08331..fa1fee0eb4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,7 +14,7 @@ Added ~~~~~ * Remove `distutils` dependencies across the project. #5992 Contributed by @AndroxxTraxxon - + * Move `git clone` to `user_home/.st2packs` #5845 * Error on `st2ctl status` when running in Kubernetes. #5851 From c46298c338d86c11753593cf858fd8911d450686 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Tue, 12 Sep 2023 22:29:35 -0500 Subject: [PATCH 11/13] Update test_dist_utils.py: remove unused `six` import --- st2common/tests/unit/test_dist_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/st2common/tests/unit/test_dist_utils.py b/st2common/tests/unit/test_dist_utils.py index 3faaf03bec..e19df80604 100644 --- a/st2common/tests/unit/test_dist_utils.py +++ b/st2common/tests/unit/test_dist_utils.py @@ -16,7 +16,6 @@ import os import sys -import six import mock import unittest2 From 602d71ca4df7101c1cdc71dfad4c802360a1322f Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Tue, 12 Sep 2023 22:43:04 -0500 Subject: [PATCH 12/13] removing unused imports: pip --- scripts/dist_utils_old.py | 1 - scripts/fixate-requirements.py | 1 - 2 files changed, 2 deletions(-) diff --git a/scripts/dist_utils_old.py b/scripts/dist_utils_old.py index 05fdb6b92e..739970900c 100644 --- a/scripts/dist_utils_old.py +++ b/scripts/dist_utils_old.py @@ -38,7 +38,6 @@ GET_PIP = "curl https://bootstrap.pypa.io/get-pip.py | python" try: - import pip from pip import __version__ as pip_version except ImportError as e: print("Failed to import pip: %s" % (text_type(e))) diff --git a/scripts/fixate-requirements.py b/scripts/fixate-requirements.py index 445bc6a5ec..e7b8377297 100755 --- a/scripts/fixate-requirements.py +++ b/scripts/fixate-requirements.py @@ -47,7 +47,6 @@ GET_PIP = " curl https://bootstrap.pypa.io/get-pip.py | python" try: - import pip from pip import __version__ as pip_version except ImportError as e: print("Failed to import pip: %s" % (text_type(e))) From c41021eda018a44da7edbf61bb919840eb5da8a3 Mon Sep 17 00:00:00 2001 From: David Culbreth Date: Fri, 15 Sep 2023 11:00:40 -0500 Subject: [PATCH 13/13] Update CHANGELOG.rst --- CHANGELOG.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3694ff2347..59f4ab2406 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,8 +15,6 @@ Fixed Added ~~~~~ -* Remove `distutils` dependencies across the project. #5992 - Contributed by @AndroxxTraxxon * Move `git clone` to `user_home/.st2packs` #5845 @@ -40,6 +38,11 @@ Added * Expose environment variable ST2_ACTION_DEBUG to all StackStorm actions. Contributed by @maxfactor1 +Changed +~~~~~~~ +* Remove `distutils` dependencies across the project. #5992 + Contributed by @AndroxxTraxxon + 3.8.0 - November 18, 2022 -------------------------