-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
fix: use correct runfiles path for venv import paths #299
Conversation
Fix for aspect-build#276. In `_make_import_path`, `ctx.workspace_name` is always `_main` when evaluating the deps of targets in the main repo. This includes deps that are in external repos, e.g. importer = use_extension("//:import.bzl", "importer") use_repo(importer, "myrepo") with py_test(..., deps = ["@myrepo//foo"]) In this case, we actually want to use the label's `workspace_name` attr which will be the same as the runfiles path that we need for the venv import paths. Also added a new e2e test that creates this external repo and verifies the fix. Without the fix in place, the test does fail as described in the e2e/repository-rule-deps/README.md "Repro" section.
I would like to see that the new e2e/repository-rule-deps is properly executed via the new "repository-rule-deps" check before this merges as well. I don't expect that I have permissions to run this, though. Also, once bzlmod is enabled for |
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.
Wow, nicely documented!
As Alex pointed out: > this doesn't need a new job, you can just add to the `folders` array > of the `test` job above
thanks @wade-arista , I was in the process of fixing this same issue, but you did a much better job than I had time for 😄 |
sure thing! Sorry, I had meant to post a link to discourse on #276 where we were discussing a PR, but then I forgot. Hopefully this is the same thing fix you had in mind? |
Yeah I believe this covers my case but I will have to double check just to make sure. I did notice a further issue in my testing. After patching importing a py_libary from another workspace, I saw that the dependencies of this library not being picked up correctly. I'll take a look if that is still the case and raise a separate issue if so. |
--- ### Type of change - Bug fix (change which fixes an issue) ### Test plan - Covered by existing test cases ### Details As a follow-up to #299 , this PR enables the use of external dependencies that use workspace root relative imports. This just expands current functionality to also cover the case where the dependency is from an external workspace.
In
_make_import_path
,ctx.workspace_name
is always_main
when evaluating the deps of targets in the main repo. This includes deps that are in external repos, e.g.with
In this case, we actually want to use the label's
workspace_name
attr which will be the same as the runfiles path that we need for the venv import paths.Also added a new e2e test that creates this external repo and verifies the fix. Without the fix in place, the test does fail as described in the e2e/repository-rule-deps/README.md "Repro" section.
Test plan
e2e/repository-rule-deps
.Fixes: #276