Packaging: Inject st2 version into rpm/deb packages (pants-plugins/release)#6321
Merged
cognifloyd merged 6 commits intomasterfrom Mar 24, 2025
Merged
Packaging: Inject st2 version into rpm/deb packages (pants-plugins/release)#6321cognifloyd merged 6 commits intomasterfrom
cognifloyd merged 6 commits intomasterfrom
Conversation
Contributor
|
It looks awesome and pretty useful on the first glance. I will take the time for a full review on the weekend. |
guzzijones
approved these changes
Mar 20, 2025
dd86e54 to
1370f97
Compare
Member
Author
|
CircleCI builds are broken thanks to a new release of setuptools (v78) that removes support for deprecated keys in I'm working on fixing this by add a constraint to the wheels that are inadvertently (in st2-packages CI) pulling in this too-new version of setuptools. |
This was referenced Mar 24, 2025
This was referenced Apr 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is working towards doing packaging via pantsbuild. Eventually, I hope to archive and stop using st2-packages.git.
This PR enables the
nfpmbackend in pants and updatespants-plugins/releaseso that it can inject the version number into the rpm/deb similar to how that plugin injects the version in python wheels that pants builds. To keep this PR focused onpants-plugins/release, it does not add any BUILD metadata likenfpm_deb_packageornfpm_rpm_package. Adding the BUILD metadata, and using the changes introduced in this PR, will come in follow-up PRs.Relevant pants docs about nfpm:
nfpmsubsystemnfpm_deb_packagetargetversion_schemafieldversionfieldnfpm_rpm_packagetargetversion_schemafieldversionfieldInjectNfpmPackageFieldsRequestplugin hookRelevant pants docs about developing our
pants-plugins/release:Implemenation notes
It can be helpful to review each commit of this PR.
8290573: enable the nFPM backend in pants.
3e20568:
pants-plugins/releasewas introduced in Addpants-plugins/releaseto handle wheel metadata generation #5891 to help with injecting wheel metadata (like the version number) into the generated wheels. Since we already have the logic to get the version number, and we want to do the same for nfpm, I extracted that into a separate pants rule calledextract_version.st2/pants-plugins/release/rules.py
Lines 103 to 104 in 3e20568
6b508a2: Then I implemented an
InjectNfpmPackageFieldsRequestwith theinject_package_fieldsrule.st2/pants-plugins/release/rules.py
Lines 196 to 205 in 6b508a2
And, this registers our implementation with a
UnionRulehere:st2/pants-plugins/release/rules.py
Line 234 in 6b508a2
This is where this rule uses the
extract_versionrule introduced in the last commit:st2/pants-plugins/release/rules.py
Lines 208 to 215 in 6b508a2
Then the cleans up the version to match nfpm's expectations of
semverformatted versions:st2/pants-plugins/release/rules.py
Lines 217 to 221 in 6b508a2
Finally, the rule defines the fields that get injected in
nfpm_deb_packageandnfpm_rpm_packagetargets.st2/pants-plugins/release/rules.py
Lines 223 to 226 in 6b508a2
If the version extracted is
3.9.0dev, then the equivalent hard-coded BUILD metadata would look like:Note: A follow-up PR will inject
version_release, another nfpm package field. I did not include that in this PR, because it involves a script to retrieve the release number from packagecloud.