Gazelle example that mixes internal and third party deps
🚀 feature request
Relevant Rules
rules_python, specifically the Gazelle capabilities: https://github.com/bazelbuild/rules_python/tree/main/gazelle
Description
I'm able to follow the README to enable Gazelle for my monorepo. However, it seems that updating the manifest file only looks at third party libraries. In order to avoid issues when running bazel run //:gazelle for internal dependencies (linked via deps in BUILD files), I have to manually add a bunch of directives to resolve between an attempted import and an internal dep.
Describe the solution you'd like
A happy path for resolving both internal and third party dependencies without having to manually list all internal deps as resolve directives.
I have the same issue; python gazelle doesn't update the BUILD files to include my internal dependencies.
Could you please share the directives you added to solve this?
Sure, it's nothing special. Just stuff like this:
# gazelle:resolve_regexp py py foo.* //foo/python/foo
I just did this while debugging and trying to set up Gazelle but I don't consider this a scalable solution. I figure there must be a way for Gazelle to crawl my internal deps the same way it did a great job at constructing the third party dep tree. One other detail I should mention is that I am setting up via single WORKSPACE file and not via bzlmod. If switching to bzlmod to manage 3rd party python dependencies magically fixes the internal dependency issue, then I will happily switch to that. Just holding off on that migration for now until I get some input here. Thanks!
Could you please post a minimal reproduction for us to better understand why you need to add the gazelle directives? That is usually not needed.
@aignas just wanted to acknowledge your comment - I appreciate you responding. I will try to come up with a reproducible example when I have a bit of downtime over the next week.
In the meantime, do you mind just confirming - if following the gazelle/autodeps instructions correctly, it should build manifests for not just third party libraries but also internal targets, is that correct? I might give it one more try on my $dayjob codebase - perhaps using bzlmod, which I wasn't before - before trying to make a standalone reproducible example.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!
#1842 could be something that may be useful once you try this again. Closing this as there are plenty of users using the plugin with internal and external dependencies and we have test coverage for the feature working, so it's likely a setup issue.