Skip to content

Starlarkify Python's build flags #3252

Open

Description

@gregestren

As part of Starlarkification, we plan to move all Python-related build flags defined in Bazel core code into rules_python.

This:

  • gives rules_python owners more complete control over Bazel's Python support
  • reduces the need for bazel / rules_python release synchronization
  • saves rules_python contributors from having to know how to patch Bazel.
  • saves Bazel devs from having to know the details of Python

This issue tracks the effort.

Also see:

Activity

  1. gregestren commented on Sep 8, 2025

    @gregestren
    ContributorAuthor

    I'm happy to have this assigned to me!

  2. rickeylev commented on Sep 17, 2025

    @rickeylev
    Collaborator

    FYI: I've added a CI job that uses bazel rolling. It won't shorten the iteration cycle, but you'll be able to more commit changes here with more confidence they work and won't regress. If they do, we'll see it in typical PRs. The CI job is non-blocking, so we can still merge, but it'll be much more visible.

  3. added a commit that references this issue on Sep 22, 2025
  4. added a commit that references this issue on Oct 15, 2025
  5. shayanhoshyari commented on Jan 8, 2026

    @shayanhoshyari
    Contributor

    @rickeylev @aignas Related to this, are the documentation now busted?

    The docs say https://rules-python.readthedocs.io/en/stable/api/rules_python/python/config_settings/index.html#experimental_python_import_all_repositories

    flag --//python/config_settings:experimental_python_import_all_repositories
    Controls whether repository directories are added to the import path.

    When enabled, the top-level directories in the runfiles root directory (which are presumbed to be repository directories) are added to the Python import search path.

    It’s recommended to set this to false to avoid external dependencies unexpectedly interferring with import searching.

    Values;

    true (default)

    false

    This flag replaces the Bazel builtin --experimental_python_import_all_repositories flag.

    Added in version 1.7.0.

    However, I tried setting it and nothing happened in .1.8.0-rc1. Only setting the bazel's own --experimental_python_import_all_repositories worked. Looking at the code, seems thatread_possibly_native_flag(...) only reads the rules_python variant if --incompatible_remove_ctx_bazel_py_fragment is set (which needs bazel > 9), but the doc does not mention this at all.

  6. gregestren commented on Jan 8, 2026

    @gregestren
    ContributorAuthor

    FWIW I'd expect --experimental_python_import_all_repositories syntax to work with any Bazel version. Bazel 9+ should automatically route to --//python/config_settings:experimental_python_import_all_repositories. Let us know if you see otherwise.

    Acknowledged the documentation is a separate concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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