All Projects → google → Subpar

google / Subpar

Licence: apache-2.0
Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Subpar

rules node
Node rules for Bazel (unsupported)
Stars: ✭ 51 (-89.17%)
Mutual labels:  bazel
Bazel Remote
A remote cache for Bazel
Stars: ✭ 260 (-44.8%)
Mutual labels:  bazel
Angular Bazel Example
MOVED to the bazel nodejs monorepo 👉
Stars: ✭ 354 (-24.84%)
Mutual labels:  bazel
bazel-packages
[WIP] Collection of Bazel packages
Stars: ✭ 14 (-97.03%)
Mutual labels:  bazel
blackjack
Build cargo dependencies with Bazel
Stars: ✭ 34 (-92.78%)
Mutual labels:  bazel
Rules typescript
MOVED to https://github.com/bazelbuild/rules_nodejs/tree/3.x/third_party/github.com/bazelbuild/rules_typescript
Stars: ✭ 280 (-40.55%)
Mutual labels:  bazel
bazel.cmake
bazel.cmake mimics the behavior of bazel to simplify the usability of CMake
Stars: ✭ 38 (-91.93%)
Mutual labels:  bazel
Examples
Examples for Bazel
Stars: ✭ 412 (-12.53%)
Mutual labels:  bazel
example-bazel-monorepo
🌿💚 Example Bazel-ified monorepo, supporting Golang, Java, Python, Scala, and Typescript
Stars: ✭ 213 (-54.78%)
Mutual labels:  bazel
Bazel Buildfarm
Bazel remote caching and execution service
Stars: ✭ 352 (-25.27%)
Mutual labels:  bazel
rules sh
Shell rules for Bazel
Stars: ✭ 18 (-96.18%)
Mutual labels:  bazel
rules clojure
Clojure rules for Bazel
Stars: ✭ 27 (-94.27%)
Mutual labels:  bazel
Sandboxfs
A virtual file system for sandboxing
Stars: ✭ 286 (-39.28%)
Mutual labels:  bazel
gobazel
gobazel is a tool to help golang bazel developers to map bazel's folder structure to golang's standard folder structure, through FUSE (thus only works for Linux and MacOS users).
Stars: ✭ 28 (-94.06%)
Mutual labels:  bazel
Squzy
Squzy - is a high-performance open-source monitoring, incident and alert system written in Golang with Bazel and love.
Stars: ✭ 359 (-23.78%)
Mutual labels:  bazel
ng-qt
Build extremely powerful and efficient native cross-platform desktop applications using Angular and NodeGUI
Stars: ✭ 14 (-97.03%)
Mutual labels:  bazel
Rules scala
Scala rules for Bazel
Stars: ✭ 269 (-42.89%)
Mutual labels:  bazel
Rules foreign cc
Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja)
Stars: ✭ 418 (-11.25%)
Mutual labels:  bazel
Tulsi
An Xcode Project Generator For Bazel
Stars: ✭ 365 (-22.51%)
Mutual labels:  bazel
Bazel
a fast, scalable, multi-language and extensible build system
Stars: ✭ 17,790 (+3677.07%)
Mutual labels:  bazel

Subpar

Build Status

Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.

Status

Subpar is currently owned by the maintainers of bazelbuild/rules_python, which depends on it. It is not being actively developed beyond what is needed to keep compatibility with rules_python.

Historically, subpar was the only way to produce a deployable Python artifact in Bazel. This is no longer quite true; --build_python_zip allows you to create executable Python zip artifacts with the standard py_binary rule. Subpar still supports some use cases --build_python_zip doesn't: In particular, it allows you to build archives of specific targets without using a global command-line flag, and in some cases the archives can run in-place without extraction.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].