Subpar
Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.
Install / Use
/learn @google/SubparREADME
Subpar (deprecated)
Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.
Status
This project is unmaintained and considered deprecated.
Historically, subpar was the only way to produce a deployable Python artifact in Bazel.
This is no longer true; --build_python_zip and the python_zip_file output_group allows you to create executable Python zip artifacts with the standard py_binary rule.
rules_docker can also be used to build container images that launch py_binary.
Setup
- Add the following to your WORKSPACE file:
git_repository(
name = "subpar",
remote = "https://github.com/google/subpar",
tag = "1.0.0",
)
- Add the following to the top of any BUILD files that declare
par_binary()rules:
load("@subpar//:subpar.bzl", "par_binary")
Usage
par_binary() is a drop-in replacement for py_binary() in your BUILD files
that also builds a self-contained, single-file executable for the application,
with a .par file extension.
To build the .par file associated with a par_binary(name=myname) rule, do
bazel build //my/package:myname.par
The .par file is created alongside the python stub and .runfiles directories that py_binary() creates, but is independent of them. It can be copied to other directories or machines, and executed directly without needing the .runfiles directory. The body of the .par file contains all the srcs, deps, and data files listed.
Limitations:
- C extension modules in 'deps' is not yet supported
- Automatic re-extraction of '.runfiles' is not yet supported
- Does not include a copy of the Python interpreter ('hermetic .par')
Example
Given a BUILD file with the following:
load("@subpar//:subpar.bzl", "par_binary")
par_binary(
name = 'foo',
srcs = ['foo.py', 'bar.py'],
deps = ['//baz:some_py_lib'],
data = ['quux.dat'],
)
Run the following build command:
bazel build //package:foo.par
This results in the following files being created by bazel build:
bazel-bin/
package/
foo
foo.par
foo.runfiles/
...
The .par file can be copied, moved, or renamed, and still run like a compiled executable file:
$ scp bazel-bin/package/foo.par my-other-machine:foo.par
$ ssh my-other-machine ./foo.par
System Requirements
- Python Versions: CPython versions 2.7.6+
- Operating Systems: Debian-derived Linux, including Ubuntu and Goobuntu.
DISCLAIMER
This is not an official Google product, it is just code that happens to be owned by Google.
Related Skills
claude-opus-4-5-migration
107.2kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
346.4kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
TrendRadar
50.7k⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
mcp-for-beginners
15.8kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
