Skip to content

pipstar regression: Labels duplicated in whl_library_targets_from_requires #3511

@thirtyseven

Description

@thirtyseven

🐞 bug report

Affected Rule

The issue is caused by the rule: pip.parse

Is this a regression?

Yes, the previous version in which this bug was not present was: 1.7.0

Description

Some pip packages fail to build in 1.8.0-rc3 with errors like:

ERROR: /private/var/tmp/_bazel_tkaplan/2ee08b28e31e216c71c3665814b9e6fa/external/rules_python++pip+py3deps_310_ray_cp310_cp310_macosx_11_0_arm64_6f221b14/BUILD.bazel:6:34: in deps attribute of py_library rule @@rules_python++pip+py3deps_310_ray_cp310_cp310_macosx_11_0_arm64_6f221b14//:pkg: Label '@@rules_python++pip+py3deps//grpcio:pkg' is duplicated. Since this rule was created by the macro 'whl_library_targets_from_requires', the error might have been caused by the macro implementation
ERROR: /private/var/tmp/_bazel_tkaplan/2ee08b28e31e216c71c3665814b9e6fa/external/rules_python++pip+py3deps_310_ray_cp310_cp310_macosx_11_0_arm64_6f221b14/BUILD.bazel:6:34: Analysis of target '@@rules_python++pip+py3deps_310_ray_cp310_cp310_macosx_11_0_arm64_6f221b14//:pkg' (config: 854dc54) failed

🔬 Minimal Reproduction

MODULE.bazel:

bazel_dep(name = "rules_python", version = "1.8.0-rc3")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    python_version = "3.10",
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    hub_name = "pypi",
    python_version = "3.10",
    requirements_by_platform = {
        "//:requirements_linux.txt": "linux_*",
        "//:requirements_mac.txt": "osx_*",
    },
)
use_repo(pip, "pypi")

uv = use_extension(
    "@rules_python//python/uv:uv.bzl",
    "uv",
    dev_dependency = True,
)

BUILD.bazel:

load("@rules_python//python/uv:lock.bzl", "lock")

DEFAULT_UV_ARGS = [
    "--index-strategy=unsafe-best-match",
]

# Generate lock files for default Python version
lock(
    name = "requirements_mac",
    srcs = [":requirements.in"],
    out = "requirements_mac.txt",
    args = DEFAULT_UV_ARGS + ["--python-platform=macos"],
)

lock(
    name = "requirements_linux",
    srcs = [":requirements.in"],
    out = "requirements_linux.txt",
    args = DEFAULT_UV_ARGS + ["--python-platform=linux"],
)

requirements.in:

ray[client,data,serve,train]==2.44.1

Run:

bazel run :requirements_mac.update
bazel run :requirements_linux.update
bazel build @pypi//...

🔥 Exception or Error




bazel build @pypi//...     
ERROR: /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_ray/BUILD.bazel:6:34: in data attribute of filegroup rule @@rules_python++pip+pypi_310_ray//:whl: Label '@@rules_python++pip+pypi//grpcio:whl' is duplicated. Since this rule was created by the macro 'whl_library_targets_from_requires', the error might have been caused by the macro implementation
ERROR: /private/var/tmp/_bazel_tkaplan/4c0c47e0a98a460290f6962870658619/external/rules_python++pip+pypi_310_ray/BUILD.bazel:6:34: Analysis of target '@@rules_python++pip+pypi_310_ray//:whl' (config: 7f8856b) failed
Use --verbose_failures to see the command lines of failed build steps.
ERROR: Analysis of target '@@rules_python++pip+pypi//ray:whl' failed; build aborted: Analysis failed
INFO: Elapsed time: 9.578s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

🌍 Your Environment

Operating System:

  
Mac OS 15.7.3
  

Output of bazel version:

  
8.5.1
  

Rules_python version:

  
1.8.0-rc3
  

Anything else relevant?
The error does not occur with --repo_env=RULES_PYTHON_ENABLE_PIPSTAR=0

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