Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pants source roots and a constant for pack common lib directory #5930

Merged
merged 3 commits into from
Mar 10, 2023

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Mar 10, 2023

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 in pants.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 a COMMON_LIB_DIR constant to clarify which lib is which (ie to distinguish it from virtualenv/lib and virtualenv/python*/lib). I also adjusted one other place that was not using the action LIBS_DIR constant like everything else that references <pack>/actions/lib.

Pants documentation

@cognifloyd cognifloyd added this to the pants milestone Mar 10, 2023
@cognifloyd cognifloyd self-assigned this Mar 10, 2023
@pull-request-size pull-request-size bot added the size/S PR that changes 10-29 lines. Very easy to review. label Mar 10, 2023
@cognifloyd cognifloyd requested a review from a team March 10, 2023 06:38
@cognifloyd cognifloyd merged commit 3803450 into master Mar 10, 2023
@cognifloyd cognifloyd deleted the common-lib-dir branch March 10, 2023 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packs pantsbuild refactor size/S PR that changes 10-29 lines. Very easy to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants