Skip to content

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Feb 20, 2023

Background

This is another part of introducing pants, as discussed in various TSC meetings.

Related PRs can be found in:

Overview of this PR

This PR adds the st2_component_python_distribution() macro to the BUILD metadata for all of our components (st2common, st2client, st2auth, etc).

Thanks to the macro, we only have to define 3 (or 4) parameters for each runner: component_name, scripts, and entry_points. I copied the scripts and entry_points from the setup.py file, which will become obsolete once pants can generate the setup.py file for us.

Under entry_points, I have "tagged" the st2auth.sso.backends, the st2common.metrics.driver and the st2common.rbac.backend categories as stevedore_namespaces. Once we switch to 2.16 and enable the pants.backend.experimental.python.framework.stevedore plugin, the stevedore plugin will, for tests, use this "tag" to look up which wheels implement a plugin in that stevedore namespace.

To facilitate comparison, I will add a comment to each of the files that shows the current setup.py entry_points and scripts.

Next steps

Follow-up PRs will adjust the dependencies on the python_distributions to ensure all files get included.

@cognifloyd cognifloyd added this to the pants milestone Feb 20, 2023
@cognifloyd cognifloyd self-assigned this Feb 20, 2023
@pull-request-size pull-request-size bot added the size/M PR that changes 30-99 lines. Good size to review. label Feb 20, 2023
Comment on lines +3 to +9
scripts=[
"bin/st2actionrunner",
"bin/st2notifier",
"bin/st2workflowengine",
"bin/st2scheduler",
"bin/runners.sh:shell", # used by service files installed by st2-packaging
],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

st2/st2actions/setup.py

Lines 49 to 54 in f115934

scripts=[
"bin/st2actionrunner",
"bin/st2notifier",
"bin/st2workflowengine",
"bin/st2scheduler",
],

Plus I noticed that st2-packaging needs runners.sh, so I included that as well.

@@ -0,0 +1,4 @@
st2_component_python_distribution(
component_name="st2api",
scripts=["bin/st2api"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts=["bin/st2api"],

Comment on lines +3 to +8
scripts=["bin/st2auth"],
entry_points={
stevedore_namespace("st2auth.sso.backends"): {
"noop": "st2auth.sso.noop:NoOpSingleSignOnBackend",
},
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

st2/st2auth/setup.py

Lines 49 to 52 in f115934

scripts=["bin/st2auth"],
entry_points={
"st2auth.sso.backends": ["noop = st2auth.sso.noop:NoOpSingleSignOnBackend"]
},

Comment on lines +3 to +7
entry_points={
"console_scripts": {
"st2": "st2client.shell:main",
},
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entry_points={"console_scripts": ["st2 = st2client.shell:main"]},

Comment on lines +3 to +38
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",
],
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",
},
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

st2/st2common/setup.py

Lines 50 to 82 in f115934

scripts=[
"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-trigger-instances",
"bin/st2-purge-traces",
"bin/st2-purge-rule-enforcements",
"bin/st2-purge-tokens",
"bin/st2-run-pack-tests",
"bin/st2ctl",
"bin/st2-generate-symmetric-crypto-key",
"bin/st2-self-check",
"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",
],
entry_points={
"st2common.metrics.driver": [
"statsd = st2common.metrics.drivers.statsd_driver:StatsdDriver",
"noop = st2common.metrics.drivers.noop_driver:NoopDriver",
"echo = st2common.metrics.drivers.echo_driver:EchoDriver",
],
"st2common.rbac.backend": [
"noop = st2common.rbac.backends.noop:NoOpRBACBackend"
],
},

A few of the scripts were missing in setup.py, so I included them here. Also, a couple of them were missing the execute bit, so I added that as well.,

Comment on lines +3 to +10
scripts=[
"bin/st2-rule-tester",
"bin/st2-trigger-refire",
"bin/st2rulesengine",
"bin/st2sensorcontainer",
"bin/st2garbagecollector",
"bin/st2timersengine",
],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

st2/st2reactor/setup.py

Lines 49 to 56 in f115934

scripts=[
"bin/st2-rule-tester",
"bin/st2-trigger-refire",
"bin/st2rulesengine",
"bin/st2sensorcontainer",
"bin/st2garbagecollector",
"bin/st2timersengine",
],

@@ -0,0 +1,4 @@
st2_component_python_distribution(
component_name="st2stream",
scripts=["bin/st2stream"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts=["bin/st2stream"],

@cognifloyd
Copy link
Member Author

#5906 should be merged first

@cognifloyd cognifloyd marked this pull request as ready for review February 20, 2023 20:20
@cognifloyd cognifloyd force-pushed the pants-python_distributions-components branch from 7016ce7 to 4dd0184 Compare February 24, 2023 17:44
Copy link
Contributor

@amanda11 amanda11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are st2common/bin/st2-purge-task-executions and st2common/bin/st2-purge-workflows now empty files?
Is that github just showing it odd in PR, and all you've done is change the permissions on the file?

@cognifloyd
Copy link
Member Author

Yeah. That's just GitHub being weird as I only changed the execute bit, not the file contents. If you do a "view file" on those, you'll see the file contents.

@cognifloyd cognifloyd force-pushed the pants-python_distributions-components branch from 4dd0184 to c3615b5 Compare February 27, 2023 17:51
@cognifloyd cognifloyd enabled auto-merge February 27, 2023 17:52
@cognifloyd cognifloyd requested review from amanda11 and a team February 27, 2023 17:53
@cognifloyd cognifloyd requested a review from a team February 27, 2023 23:44
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.
@cognifloyd cognifloyd force-pushed the pants-python_distributions-components branch from c3615b5 to 083fd00 Compare March 2, 2023 20:52
@cognifloyd cognifloyd merged commit 7fe538a into master Mar 2, 2023
@cognifloyd cognifloyd deleted the pants-python_distributions-components branch March 2, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pantsbuild size/M PR that changes 30-99 lines. Good size to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants