Skip to content

Commit b170603

Browse files
committed
add LICENSE to all wheels and sdists built by pants
1 parent 8258239 commit b170603

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

BUILD

+5
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ python_test_utils(
5252
name="test_utils",
5353
skip_pylint=True,
5454
)
55+
56+
file(
57+
name="license",
58+
source="LICENSE",
59+
)

pants-plugins/macros.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,28 @@
1313
# limitations under the License.
1414

1515

16+
def st2_license(**kwargs):
17+
"""copy the LICENSE file into each wheel.
18+
19+
As long as the file is in the src root when building the sdist/wheel,
20+
setuptools automatically includes the LICENSE file in the dist-info.
21+
"""
22+
if "dest" not in kwargs:
23+
raise ValueError("'dest' path is required for st2_license macro")
24+
relocated_files( # noqa: F821
25+
name="license",
26+
files_targets=["//:license"],
27+
src="",
28+
**kwargs,
29+
)
30+
31+
1632
def st2_runner_python_distribution(**kwargs):
1733
runner_name = kwargs.pop("runner_name")
1834
description = kwargs.pop("description")
1935

36+
st2_license(dest=f"contrib/runners/{runner_name}_runner")
37+
2038
kwargs["provides"] = python_artifact( # noqa: F821
2139
name=f"stackstorm-runner-{runner_name.replace('_', '-')}",
2240
description=description,
@@ -28,7 +46,7 @@ def st2_runner_python_distribution(**kwargs):
2846
)
2947

3048
dependencies = kwargs.pop("dependencies", [])
31-
for dep in [f"./{runner_name}_runner"]:
49+
for dep in [f"./{runner_name}_runner", ":license"]:
3250
if dep not in dependencies:
3351
dependencies.append(dep)
3452
kwargs["dependencies"] = dependencies
@@ -45,6 +63,8 @@ def st2_runner_python_distribution(**kwargs):
4563
def st2_component_python_distribution(**kwargs):
4664
st2_component = kwargs.pop("component_name")
4765

66+
st2_license(dest=st2_component)
67+
4868
description = (
4969
f"{st2_component} StackStorm event-driven automation platform component"
5070
)
@@ -64,7 +84,7 @@ def st2_component_python_distribution(**kwargs):
6484

6585
dependencies = kwargs.pop("dependencies", [])
6686

67-
for dep in [st2_component] + scripts:
87+
for dep in [st2_component, ":license"] + scripts:
6888
dep = f"./{dep}" if dep[0] != ":" else dep
6989
if dep not in dependencies:
7090
dependencies.append(dep)

0 commit comments

Comments
 (0)