-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
go: analyze package metadata #12429
go: analyze package metadata #12429
Conversation
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
This comment has been minimized.
This comment has been minimized.
src/python/pants/backend/go/pkg.py
Outdated
module_address: Optional[Address] | ||
package_name: str | ||
imported_import_paths: Tuple[str] | ||
dependency_import_paths: Tuple[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field is imported paths plus what appears to be transitive dependencies.
|
||
|
||
@rule | ||
async def find_nearest_go_module(request: FindOwningGoModuleRequest) -> ResolvedOwningGoModule: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was refactored out of the target_type_rules
to allow reuse. Probably can be a separate PR.
The exception is being thrown from |
# Obtain unexpanded targets and ensure file targets are filtered out. Unlike Python, file targets do not | ||
# make sense semantically for Go source since Go builds entire packages at a time. The filtering is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: this is somewhat true of Java as well: the entire JVM package is implicitly available without an import statement, but separate compilation is still supported.
I expect that @patricklaw will have the inference implementation for the JVM infer a dependency on all files in the package (which will cause it to automatically be coarsened to a single CoarsenedTarget
) rather than taking the approach you're taking here. Part of the reason for that is that the JVM allows import cycles between files, and so he already needs to be able to support cycles and thus coarsening.
The equivalent case for go
would be if multiple packages had cyclic imports for one another: but it looks like that isn't possible: https://jogendra.dev/import-cycles-in-golang-and-how-to-deal-with-them
So yea: this seems like the way to go for go
.
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
address: Address | ||
|
||
|
||
def error_to_string(d: dict) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be dict[str, str]
, or is this trickier than that?
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
Analyze package metadata and report it via
ResolvedGoPackage
type. This provides the data that will be used for dependency inference and builds of packages.Also refactors the code that finds the owning
go_module
into its own rules viaFindNearestGoModuleRequest
.