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

[internal] Fix go_binary's main field inference to work with generated targets #13163

Merged
merged 1 commit into from
Oct 8, 2021

Conversation

Eric-Arellano
Copy link
Contributor

Restores support for #13117 post-#13139.

[ci skip-rust]

…rated targets

[ci skip-rust]

[ci skip-build-wheels]
Comment on lines +152 to +156
if not self.address.is_generated_target:
# TODO: Make this error more eager via target validation.
raise AssertionError(
f"Target was manually created, but expected to be generated: {self.address}"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tdyas I've been thinking a lot the past few days about whether to keep _go_{first,third}_party_package targets private.

The downside is they won't show up in ./pants help and the docs, and I think it would be helpful for people to understand what the atoms of their builds are. In particular, it will be important when adding an overrides mechanism to go_mod.

I think the answer is to make them public, but use eager validation that they are never explicitly created.

Copy link
Contributor

Choose a reason for hiding this comment

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

I share your concern with that downside. Letting users understand the magic even a little is probably beneficial, even if the targets should be auto-generated in the standard case. Should the first-party target then be called go_package again, or keep the longer name so users are less likely to try and use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should still be go_first_party_package, per discussion today. But document that it should not be manually created + add eager validation.

"Hint: consider leaving off this field so that Pants will find the `go_package` "
"target for you."
"Hint: consider leaving off this field so that Pants will find the "
"`_go_internal_package` target for you."
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this error explain to the user that _go_internal_package is a hidden target type that is auto-generated for them? Some of the other error messages in this PR do mention that fact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably. Will audit all the error messages when renaming these targets.

@Eric-Arellano Eric-Arellano enabled auto-merge (squash) October 8, 2021 02:49
@Eric-Arellano Eric-Arellano merged commit 7b5b86f into pantsbuild:main Oct 8, 2021
@Eric-Arellano Eric-Arellano deleted the infer-main branch October 8, 2021 06:32
@stuhood stuhood mentioned this pull request Oct 11, 2021
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.

2 participants