From e564418b7f135abdd1ff6d80150105760b6bdca7 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 18 Jun 2022 21:06:44 -0500 Subject: [PATCH 1/5] add python_distribution for building st2 component wheel/sdist with pants --- st2actions/BUILD | 3 +++ st2api/BUILD | 3 +++ st2auth/BUILD | 3 +++ st2client/BUILD | 3 +++ st2common/BUILD | 3 +++ st2reactor/BUILD | 3 +++ st2stream/BUILD | 3 +++ st2tests/BUILD | 3 +++ 8 files changed, 24 insertions(+) create mode 100644 st2actions/BUILD create mode 100644 st2api/BUILD create mode 100644 st2auth/BUILD create mode 100644 st2client/BUILD create mode 100644 st2common/BUILD create mode 100644 st2reactor/BUILD create mode 100644 st2stream/BUILD create mode 100644 st2tests/BUILD diff --git a/st2actions/BUILD b/st2actions/BUILD new file mode 100644 index 0000000000..a5a2baa6c1 --- /dev/null +++ b/st2actions/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2actions", +) diff --git a/st2api/BUILD b/st2api/BUILD new file mode 100644 index 0000000000..5bd8df5173 --- /dev/null +++ b/st2api/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2api", +) diff --git a/st2auth/BUILD b/st2auth/BUILD new file mode 100644 index 0000000000..8e83f32b3a --- /dev/null +++ b/st2auth/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2auth", +) diff --git a/st2client/BUILD b/st2client/BUILD new file mode 100644 index 0000000000..ec21bc1f36 --- /dev/null +++ b/st2client/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2client", +) diff --git a/st2common/BUILD b/st2common/BUILD new file mode 100644 index 0000000000..d194a86c5b --- /dev/null +++ b/st2common/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2common", +) diff --git a/st2reactor/BUILD b/st2reactor/BUILD new file mode 100644 index 0000000000..29fd451fbf --- /dev/null +++ b/st2reactor/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2reactor", +) diff --git a/st2stream/BUILD b/st2stream/BUILD new file mode 100644 index 0000000000..1ec028de81 --- /dev/null +++ b/st2stream/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2stream", +) diff --git a/st2tests/BUILD b/st2tests/BUILD new file mode 100644 index 0000000000..a6188b03a9 --- /dev/null +++ b/st2tests/BUILD @@ -0,0 +1,3 @@ +st2_component_python_distribution( + component_name="st2tests", +) From 796a08c6dc7b9ebddd4fb565032033c5ad741bb1 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Mon, 20 Jun 2022 23:38:24 -0500 Subject: [PATCH 2/5] Add scripts to BUILD python_distribution for st2 components --- st2actions/BUILD | 7 +++++++ st2api/BUILD | 1 + st2auth/BUILD | 1 + st2common/BUILD | 26 ++++++++++++++++++++++++++ st2reactor/BUILD | 8 ++++++++ st2stream/BUILD | 1 + 6 files changed, 44 insertions(+) diff --git a/st2actions/BUILD b/st2actions/BUILD index a5a2baa6c1..676079ffb0 100644 --- a/st2actions/BUILD +++ b/st2actions/BUILD @@ -1,3 +1,10 @@ st2_component_python_distribution( component_name="st2actions", + scripts=[ + "bin/st2actionrunner", + "bin/st2notifier", + "bin/st2workflowengine", + "bin/st2scheduler", + "bin/runners.sh:shell", # used by service files installed by st2-packaging + ], ) diff --git a/st2api/BUILD b/st2api/BUILD index 5bd8df5173..6516f44920 100644 --- a/st2api/BUILD +++ b/st2api/BUILD @@ -1,3 +1,4 @@ st2_component_python_distribution( component_name="st2api", + scripts=["bin/st2api"], ) diff --git a/st2auth/BUILD b/st2auth/BUILD index 8e83f32b3a..5c862cb172 100644 --- a/st2auth/BUILD +++ b/st2auth/BUILD @@ -1,3 +1,4 @@ st2_component_python_distribution( component_name="st2auth", + scripts=["bin/st2auth"], ) diff --git a/st2common/BUILD b/st2common/BUILD index d194a86c5b..895e72a930 100644 --- a/st2common/BUILD +++ b/st2common/BUILD @@ -1,3 +1,29 @@ st2_component_python_distribution( component_name="st2common", + scripts=[ + # some scripts in bin are only for development and should not be included. + "bin/st2-bootstrap-rmq", + "bin/st2-cleanup-db", + "bin/st2-register-content", + "bin/st2-purge-executions", + "bin/st2-purge-workflows", + "bin/st2-purge-task-executions", + "bin/st2-purge-tokens", + "bin/st2-purge-trigger-instances", + "bin/st2-purge-traces", + "bin/st2-purge-rule-enforcements", + "bin/st2-generate-symmetric-crypto-key", + "bin/st2-track-result", + "bin/st2-validate-pack", + "bin/st2-validate-pack-config", + "bin/st2-pack-install", + "bin/st2-pack-download", + "bin/st2-pack-setup-virtualenv", + "bin/migrations/v3.5/st2-migrate-db-dict-field-values", + "bin/st2-run-pack-tests:shell", + "bin/st2ctl:shell", + "bin/st2-self-check:shell", + # dev scripts we might want to include + # "bin/st2-generate-schemas", + ], ) diff --git a/st2reactor/BUILD b/st2reactor/BUILD index 29fd451fbf..ba8bf89a93 100644 --- a/st2reactor/BUILD +++ b/st2reactor/BUILD @@ -1,3 +1,11 @@ st2_component_python_distribution( component_name="st2reactor", + scripts=[ + "bin/st2-rule-tester", + "bin/st2-trigger-refire", + "bin/st2rulesengine", + "bin/st2sensorcontainer", + "bin/st2garbagecollector", + "bin/st2timersengine", + ], ) diff --git a/st2stream/BUILD b/st2stream/BUILD index 1ec028de81..233bb07a2b 100644 --- a/st2stream/BUILD +++ b/st2stream/BUILD @@ -1,3 +1,4 @@ st2_component_python_distribution( component_name="st2stream", + scripts=["bin/st2stream"], ) From d72061f06db19168376f9e26110edb4e597db193 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Mon, 20 Feb 2023 13:55:36 -0600 Subject: [PATCH 3/5] fix execute bit on some scripts --- st2common/bin/st2-purge-task-executions | 0 st2common/bin/st2-purge-workflows | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 st2common/bin/st2-purge-task-executions mode change 100644 => 100755 st2common/bin/st2-purge-workflows diff --git a/st2common/bin/st2-purge-task-executions b/st2common/bin/st2-purge-task-executions old mode 100644 new mode 100755 diff --git a/st2common/bin/st2-purge-workflows b/st2common/bin/st2-purge-workflows old mode 100644 new mode 100755 From 575bd5730dbdf28f4c9cc235ab6dc41c710187ab Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Fri, 3 Feb 2023 12:44:18 -0600 Subject: [PATCH 4/5] record entry_points for wheels tag with stevedore_namespace so that once we enable the pants-plugin for stevedore, pants can install things appropriately for tests to access the setuptools metadata. --- pants-plugins/macros.py | 2 ++ st2auth/BUILD | 5 +++++ st2client/BUILD | 5 +++++ st2common/BUILD | 10 ++++++++++ 4 files changed, 22 insertions(+) diff --git a/pants-plugins/macros.py b/pants-plugins/macros.py index 79fad0091b..b7d2367022 100644 --- a/pants-plugins/macros.py +++ b/pants-plugins/macros.py @@ -84,6 +84,8 @@ def st2_component_python_distribution(**kwargs): description = ( f"{st2_component} StackStorm event-driven automation platform component" ) + # setup(scripts=[...]) is for pre-made scripts, which we have. + # TODO: use entry_points.console_scripts instead of hand-generating these. scripts = kwargs.pop("scripts", []) st2_license(dest=st2_component) diff --git a/st2auth/BUILD b/st2auth/BUILD index 5c862cb172..1e1d641374 100644 --- a/st2auth/BUILD +++ b/st2auth/BUILD @@ -1,4 +1,9 @@ st2_component_python_distribution( component_name="st2auth", scripts=["bin/st2auth"], + entry_points={ + stevedore_namespace("st2auth.sso.backends"): { + "noop": "st2auth.sso.noop:NoOpSingleSignOnBackend", + }, + }, ) diff --git a/st2client/BUILD b/st2client/BUILD index ec21bc1f36..96c25c45c2 100644 --- a/st2client/BUILD +++ b/st2client/BUILD @@ -1,3 +1,8 @@ st2_component_python_distribution( component_name="st2client", + entry_points={ + "console_scripts": { + "st2": "st2client.shell:main", + }, + }, ) diff --git a/st2common/BUILD b/st2common/BUILD index 895e72a930..75e35c9fc5 100644 --- a/st2common/BUILD +++ b/st2common/BUILD @@ -26,4 +26,14 @@ st2_component_python_distribution( # dev scripts we might want to include # "bin/st2-generate-schemas", ], + entry_points={ + stevedore_namespace("st2common.metrics.driver"): { + "statsd": "st2common.metrics.drivers.statsd_driver:StatsdDriver", + "noop": "st2common.metrics.drivers.noop_driver:NoopDriver", + "echo": "st2common.metrics.drivers.echo_driver:EchoDriver", + }, + stevedore_namespace("st2common.rbac.backend"): { + "noop": "st2common.rbac.backends.noop:NoOpRBACBackend", + }, + }, ) From 083fd00fc43fec8cddbd7e1d73c988a0e0357cc8 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Mon, 20 Feb 2023 14:16:39 -0600 Subject: [PATCH 5/5] update changelog entry --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1a3a580631..84005045a0 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 + #5890 #5898 #5901 #5906 #5899 #5907 #5909 Contributed by @cognifloyd * Added a joint index to solve the problem of slow mongo queries for scheduled executions. #5805