Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ python_test_utils(
name="test_utils",
skip_pylint=True,
)

file(
name="license",
source="LICENSE",
)
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
#5890 #5898 #5901
Contributed by @cognifloyd

* Added a joint index to solve the problem of slow mongo queries for scheduled executions. #5805
Expand Down
93 changes: 93 additions & 0 deletions pants-plugins/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,99 @@
# limitations under the License.


def st2_license(**kwargs):
"""copy the LICENSE file into each wheel.
As long as the file is in the src root when building the sdist/wheel,
setuptools automatically includes the LICENSE file in the dist-info.
"""
if "dest" not in kwargs:
raise ValueError("'dest' path is required for st2_license macro")
relocated_files( # noqa: F821
name="license",
files_targets=["//:license"],
src="",
**kwargs,
)


def st2_runner_python_distribution(**kwargs):
runner_name = kwargs.pop("runner_name")
description = kwargs.pop("description")

st2_license(dest=f"contrib/runners/{runner_name}_runner")

kwargs["provides"] = python_artifact( # noqa: F821
name=f"stackstorm-runner-{runner_name.replace('_', '-')}",
description=description,
version_file=f"{runner_name}_runner/__init__.py", # custom for our release plugin
# test_suite="tests",
zip_safe=kwargs.pop(
"zip_safe", True
), # most runners are safe to run from a zipapp
)

dependencies = kwargs.pop("dependencies", [])
for dep in [f"./{runner_name}_runner", ":license"]:
if dep not in dependencies:
dependencies.append(dep)
kwargs["dependencies"] = dependencies

repositories = kwargs.pop("repositories", [])
for repo in ["@pypi"]:
if repo not in repositories:
repositories.append(repo)
kwargs["repositories"] = repositories

python_distribution(**kwargs) # noqa: F821


def st2_component_python_distribution(**kwargs):
st2_component = kwargs.pop("component_name")

st2_license(dest=st2_component)

description = (
f"{st2_component} StackStorm event-driven automation platform component"
)

scripts = kwargs.pop("scripts", [])

kwargs["provides"] = python_artifact( # noqa: F821
name=st2_component,
description=description,
scripts=[
script[:-6] if script.endswith(":shell") else script for script in scripts
],
version_file=f"{st2_component}/__init__.py", # custom for our release plugin
# test_suite=st2_component,
zip_safe=False, # We rely on __file__ to load many things, so st2 should not run from a zipapp
)

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

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

# see st2_shell_sources_and_resources below
if dep.endswith(":shell"):
dep_res = f"{dep}_resources"
if dep_res not in dependencies:
dependencies.append(dep_res)

kwargs["dependencies"] = dependencies

repositories = kwargs.pop("repositories", [])
for repo in ["@pypi"]:
if repo not in repositories:
repositories.append(repo)
kwargs["repositories"] = repositories

python_distribution(**kwargs) # noqa: F821


def st2_shell_sources_and_resources(**kwargs):
"""This creates a shell_sources and a resources target.
Expand Down