Skip to content

example/build_file_generation/ is broken #1160

@ofey404

Description

@ofey404

🐞 bug report

Affected Rule

I'm new to rule_python, but the example cannot run.

https://github.com/bazelbuild/rules_python/tree/main/examples/build_file_generation

Is this a regression?

No.

Description

The example/build_file_generation/ can not run.

🔬 Minimal Reproduction

I save the spot in this commit of my fork:

ofey404@7a10e85

image

I use bazelisk with USE_BAZEL_VERSION=5.4.0.

I follow the instruction in README.md of example:

Or, try importing the `requests` library in `__init__.py`.
You'll see that `deps = ["@pip//pypi__requests"]` is automatically
added to the `py_library` target in the `BUILD` file.

But requests package is not found.

bazel run //:gazelle
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:gazelle up-to-date:
  bazel-bin/gazelle-runner.bash
  bazel-bin/gazelle
INFO: Elapsed time: 0.297s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
gazelle: ERROR: failed to validate dependencies for target "@build_file_generation_example//:build_file_generation": "requests" at line 15 from "__init__.py" is an invalid dependency: possible solutions:
        1. Add it as a dependency in the requirements.txt file.
        2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.
        3. Ignore it with a comment '# gazelle:ignore requests' in the Python file.

🔥 Exception or Error

At least the example should work, so that newcomers could learn how to use it.

🌍 Your Environment

Operating System:

cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Output of bazel version:

bazel version
Bazelisk version: v1.13.2
Build label: 5.4.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 15 16:14:25 2022 (1671120865)
Build timestamp: 1671120865
Build timestamp as int: 1671120865

Rules_python version:

latest.

git log HEAD
commit 7a10e85844bf8acdc9f24220a2d529975a9f5ca7 (HEAD -> main, ofey404/main)
Author: Ofey Chan <ofey206@gmail.com>
Date:   Mon Apr 10 17:32:20 2023 +0800

    stage: reproduce error on example

commit b80b8fde601f3bee9a4174c4aef03a3811912b93 (origin/main, origin/HEAD)
Author: Mathieu Sabourin <mathieu.c.sabourin@gmail.com>
Date:   Fri Apr 7 23:52:41 2023 -0700

    fix: respect kind mapping (#1158)

Anything else relevant?

Nope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions