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

Compute source roots in a rule. #9888

Merged
merged 9 commits into from May 29, 2020
Merged

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented May 28, 2020

Previously we computed the source root for a path outside the engine, via a utility method.

However we want to support marking source roots using a sentinel file, and this requires source root computation to have filesystem access, meaning it has to be done in a rule.

This change introduces a set of rules for finding the source root for a path, and converts all v2 code to use those rules.

Note that this change introduces a new field, root_to_relfiles, on SourceRootStrippedSources, which maps from each found source root to the list of files under that source root. This allows us to re-use source root stripping logic in places where we previously replicated it. V2 Engine FTW!

A future change will leverage this change to support sentinel files.

[ci skip-rust-tests]
[ci skip-jvm-tests]

Previously we computed the source root for a path
outside the engine, via a utillity method. However we
want to support marking source roots using a sentinel
file, and this requires filesystem access in the computation,
meaning that has to be done in a rule.

This change introduces a set of rules for finding the source root
for a path, and converts all v2 code to use those rules.

[ci skip-rust-tests]
[ci skip-jvm-tests]
@benjyw benjyw changed the title Rules to compute source roots. Compute source roots in a rule. May 28, 2020
@benjyw benjyw marked this pull request as ready for review May 28, 2020 22:39
@benjyw
Copy link
Sponsor Contributor Author

benjyw commented May 28, 2020

Reviewers: This isn't just boilerplate, please double-check my logic. Thanks!

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

src/python/pants/source/source_root.py Outdated Show resolved Hide resolved
src/python/pants/source/source_root.py Show resolved Hide resolved
src/python/pants/core/util_rules/strip_source_roots.py Outdated Show resolved Hide resolved
src/python/pants/core/util_rules/strip_source_roots.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/rules/util.py Show resolved Hide resolved
src/python/pants/backend/python/rules/run_setup_py.py Outdated Show resolved Hide resolved
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

src/python/pants/backend/project_info/list_roots.py Outdated Show resolved Hide resolved
src/python/pants/source/source_root.py Outdated Show resolved Hide resolved
src/python/pants/core/util_rules/strip_source_roots.py Outdated Show resolved Hide resolved
[ci skip-rust-tests]
[ci skip-jvm-tests]
[ci skip-rust-tests]
[ci skip-jvm-tests]
[ci skip-rust-tests]
[ci skip-jvm-tests]
@benjyw benjyw requested a review from stuhood May 29, 2020 16:35
# Delete this line to force CI to run Clippy and the Rust tests.
[ci skip-rust-tests]
# Delete this line to force CI to run the JVM tests.
[ci skip-jvm-tests]
# Delete this line to force CI to run Clippy and the Rust tests.
[ci skip-rust-tests]
# Delete this line to force CI to run the JVM tests.
[ci skip-jvm-tests]
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Many tests will need them, so it seems reasonable.

[ci skip-rust-tests]
[ci skip-jvm-tests]
[ci skip-rust-tests]
[ci skip-jvm-tests]
[ci skip-rust-tests]
[ci skip-jvm-tests]
@benjyw benjyw merged commit e23ca1b into pantsbuild:master May 29, 2020
@benjyw benjyw deleted the source_roots_rules branch May 29, 2020 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants