bazel-contrib / bazel-contrib/rules_python

FR: add PyInfo.direct_imports

Open
#2,942 0 comments 0 reactions 0 assignees View on GitHub
core-rules type: feature request
Dominant language
Starlark
Stars
688
Forks
721
Avg merge
15h 7m
Merged PRs (30d)
76

Description

Currently, the PyInfo's imports field returns all imports paths defined in a target, combined with the ones from its transitive dependencies, as defined here

There's no way to retrieve the direct import paths. It would be useful for IDE support, where we typically read data about a large number of targets and dependencies between them. In that case, we pessimistically would end up in n^2 import entries when reading that, because of depset expansion.

Alternatively IDEs could read just direct_imports and deps fields, and map them to their internal graph. Full transitive imports could still be resolved on demand, based on deps

What underlying problem are you trying to solve with this feature?

Avoid depset flattening when reading both imports and deps from PyInfo, according to https://bazel.build/rules/performance#avoid-depset-to-list

(originally from https://github.com/bazelbuild/bazel/issues/20449 by @tpasternak )

Contributor guide

Open the contributing guide

Research direction

Start by locating the PyInfo provider and the existing imports and deps fields, then read the linked Bazel guidance on avoiding depset-to-list conversion. Done means exposing direct import paths without flattening transitive dependencies while preserving the existing transitive imports behavior; no specific file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.