-
Notifications
You must be signed in to change notification settings - Fork 566
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
Allow accessing requirements directly by labels #414
Comments
Ok, so the reason for the status quo is mentioned in the wheel extracting code:
This happens inside the shim for launching a # Returns repository roots to add to the import path.
def GetRepositoriesImports(module_space, import_all):
if import_all:
repo_dirs = [os.path.join(module_space, d) for d in os.listdir(module_space)]
repo_dirs.sort()
return [d for d in repo_dirs if os.path.isdir(d)]
return [os.path.join(module_space, '__main__')] the thing I'm not sure of is why the external repository root is added to the Python path-that seems undesirable? (And here forces us to add prefixes to things to work around it.) |
Thanks for the issue @person142, this is an important misalignment with the rest of the rules ecosystem. Checking this locally for myself, I can indeed run a
where It does seem undesirable that this ends up on the PYTHONPATH. We need to track down why it ended up like this. |
One interesting thing is that
then the generated repos will have names like I'm working on a PR to make the prefix configurable so that the above shortened forms could be tried out. |
Aforementioned PR: #459. |
And working at it from the other end, bazelbuild/bazel#2636 (comment) on the Bazel side. So if we can get the |
We probably want something pretty close to what
If an |
The requirements.bzl helper produced by At a minimum I think we should stop saying "always use the requirement() helper" and instead say "you can use the __pypi names but note that a future release could change these, in that case we'll note it as a breaking change and give you a buildozer command to easily update your code" The requirements.bzl helper produced by |
@person142 should this be closed now that we have landed the change to pick your prefix for pip_parse? |
Yes, the situation for |
Update: I'm guessing this is what Update 2: the new label format under Is just writing the label still supposed to be supported under bzlmod? If not, should the "Using third_party packages as dependencies" section of the README be updated to recommend against doing this? I see With
|
🚀 feature request
Relevant Rules
py_binary
,py_library
, andpy_test
Description
Per the README accessing requirements by labels is not supported:
The requirements also have somewhat unintuitive labels since they prepend
pypi__
onto the (sanitized) package name. Not working with labels directly has some consequences:all_whl_requirements
without digging into the requirements workspace, so the abstraction is leaky. (Though uncommon, I find I occasionally need to dig through the requirements workspace in some other settings too.)requirement
, now there'swhl_requirement
, if you started wrapping console scripts then there would need to be a new function for that, etc. etc.Describe the solution you'd like
Is it possible to:
@<workspace>//<sanitized-package-name>
(For the short form of the label.)Describe alternatives you've considered
We don't enforce that Python deps be sorted. When I need to buildozer a requirement I do some hacky find-replace to stringify it and then unstringify it.
The text was updated successfully, but these errors were encountered: