Skip to content
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

[Bug]: py_binary seems to ignore nonexistent dependencies #316

Closed
mboulton-fathom opened this issue Mar 21, 2024 · 0 comments · Fixed by #318
Closed

[Bug]: py_binary seems to ignore nonexistent dependencies #316

mboulton-fathom opened this issue Mar 21, 2024 · 0 comments · Fixed by #318
Labels
bug Something isn't working untriaged Requires traige

Comments

@mboulton-fathom
Copy link

mboulton-fathom commented Mar 21, 2024

What happened?

py_binary from rules_py seems to ignore non-existent dependencies, resulting in no error being raised if you try to use a py_library in the 'deps' field when the dependency doesn't actually exist

Version

Development (host) and target OS/architectures:

Linux

Output of bazel --version:

bazel 7.1.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "rules_python", version = "0.31.0")
bazel_dep(name = "aspect_rules_py", version = "0.7.1")

Language(s) and/or frameworks involved:

Just Python

How to reproduce

Reproduction repo here: https://github.com/mboulton-fathom/rules_py_bug_repro

With this build file:

load("@aspect_rules_py//py:defs.bzl", new_py_binary = "py_binary")
load("@rules_python//python:defs.bzl", old_py_binary = "py_binary")

old_py_binary(
    name = "old",
    srcs = [":main.py"],
    deps = [":dldfk"],
)

new_py_binary(
    name = "new",
    srcs = [":main.py"],
    deps = [":dldfk"],
)

Using py_binary from rules_python:

bazel run //:old
INFO: Invocation ID: 2e19ba83-6202-4fe0-a2f3-10cf2474e919
ERROR: /home/michael/code/rules_py_bug_repro/BUILD.bazel:4:14: in deps attribute of py_binary rule //:old: rule '//:dldfk' does not exist. Since this rule was created by the macro 'py_binary', the error might have been caused by the macro implementation
ERROR: /home/michael/code/rules_py_bug_repro/BUILD.bazel:4:14: Analysis of target '//:old' failed

Using py_binary from rules_py:

bazel run //:new
INFO: Invocation ID: 6fc985ed-7488-43fb-8b1d-36d29d1bfd11
INFO: Analyzed target //:new (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:new up-to-date:
  bazel-bin/new
  bazel-bin/new.venv.pth
INFO: Elapsed time: 0.044s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/new
Hello

This causes all kinds of confusion if you have a typo in a dependency

Any other information?

No response

@mboulton-fathom mboulton-fathom added the bug Something isn't working label Mar 21, 2024
@github-actions github-actions bot added the untriaged Requires traige label Mar 21, 2024
alexeagle pushed a commit that referenced this issue Mar 24, 2024
Remove the `allow_files = True` from the `deps` attr of `py_libaray`
(they are inherited by `py_binary`). This allowed users to place
non-existent targets into `deps`.

Closes #316
@github-project-automation github-project-automation bot moved this to ✅ Done in Open Source Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant