Skip to content

bug: imports attr misdocumented and misinterpretered when venv mode activated #3565

@rickeylev

Description

@rickeylev

There are two bugs with the imports attribute:

First, the docs say it is a "repo root relative" path -- this is incorrect. It is a target-relative path. i.e. //foo:bar setting . means add $repo/foo to sys.path. This is evident from reading the code, it essentially does:

join(main_repo, runfiles_short_path(ctx.label), imports_attr_value), e.g. join("_main", "../+somerepo/foo", ".")

Second, when the experimental_venvs_site_packages setting is enabled, py_library treats the value as a repo-relative path, not a target-relative path.

This makes using the same imports value unnecessarily difficult.

To fix:

  • Fix docs
  • Change py_library to treat it as target-relative

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-rulesIssues concerning core bin/test/lib rulestype: bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions