commit | 07ff5feb7c7b113eea593eb6ec50b51099cf0261 | [log] [tgz] |
---|---|---|
author | Ali <shariat@users.noreply.github.com> | Thu Apr 26 11:10:40 2018 -0700 |
committer | Douglas Greiman <dgreiman@google.com> | Thu Apr 26 11:10:40 2018 -0700 |
tree | 07ae74746a7a78104f97cd88042aef876d64d786 | |
parent | 751ca6725d3888cb6922906ffd47627804eaeb83 [diff] |
make python_archive compatible with python 2.6 (#80)
Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.
git_repository( name = "subpar", remote = "https://github.com/google/subpar", tag = "1.0.0", )
par_binary()
rules:load("@subpar//:subpar.bzl", "par_binary")
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.
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
This is not an official Google product, it is just code that happens to be owned by Google.