rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

Gazelle example that mixes internal and third party deps

Open FrankPortman opened this issue 2 years ago • 5 comments

🚀 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.

FrankPortman avatar Aug 22 '23 13:08 FrankPortman

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?

cbournhonesque-sc avatar Aug 28 '23 16:08 cbournhonesque-sc

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!

FrankPortman avatar Aug 28 '23 16:08 FrankPortman

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 avatar Nov 05 '23 13:11 aignas

@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.

FrankPortman avatar Nov 07 '23 14:11 FrankPortman

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!

github-actions[bot] avatar May 05 '24 22:05 github-actions[bot]

#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.

aignas avatar Jun 04 '24 01:06 aignas