Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Added
to pants' use of PEX lockfiles. This is not a user-facing addition.
#6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253
#6254 #6258 #6259 #6260 #6269 #6275 #6279 #6278 #6282 #6283 #6273 #6287 #6306 #6307
#6311 #6314 #6315 #6317 #6319 #6312 #6320
#6311 #6314 #6315 #6317 #6319 #6312 #6320 #6321
Contributed by @cognifloyd
* Build of ST2 EL9 packages #6153
Contributed by @amanda11
Expand Down
1 change: 1 addition & 0 deletions contrib/runners/orquesta_runner/in-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
orquesta@ git+https://github.com/StackStorm/orquesta.git@5ba1467614b2ef8b4709b2ca89e68baa671e8975
setuptools
1 change: 1 addition & 0 deletions contrib/runners/orquesta_runner/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# in-requirements.txt for that component and then run 'make requirements' to
# update the component requirements.txt
orquesta@ git+https://github.com/StackStorm/orquesta.git@5ba1467614b2ef8b4709b2ca89e68baa671e8975
setuptools<78
3 changes: 3 additions & 0 deletions fixed-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ tooz==6.3.0
# virtualenv==20.29.2 (<21) has pip==25.0.1 wheel==0.45.1 setuptools==75.3.0
# lockfiles/st2.lock has pip==25.0.1 wheel==0.45.1 setuptools==75.3.0
virtualenv==20.29.2
# This setuptools version number is in the Makefile, but CircleCI builds are pulling a version
# that is incompatible with our logshipper fork.
setuptools<78
webob==1.8.9
webtest==3.0.1
zake==0.2.2
Expand Down
96 changes: 81 additions & 15 deletions pants-plugins/release/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@
from __future__ import annotations

import re
from dataclasses import dataclass

from pants.backend.nfpm.fields.version import NfpmVersionField, NfpmVersionSchemaField
from pants.backend.nfpm.util_rules.inject_config import (
InjectedNfpmPackageFields,
InjectNfpmPackageFieldsRequest,
)
from pants.backend.python.util_rules.package_dists import (
SetupKwargs,
SetupKwargsRequest,
)
from pants.engine.fs import DigestContents, GlobMatchErrorBehavior, PathGlobs
from pants.engine.internals.native_engine import Field
from pants.engine.target import Target
from pants.engine.rules import collect_rules, Get, MultiGet, rule, UnionRule
from pants.util.frozendict import FrozenDict
Expand Down Expand Up @@ -88,6 +95,40 @@ def is_applicable(cls, _: Target) -> bool:
# return target.address.spec.startswith("st2")


@dataclass(frozen=True)
class StackStormVersionRequest:
version_file: str
description_of_origin: str


@dataclass(frozen=True)
class StackStormVersion:
value: str


@rule
async def extract_version(request: StackStormVersionRequest) -> StackStormVersion:
version_digest_contents = await Get(
DigestContents,
PathGlobs(
[request.version_file],
description_of_origin=request.description_of_origin,
glob_match_error_behavior=GlobMatchErrorBehavior.error,
),
)

version_file_contents = version_digest_contents[0].content.decode()
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file_contents, re.M
)
if not version_match:
raise ValueError(
f"Could not find the __version__ in {request.version_file}\n{version_file_contents}"
)

return StackStormVersion(version_match.group(1))


@rule
async def setup_kwargs_plugin(request: StackStormSetupKwargsRequest) -> SetupKwargs:
kwargs = request.explicit_kwargs.copy()
Expand All @@ -100,13 +141,12 @@ async def setup_kwargs_plugin(request: StackStormSetupKwargsRequest) -> SetupKwa

version_file = kwargs.pop("version_file")

version_digest_contents, readme_digest_contents = await MultiGet(
version, readme_digest_contents = await MultiGet(
Get(
DigestContents,
PathGlobs(
[f"{request.target.address.spec_path}/{version_file}"],
StackStormVersion,
StackStormVersionRequest(
version_file=f"{request.target.address.spec_path}/{version_file}",
description_of_origin=f"StackStorm version file: {version_file}",
glob_match_error_behavior=GlobMatchErrorBehavior.error,
),
),
Get(
Expand All @@ -118,19 +158,10 @@ async def setup_kwargs_plugin(request: StackStormSetupKwargsRequest) -> SetupKwa
),
)

version_file_contents = version_digest_contents[0].content.decode()
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file_contents, re.M
)
if not version_match:
raise ValueError(
f"Could not find the __version__ in {request.target.address.spec_path}/{version_file}\n{version_file_contents}"
)

# Hardcode certain kwargs and validate that they weren't already set.
hardcoded_kwargs = PROJECT_METADATA.copy()
hardcoded_kwargs["project_urls"] = FrozenDict(PROJECT_URLS)
hardcoded_kwargs["version"] = version_match.group(1)
hardcoded_kwargs["version"] = version.value

long_description = (
readme_digest_contents[0].content.decode() if readme_digest_contents else ""
Expand Down Expand Up @@ -162,8 +193,43 @@ async def setup_kwargs_plugin(request: StackStormSetupKwargsRequest) -> SetupKwa
return SetupKwargs(kwargs, address=request.target.address)


class StackStormNfpmPackageFieldsRequest(InjectNfpmPackageFieldsRequest):
@classmethod
def is_applicable(cls, _: Target) -> bool:
return True


@rule
async def inject_package_fields(
request: StackStormNfpmPackageFieldsRequest,
) -> InjectedNfpmPackageFields:
address = request.target.address

version_file = "st2common/st2common/__init__.py"
extracted_version = await Get(
StackStormVersion,
StackStormVersionRequest(
version_file=version_file,
description_of_origin=f"StackStorm version file: {version_file}",
),
)

version: str = extracted_version.value
if version.endswith("dev") and version[-4] != "-":
# nfpm parses this into version[-version_prerelease][+version_metadata]
# that dash is required to be a valid semver version.
version = version.replace("dev", "-dev")

fields: list[Field] = [
NfpmVersionSchemaField("semver", address=address),
NfpmVersionField(version, address=address),
]
return InjectedNfpmPackageFields(fields, address=address)


def rules():
return [
*collect_rules(),
UnionRule(SetupKwargsRequest, StackStormSetupKwargsRequest),
UnionRule(InjectNfpmPackageFieldsRequest, StackStormNfpmPackageFieldsRequest),
]
3 changes: 3 additions & 0 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ backend_packages = [
# packaging
"pants.backend.experimental.makeself",

# packaging
"pants.backend.experimental.nfpm",

# internal plugins in pants-plugins/
"pants.backend.plugin_development",
"api_spec",
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ requests==2.32.3
retrying==1.3.4
routes==2.5.1
semver==3.0.4
setuptools<78
simplejson
six==1.17.0
sseclient-py==1.8.0
Expand Down
3 changes: 3 additions & 0 deletions st2actions/in-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ lockfile
# needed by core "linux" pack - TODO: create virtualenv for linux pack on postinst
pyinotify
logshipper@ git+https://github.com/StackStorm/logshipper.git@stackstorm_patched ; platform_system=="Linux"
# logshipper has metadata in setup.cfg that is not supported by setuptools 78, so we need
# an explicit dep (from fixed-requirements.txt) to prevent CircleCI from pulling that in.
setuptools
# required by pack_mgmt/setup_virtualenv.py#L135
virtualenv
# needed by requests
Expand Down
1 change: 1 addition & 0 deletions st2actions/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ python-dateutil==2.9.0.post0
python-json-logger
pyyaml==6.0.2
requests==2.32.3
setuptools<78
six==1.17.0
urllib3==2.2.3
Loading