pants: register requirements for contrib/examples pack #5834
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
In #5733, I configured pants to ignore several requirements files, including
contrib/examples/requirements.txt
:st2/pants.toml
Lines 28 to 29 in f25df1f
One of the reasons I excluded that file, beyond what I described in #5733, was because it includes
requests
which is already included in the main requirements files:st2/contrib/examples/requirements.txt
Line 1 in f25df1f
st2/requirements-pants.txt
Line 58 in f25df1f
If we included both of these, then pants would start complaining that
import requests
is ambiguous all over the place. Compare that to #5833 where I had to disambiguate some other dependencies, but those affected a more isolated set of files. We do not want to register explicit dependencies onrequests
all over the place as that would be quite painful. So, excluding the requirements file was the best course of action.However, there are two more dependencies that are NOT in the main requirements file:
st2/contrib/examples/requirements.txt
Lines 2 to 3 in f25df1f
These deps,
beautifulsoup4
andflask
, are only needed for the examples pack. Including those in the main requirements file would be a signal for future contributors that they can use those in other parts of the codebase, but we don't want anything other than the examples pack to depend on them.So, this PR:
contrib/examples/BUILD
file, andlockfiles/st2.lock
(introduced in pantsbuild: Generate PEX lockfile for st2 #5830).This PR also shows an example of how github displays the lockfile diff when we add new dependencies.
Aside: Once we upgrade to pants 2.16 (which is in development), a new "dependency rules" feature will allow us to enforce that nothing else can import these deps. That will make this even safer.
Relevant Pants documentation