-
Notifications
You must be signed in to change notification settings - Fork 541
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
Inconsistency: Implicit dependencies for a pip package used if already installed, needs to be explicitly specified as requirement otherwise #125
Comments
At least in this case, it seems like the issue is that google-auth just has an undeclared dependency on requests: https://github.com/GoogleCloudPlatform/google-auth-library-python/blob/master/setup.py#L21-L26 |
@theacodes can probably go into more detail about this (and can correct where I'm mistaken), but I think the case here is that @ghostwriternr: is "ensuring that we have |
You are correct, @nathanielmanistaatgoogle. |
@nathanielmanistaatgoogle Thanks a ton! That does make a lot of sense. And yes, the line you've referred to in the Bazel But I'd like to raise my question again. Does rules_python expect all explicit and implicit dependencies be specified as a 'requirement'? For instance here, |
A partial answer is transitive package dependencies used to automatically work. I haven't tracked down exactly what changed, but I think part of the problem is a Eg.
|
Was just hit by this issue because bazel 0.27 forced us to update a few packages. Is there any hope to see this issue fixed in the near term? |
+1 I'm seeing this as well |
@ghostwriternr I think you are looking for #198. It does add support for packages that do not contain a metadata.json file. You may want to try to reproduce a transitive import with it. I used the following: load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "rules_python",
remote = "https://github.com/oapio/rules_python.git", # oapio:marian/whl_fix
commit = "a158e6ad34fcc90a0a6cce663cd3153e7f8f86c3", # https://github.com/bazelbuild/rules_python/pull/198
) And successfully remove the following line from a load("@rules_python//python:defs.bzl", "py_binary")
load("@pypi//:requirements.bzl", "requirement")
py_binary(
name = "autoflake",
srcs = ["entrypoint.py"],
main = "entrypoint.py",
deps = [
requirement("autoflake"),
# requirement("pyflakes"), Removed this transitive dep with success
],
) |
rules_python 0.1.0 has been released which upstreams the rules_python_external repo. Please switch from |
TL;DR: Does rules_python expect that all explicit and implicit dependencies be specified as a 'requirement'?
I was using
google-auth
in my project today when I noticed this issue.SCENARIO 1:
Instance with
requests
Python package installed in the current environment.My
requirements.txt
:My
BUILD
file:Observation
My Bazel test failed with the following stacktrace, complaining about not finding the
requests
library:SCENARIO 2:
Fresh instance with no PIP packages installed in current environment.
My
requirements.txt
:My
BUILD
file:Observation
My Bazel test passes successfully.
Issues
This brings up 2 issues which are (probably) already reported:
metadata.json
files.The bigger issue is a question of inconsistency with specifying requirements. Does rules_python expect that all explicit and implicit dependencies be specified as a 'requirement'? In scenario 1, an implicit dependency was not declared but it was read nonetheless due to it being visible to Bazel. In scenario 2, it was needed to be specified a 'requirement' as well as explicitly added to 'requirements.txt' so that it could go ahead and install it.
If I didn't add it explicitly to 'requirements.txt', the error log was:
This behaviour makes sense but makes it super easy to miss-out on specifying implicit dependencies for a package without realising it.
The text was updated successfully, but these errors were encountered: