diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0ce7f48010..b3720a22e0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,7 +16,7 @@ Added to pants' use of PEX lockfiles. This is not a user-facing addition. #5778 #5789 #5817 #5795 #5830 #5833 #5834 #5841 #5840 #5838 #5842 #5837 #5849 #5850 #5846 #5853 #5848 #5847 #5858 #5857 #5860 #5868 #5871 #5864 #5874 #5884 #5893 #5891 - #5890 #5898 #5901 #5906 #5899 #5907 #5909 #5922 #5926 #5927 #5925 #5928 #5929 + #5890 #5898 #5901 #5906 #5899 #5907 #5909 #5922 #5926 #5927 #5925 #5928 #5929 #5930 Contributed by @cognifloyd * Added a joint index to solve the problem of slow mongo queries for scheduled executions. #5805 diff --git a/contrib/runners/python_runner/tests/unit/test_pythonrunner.py b/contrib/runners/python_runner/tests/unit/test_pythonrunner.py index a9699f1df9..27a6806e9a 100644 --- a/contrib/runners/python_runner/tests/unit/test_pythonrunner.py +++ b/contrib/runners/python_runner/tests/unit/test_pythonrunner.py @@ -35,6 +35,7 @@ ) from st2common.constants.action import LIVEACTION_STATUS_TIMED_OUT from st2common.constants.action import MAX_PARAM_LENGTH +from st2common.constants.pack import COMMON_LIB_DIR from st2common.constants.pack import SYSTEM_PACK_NAME from st2common.persistence.execution import ActionExecutionOutput from python_runner.python_action_wrapper import PythonActionWrapper @@ -951,7 +952,7 @@ def test_content_version_contains_common_libs_config_enabled( _, call_kwargs = mock_popen.call_args actual_env = call_kwargs["env"] - pack_common_lib_path = os.path.join(runner.git_worktree_path, "lib") + pack_common_lib_path = os.path.join(runner.git_worktree_path, COMMON_LIB_DIR) self.assertIn("PYTHONPATH", actual_env) self.assertIn(pack_common_lib_path, actual_env["PYTHONPATH"]) diff --git a/pants.toml b/pants.toml index b8dc5656a7..2c40fd7ca1 100644 --- a/pants.toml +++ b/pants.toml @@ -85,8 +85,11 @@ root_patterns = [ "/contrib/packs", "/st2tests/testpacks/checks", "/st2tests/testpacks/errorcheck", - # odd import in examples.isprime - "/contrib/examples/lib", + # pack common lib directories that ST2 adds to the PATH for actions/sensors + "/contrib/*/lib", + "/contrib/*/actions/lib", + # other special-cased pack directories + "/contrib/examples/actions/ubuntu_pkg_info", # python script runs via shell expecting cwd in PYTHONPATH # lint plugins "/pylint_plugins", # pants plugins diff --git a/st2common/st2common/constants/pack.py b/st2common/st2common/constants/pack.py index c0a68abc07..2f3d14bf50 100644 --- a/st2common/st2common/constants/pack.py +++ b/st2common/st2common/constants/pack.py @@ -14,6 +14,7 @@ # limitations under the License. __all__ = [ + "COMMON_LIB_DIR", "PACKS_PACK_NAME", "PACK_REF_WHITELIST_REGEX", "RESERVED_PACK_LIST", @@ -32,6 +33,8 @@ "CONFIG_SCHEMA_FILE_NAME", ] +COMMON_LIB_DIR = "lib" + # Prefix for render context w/ config PACK_CONFIG_CONTEXT_KV_PREFIX = "config_context" diff --git a/st2common/st2common/util/pack.py b/st2common/st2common/util/pack.py index 0c13ccf347..a3816fee96 100644 --- a/st2common/st2common/util/pack.py +++ b/st2common/st2common/util/pack.py @@ -22,6 +22,7 @@ from collections.abc import Iterable from st2common.util import schema as util_schema +from st2common.constants.pack import COMMON_LIB_DIR from st2common.constants.pack import MANIFEST_FILE_NAME from st2common.constants.pack import PACK_REF_WHITELIST_REGEX from st2common.constants.pack import RESERVED_PACK_LIST @@ -215,7 +216,7 @@ def get_pack_common_libs_path_for_pack_db(pack_db): if not pack_dir: return None - libs_path = os.path.join(pack_dir, "lib") + libs_path = os.path.join(pack_dir, COMMON_LIB_DIR) return libs_path diff --git a/st2common/st2common/util/sandboxing.py b/st2common/st2common/util/sandboxing.py index 0f948bc666..791607471f 100644 --- a/st2common/st2common/util/sandboxing.py +++ b/st2common/st2common/util/sandboxing.py @@ -27,6 +27,7 @@ from oslo_config import cfg +from st2common.constants.action import LIBS_DIR as ACTION_LIBS_DIR from st2common.constants.pack import SYSTEM_PACK_NAMES from st2common.content.utils import get_pack_base_path @@ -149,7 +150,9 @@ def get_sandbox_python_path_for_python_action( ] # Add the pack's lib directory (lib/python3.x) in front of the PYTHONPATH. - pack_actions_lib_paths = os.path.join(pack_base_path, "actions", "lib") + pack_actions_lib_paths = os.path.join( + pack_base_path, "actions", ACTION_LIBS_DIR + ) pack_virtualenv_lib_path = os.path.join(virtualenv_path, "lib") pack_venv_lib_directory = os.path.join( pack_virtualenv_lib_path, virtualenv_directories[0]