Skip to content

Commit 7032faf

Browse files
committed
finish adding BUILD data for python_distribution pants targets
1 parent ade68b1 commit 7032faf

File tree

16 files changed

+216
-43
lines changed

16 files changed

+216
-43
lines changed

pants-plugins/macros.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,23 @@ def st2_component_python_distribution(**kwargs):
4040
f"{st2_component} StackStorm event-driven automation platform component"
4141
)
4242

43+
scripts = kwargs.pop("scripts", [])
44+
4345
kwargs["provides"] = python_artifact(
4446
name=st2_component,
4547
description=description,
48+
scripts=[
49+
script[:-6] if script.endswith(":shell") else script for script in scripts
50+
],
4651
# version=get_version_string(INIT_FILE) # TODO
4752
# test_suite=st2_component,
4853
# zip_safe=False,
4954
)
5055

5156
dependencies = kwargs.pop("dependencies", [])
52-
for dep in [f"./{st2_component}"]:
57+
for dep in [st2_component] + scripts:
5358
if dep not in dependencies:
54-
dependencies.append(dep)
59+
dependencies.append(f"./{dep}")
5560
kwargs["dependencies"] = dependencies
5661

5762
python_distribution(**kwargs)

st2actions/BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
st2_component_python_distribution(
22
component_name="st2actions",
3+
scripts=[
4+
"bin/st2actionrunner",
5+
"bin/st2notifier",
6+
"bin/st2workflowengine",
7+
"bin/st2scheduler",
8+
"bin/runners.sh:shell", # used by service files installed by st2-packaging
9+
# policies get wired up by metadata in st2common/st2common/policies/meta/*.yaml
10+
"st2actions/policies",
11+
# backwards compat API:
12+
# st2actions.runners.pythonrunner.Action moved to st2common.runners.base_action.Action
13+
"st2actions/runners/pythonrunner.py",
14+
],
315
)

st2api/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
st2_component_python_distribution(
22
component_name="st2api",
3+
scripts=["bin/st2api"],
34
)

st2api/st2api/BUILD

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
python_sources()
1+
python_sources(
2+
overrides={
3+
"app.py": {
4+
"dependencies": [
5+
"./controllers",
6+
"./controllers/v1",
7+
"./controllers/exp",
8+
],
9+
},
10+
},
11+
)

st2api/st2api/controllers/BUILD

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
python_sources()
1+
python_sources(
2+
overrides={
3+
"root.py": {
4+
"dependencies": [
5+
"st2api/st2api/public", # cfg.static_root (has logo images)
6+
"st2api/st2api/templates", # cfg.template_path
7+
],
8+
},
9+
},
10+
)

st2auth/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
st2_component_python_distribution(
22
component_name="st2auth",
3+
dependencies=[
4+
# API classes not that cannot be inferred from bin/st2auth
5+
"./st2auth/backends/base.py",
6+
],
7+
scripts=["bin/st2auth"],
38
)

st2auth/st2auth/BUILD

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
python_sources()
1+
python_sources(
2+
overrides={
3+
"app.py": {
4+
"dependencies": [
5+
"./controllers",
6+
"./controllers/v1",
7+
],
8+
},
9+
},
10+
)

st2common/BUILD

Lines changed: 77 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,85 @@
11
st2_component_python_distribution(
22
component_name="st2common",
33
dependencies=[
4-
"./st2common",
5-
"./st2common/bootstrap",
6-
"./st2common/callback",
7-
"./st2common/cmd",
8-
"./st2common/constants",
9-
"./st2common/content",
10-
"./st2common/exceptions",
11-
#"./st2common/expressions",
12-
"./st2common/garbage_collection",
4+
# public API (not imported directly by any st2common entry points)
5+
"./st2common/callback/base.py",
6+
"./st2common/constants/garbage_collection.py",
7+
"./st2common/constants/policy.py",
8+
"./st2common/constants/timer.py",
9+
"./st2common/models/api/auth.py",
10+
"./st2common/models/api/inquiry.py",
11+
"./st2common/models/api/rbac.py",
12+
"./st2common/models/api/rule_enforcement.py",
13+
"./st2common/models/api/webhook.py",
14+
"./st2common/models/db/timer.py",
15+
"./st2common/models/system/actionchain.py",
16+
"./st2common/models/system/paramiko_command_action.py",
17+
"./st2common/models/system/paramiko_script_action.py",
18+
"./st2common/persistence/execution_queue.py",
19+
"./st2common/policies/concurrency.py",
20+
"./st2common/transport/consumers.py",
21+
"./st2common/validators/api/misc.py",
22+
"./st2common/services/datastore.py",
23+
"./st2common/services/inquiry.py",
24+
"./st2common/services/policies.py",
25+
"./st2common/services/rules.py",
26+
"./st2common/services/sensor_watcher.py",
27+
"./st2common/services/trigger_dispatcher.py",
28+
"./st2common/services/triggerwatcher.py",
29+
"./st2common/util/actionalias_helpstring.py",
30+
"./st2common/util/auth.py",
31+
"./st2common/util/keyvalue.py",
32+
"./st2common/util/sandboxing.py",
33+
"./st2common/util/service.py",
34+
"./st2common/util/wsgi.py",
35+
# public API: used by all of our logging conf files
1336
"./st2common/logging",
14-
#"./st2common/metrics",
15-
#"./st2common/metrics/drivers",
16-
"./st2common/middleware",
17-
"./st2common/models",
18-
"./st2common/models/api",
19-
"./st2common/models/db",
20-
"./st2common/models/system",
21-
"./st2common/models/utils",
22-
"./st2common/persistence",
23-
"./st2common/policies",
24-
"./st2common/policies/meta",
25-
#"./st2common/rbac",
37+
# public API: used by runners and python actions
2638
"./st2common/runners",
27-
"./st2common/services",
39+
# API: used by st2auth, st2api, st2stream
40+
"./st2common/middleware",
41+
# API: used by st2stream
2842
"./st2common/stream",
29-
"./st2common/transport",
30-
"./st2common/util",
31-
"./st2common/util/green",
32-
"./st2common/util/schema",
33-
"./st2common/validators",
34-
"./st2common/validators/api",
35-
"./st2common/validators/workflow",
43+
# TODO: missing st2common/bin/st2-purge-inquiries
44+
"./st2common/garbage_collection/inquiries.py",
45+
# these convenience imports can probably be removed
46+
# once persistence.reactor usages are replaced
47+
"./st2common/models/db/reactor.py", # dead code / unused
48+
"./st2common/persistence/reactor.py",
49+
# dead code (nothing imports it)
50+
# "./st2common/constants/scheduler.py",
51+
# "./st2common/content/validators.py",
52+
# "./st2common/exceptions/api.py", # InternalServerErrorException
53+
# "./st2common/exceptions/connection.py", # UnknownHostException, ConnectionErrorException, AuthenticationException
54+
# "./st2common/exceptions/resultstracker.py", # ReferenceNotFoundError
55+
# "./st2common/models/api/actionrunner.py",
56+
# "./st2common/util/argument_parser.py",
57+
# "./st2common/util/gunicorn_workers.py",
58+
# "./st2common/validators/workflow",
59+
],
60+
scripts=[
61+
# some scripts in bin are only for development and should not be included.
62+
"bin/st2-bootstrap-rmq",
63+
"bin/st2-cleanup-db",
64+
"bin/st2-register-content",
65+
"bin/st2-purge-executions",
66+
"bin/st2-purge-workflows",
67+
"bin/st2-purge-task-executions",
68+
"bin/st2-purge-trigger-instances",
69+
"bin/st2-purge-traces",
70+
"bin/st2-purge-rule-enforcements",
71+
"bin/st2-run-pack-tests:shell",
72+
"bin/st2ctl:shell",
73+
"bin/st2-generate-symmetric-crypto-key",
74+
"bin/st2-self-check:shell",
75+
"bin/st2-track-result",
76+
"bin/st2-validate-pack",
77+
"bin/st2-validate-pack-config",
78+
"bin/st2-pack-install",
79+
"bin/st2-pack-download",
80+
"bin/st2-pack-setup-virtualenv",
81+
"bin/migrations/v3.5/st2-migrate-db-dict-field-values",
82+
# dev scripts we might want to include
83+
# "bin/st2-generate-schemas",
3684
],
3785
)

st2common/bin/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,22 @@ shell_sources(
99
name="shell",
1010
sources=["st2ctl", "st2-self-check", "st2-run-pack-tests"],
1111
skip_shellcheck=True,
12+
overrides={
13+
"st2ctl": {
14+
"dependencies": [
15+
"./st2-register-content",
16+
"./st2-cleanup-db",
17+
],
18+
},
19+
"st2-self-check": {
20+
"dependencies": [
21+
"./st2ctl:shell",
22+
# TODO: dep on st2client cli?
23+
],
24+
},
25+
# st2-run-pack-tests creates its own virtualenv on the fly and
26+
# installs its dependencies, so they don't need to be listed here.
27+
# It can optionally use the deps installed with st2tests package.
28+
# "st2-run-pack-tests": {},
29+
},
1230
)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# TODO: what to do about st2-migrate-db-dict-field-values ?
22
# st2_migrate_db_dict_field_values.py is a symlink to st2-migrate-db-dict-field-values
3-
python_sources()
3+
python_sources(
4+
sources=["*.py", "st2*"],
5+
)

0 commit comments

Comments
 (0)