Add pants source roots and a constant for pack common lib directory #5930
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
I ran into an issue with dependency inference not understanding the "lib" directories. ST2 adds
<pack>/lib
to PYTHONPATH for both actions and sensors, and<pack>/actions/lib
to PYTHONPATH for actions. Pants uses "source roots" to manage the PYTHONPATH, so we need a way for pants to detect those source roots when needed. So, I adjusted the[source].root_patterns
setting inpants.toml
to account for these lib dirs.While investigating this, I had to dive into the code that defines PYTHONPATH for running pack actions/sensors. I found the
"lib"
string to be rather confusing as only some of them referred to our special common libs directory. So to clarify that code, I added aCOMMON_LIB_DIR
constant to clarify which lib is which (ie to distinguish it fromvirtualenv/lib
andvirtualenv/python*/lib
). I also adjusted one other place that was not using the actionLIBS_DIR
constant like everything else that references<pack>/actions/lib
.Pants documentation