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

Core: add pants_hash() function. #20650

Closed
wants to merge 1 commit into from
Closed

Conversation

kaos
Copy link
Member

@kaos kaos commented Mar 7, 2024

Introduce new pants_hash() function to get the fingerprint for sources to be used as target field value.

When using a target type as glob, the default globs of its source(s) field will be used.

Example:

target(
  version_tag=pants_hash("src/*.y", "tests/*.z", some_target_type)
)

Relates to #8445

@@ -47,6 +47,7 @@ def parse(
parser: Parser,
extra_symbols: BuildFilePreludeSymbols,
env_vars: EnvironmentVars,
pants_hashes: Mapping[tuple[str, ...], str],
Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't bother creating a dedicated type for this, as it's not part of any rule API.. but did consider doing it anyway for aesthetic reasons. So if there's any preferences in that direction... 🤷🏽

@kaos
Copy link
Member Author

kaos commented Mar 7, 2024

Given that this doesn't pick up sources from other targets or its dependencies, I'm not sure how useful this feature is...

@huonw
Copy link
Contributor

huonw commented Mar 7, 2024

Given that this doesn't pick up sources from other targets or its dependencies, I'm not sure how useful this feature is...

Hmmmm, that does make it seem rather error prone, where people might rely on it in incorrect circumstances!

Does it potentially also miss global options from pants.toml that might influence behaviour? (e.g. for a pex_binary the version of pex might change the output, so the configuration of the [pex-cli] subsystem should influence the hash.)

@kaos
Copy link
Member Author

kaos commented Mar 8, 2024

Given that this doesn't pick up sources from other targets or its dependencies, I'm not sure how useful this feature is...

Hmmmm, that does make it seem rather error prone, where people might rely on it in incorrect circumstances!

Does it potentially also miss global options from pants.toml that might influence behaviour? (e.g. for a pex_binary the version of pex might change the output, so the configuration of the [pex-cli] subsystem should influence the hash.)

Yea, it merely reports the digest fingerprint of the pointed at sources. That's all. Which at a low level is fine, but the UX is not good enough to expose the list of sources to fingerprint as input for the end user to provide.

Given the above limitations, I think we need an alternative approach at providing a hash for targets rather than loose sources.

@kaos kaos closed this Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants