Skip to content

Target aliases don't work with annotations in pip_parse() #1311

@georgiyekkert

Description

@georgiyekkert

Affected Rule

pip_parse

Is this a regression?

Didn't try this in other versions

Description

if you pass both arguments incompatible_generate_aliases and annotations to pip_parse(), specified annotations will be ignored.

🔬 Minimal Reproduction

  
NUMPY_ANNOTATIONS = {
    "numpy": package_annotation(
        additive_build_content = """\
filegroup(
    name = "includes",
    srcs = glob(["site-packages/numpy/core/include/**/*.h"]),
)
cc_library(
    name = "numpy_headers",
    hdrs = [":includes"],
    strip_include_prefix="site-packages/numpy/core/include/",
)
""",
    ),
}

pip_parse(
    name = "pypi",
    annotations = NUMPY_ANNOTATIONS,
    incompatible_generate_aliases = True,
    python_interpreter_target = interpreter,
    requirements = "//:requirements_lock.txt",
)
  

🔥 Exception or Error

When you try to use the annotated cc_library, it will just fail, e.g.
no such target '@pypi//numpy:numpy_headers': target 'numpy_headers' not declared in package 'numpy'

Without incompatible_generate_aliases it works as intended.

🌍 Your Environment

Operating System:

  
gLinux
  

Output of bazel version:

  
Build label: 6.1.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Mar 6 17:09:47 2023 (1678122587)
Build timestamp: 1678122587
Build timestamp as int: 1678122587
  

Rules_python version:

  
0.23.1
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    Can Close?Will close in 30 days if there is no new activitytype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions