pants: Add st2_*_python_distribution()
macros to pants-plugins/macros.py
#5901
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.
Background
This is another part of introducing pants, as discussed in various TSC meetings.
Related PRs can be found in:
Overview of this PR
This PR adds pants macros that reduce boilerplate around defining
python_distribution()
:st2_license()
st2_component_python_distribution()
st2_runner_python_distribution()
The next PR will actually add those macros to the relevant BUILD files.
See #5890 for a description of pants macros and what is involved in using them in pants.
st2_license()
macroWe need to add a LICENSE file to all of our wheels. When building wheels, we don't have to add any special metadata to the setup.py
setup()
call (orpyproject.toml
or similar); we only need to put the LICENSE file in the directory that will be the wheel.st2/pants-plugins/macros.py
Lines 16 to 21 in 7de8f3c
st2_*_python_distribution()
macrosThese macros create:
st2_license
macro.python_artifact
object with the details needed to generate the setup.py kwargs. For example, it includes theversion_file
arg which is unique topants-plugins/release
which uses this to inject the version based on that file.python_distribution
target with the metadata for creating the wheel.Using this macro is like creating a
python_distribution
like this in each of the BUILD files:st2_component_python_distribution()
macroThis is meant for for our primary components:
st2common
,st2auth
,st2api
,st2client
, etc.For example, in the next PR this is how we'll define the
st2api
distribution:st2/st2api/BUILD
Lines 1 to 4 in 7032faf
st2_runner_python_distribution()
macroThis is meant for our runners:
contrib/runners/*_runner
.For example, in the next PR this is how we'll define the
noop
runner's distribution:st2/contrib/runners/noop_runner/BUILD
Lines 1 to 7 in 7032faf