skillfed

bazel-runfiles

bazel-runfiles v2.3.1 5.1M downloads/30d#2,174 on PyPI685
Permissive license Active released

What it is and what it does

bazel-runfiles is a lookup library that helps Python code find and access files and binaries that Bazel has packaged as runfiles. When Bazel builds a Python binary or test, it stages dependencies and data files in a runfiles tree; this library provides the API to locate those files at runtime using either a manifest file or a directory structure, depending on the Bazel configuration.

The library is designed for use within Bazel-built projects. You create a Runfiles object, then call its Rlocation method with a workspace-qualified path to get the actual filesystem location of a runfile. It also supports setting up environment variables for subprocesses that need to access runfiles themselves. The implementation automatically detects whether to use manifest-based or directory-based lookup based on environment variables set by Bazel.

Use it for:

  • Access data files packaged alongside a Bazel-built Python binary at runtime.
  • Locate and run other Bazel-built binaries from within a Python test or application.
  • Set up environment variables for subprocesses spawned by a Bazel-built Python program so they can find their own runfiles.
  • Resolve workspace-qualified paths to actual filesystem paths in a Bazel build system.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Python API to locate and access runfiles (data files and binaries) built and packaged by Bazel, supporting both manifest-based and directory-based lookup strategies.

Yes, if you are building Python binaries or tests with Bazel and need to access runfiles at runtime. The package is actively maintained, has no dependencies, and carries a permissive license. It is essential infrastructure for Bazel-Python integration but only relevant within a Bazel project; installing it outside that context is unnecessary.

Install

bazel-runfiles on PyPI

pip

pip install bazel-runfiles

uv

uv add bazel-runfiles

poetry

poetry add bazel-runfiles

Installing bazel-runfiles

Before you install

Low install friction with no runtime dependencies. Active maintenance as of 2026-08-14 with recent releases. Stable production status.

License in practice

Permissive license (Apache Software License) allows use in commercial and proprietary projects without significant restrictions.

Quickstart

pip install bazel-runfiles

from runfiles import Runfiles

r = Runfiles.Create()
path = r.Rlocation("my_workspace/path/to/data.txt")
with open(path, "r") as f:
    contents = f.readlines()

Requires Python 3.7 or later. Only useful within a Bazel-built project that generates runfiles; requires proper Bazel environment variables to be set.

Verify before relying

  • Whether the package works correctly outside a Bazel-managed build environment or with older Bazel versions.
  • Performance characteristics when dealing with large numbers of runfiles or deeply nested directory structures.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 0 days since the last release
Last repo commit
First released
Downloads 5,069,741/month — #2,174 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: bazel_runfiles-2.3.1-py3-none-any.whl

Development Status :: 5 - Production/StableLicense :: OSI Approved :: Apache Software License

Tags

bazel runfiles lookupbazel data file accessbazel binary path resolutionbazel python runfilesbazel manifest-based file location
bazelbuild-system

More Build Tools packages