blob: d1fc5d19da5234b2b082dafc75b972d0880109e7 [file] [log] [blame]
<!--
Documentation generated by Skydoc
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Build self-contained python executables.</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700" type="text/css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.1/material.green-light_blue.min.css">
<script defer src="https://code.getmdl.io/1.1.1/material.min.js"></script>
<link rel="stylesheet" href="./main.css">
</head>
<body>
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer
mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<span class="mdl-layout-title">Build self-contained python executables.</span>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">Bazel</span>
<nav class="drawer-nav">
<ul class="drawer-nav">
<li><a href="./index.html">Overview</a></li>
<li>
<a href="./debug.html">debug Rules</a>
<ul>
</ul>
</li>
<li>
<a href="./subpar.html">Build self-contained python executables.</a>
<ul>
<li>
<a href="./subpar.html#parfile">
parfile
</a>
</li>
<li>
<a href="./subpar.html#parfile_test">
parfile_test
</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<main class="mdl-layout__content">
<div class="page-content">
<h1>Build self-contained python executables.</h1>
<nav class="toc">
<h2>Rules</h2>
<ul>
<li><a href="#parfile">parfile</a></li>
<li><a href="#parfile_test">parfile_test</a></li>
</ul>
<h2>Macros</h2>
<ul>
<li><a href="#par_binary">par_binary</a></li>
<li><a href="#par_test">par_test</a></li>
</ul>
</nav>
<hr>
<h2 id="par_binary">par_binary</h2>
<pre>par_binary(<a href="#par_binary.name">name</a>, <a href="#par_binary.**kwargs">**kwargs</a>)</pre>
<p>An executable Python program.</p>
<p>par_binary() is a drop-in replacement for py_binary() that also
builds a self-contained, single-file executable for the
application, with a .par file extension.</p>
<p>The <code>name</code> attribute shouldn't include the <code>.par</code> file extension,
it's added automatically. So, for a rule like
<code>par_binary(name="myname")</code>, build the file <code>myname.par</code> by doing
<code>bazel build //mypackage:myname.par</code></p>
<p>See <a href="http://www.bazel.io/docs/be/python.html#py_binary">py_binary</a>
for arguments and usage.</p>
<h3 id="par_binary_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="par_binary.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>A unique name for this rule.</p>
</td>
</tr>
<tr id="par_binary.**kwargs">
<td><code>**kwargs</code></td>
<td>
<p><code>Unknown; Optional</code></p>
</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="par_test">par_test</h2>
<pre>par_test(<a href="#par_test.name">name</a>, <a href="#par_test.**kwargs">**kwargs</a>)</pre>
<p>An executable Python test.</p>
<p>Just like par_binary, but for py_test instead of py_binary. Useful if you
specifically need to test a module's behaviour when used in a .par binary.</p>
<h3 id="par_test_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="par_test.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>A unique name for this rule.</p>
</td>
</tr>
<tr id="par_test.**kwargs">
<td><code>**kwargs</code></td>
<td>
<p><code>Unknown; Optional</code></p>
</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="parfile">parfile</h2>
<pre>parfile(<a href="#parfile.name">name</a>, <a href="#parfile.src">src</a>, <a href="#parfile.compiler">compiler</a>, <a href="#parfile.compiler_args">compiler_args</a>, <a href="#parfile.default_python_version">default_python_version</a>, <a href="#parfile.imports">imports</a>, <a href="#parfile.main">main</a>, <a href="#parfile.zip_safe">zip_safe</a>)</pre>
<p>A self-contained, single-file Python program, with a .par file extension.</p>
<p>You probably want to use par_binary() instead of this.</p>
<p>TODO(b/27502830): A directory foo.par.runfiles is also created. This
is a bug, don't use or depend on it.</p>
<h3 id="parfile_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="parfile.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>A unique name for this rule.</p>
</td>
</tr>
<tr id="parfile.src">
<td><code>src</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Required</code></p>
<p>A py_binary() target</p>
</td>
</tr>
<tr id="parfile.compiler">
<td><code>compiler</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Optional; Default is //compiler:compiler.par</code></p>
<p>Internal use only.</p>
</td>
</tr>
<tr id="parfile.compiler_args">
<td><code>compiler_args</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
</td>
</tr>
<tr id="parfile.default_python_version">
<td><code>default_python_version</code></td>
<td>
<p><code>String; Required</code></p>
<p>A string specifying the default Python major version to use when building this par file.</p>
<p>See <a href="http://www.bazel.io/docs/be/python.html#py_binary.default_python_version">py_binary.default_python_version</a></p>
</td>
</tr>
<tr id="parfile.imports">
<td><code>imports</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>List of import directories to be added to the PYTHONPATH.</p>
<p>See <a href="http://www.bazel.io/docs/be/python.html#py_binary.imports">py_binary.imports</a></p>
</td>
</tr>
<tr id="parfile.main">
<td><code>main</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Required</code></p>
<p>The name of the source file that is the main entry point of
the application.</p>
<p>See <a href="http://www.bazel.io/docs/be/python.html#py_binary.main">py_binary.main</a></p>
</td>
</tr>
<tr id="parfile.zip_safe">
<td><code>zip_safe</code></td>
<td>
<p><code>Boolean; Optional; Default is True</code></p>
<p>Whether to import Python code and read datafiles directly
from the zip archive. Otherwise, if False, all files are
extracted to a temporary directory on disk each time the
par file executes.</p>
</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="parfile_test">parfile_test</h2>
<pre>parfile_test(<a href="#parfile_test.name">name</a>, <a href="#parfile_test.src">src</a>, <a href="#parfile_test.compiler">compiler</a>, <a href="#parfile_test.compiler_args">compiler_args</a>, <a href="#parfile_test.default_python_version">default_python_version</a>, <a href="#parfile_test.imports">imports</a>, <a href="#parfile_test.main">main</a>, <a href="#parfile_test.zip_safe">zip_safe</a>)</pre>
<p>Identical to par_binary, but the rule is marked as being a test.</p>
<p>You probably want to use par_test() instead of this.</p>
<h3 id="parfile_test_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="parfile_test.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>A unique name for this rule.</p>
</td>
</tr>
<tr id="parfile_test.src">
<td><code>src</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Required</code></p>
<p>A py_binary() target</p>
</td>
</tr>
<tr id="parfile_test.compiler">
<td><code>compiler</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Optional; Default is //compiler:compiler.par</code></p>
<p>Internal use only.</p>
</td>
</tr>
<tr id="parfile_test.compiler_args">
<td><code>compiler_args</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
</td>
</tr>
<tr id="parfile_test.default_python_version">
<td><code>default_python_version</code></td>
<td>
<p><code>String; Required</code></p>
<p>A string specifying the default Python major version to use when building this par file.</p>
<p>See <a href="http://www.bazel.io/docs/be/python.html#py_binary.default_python_version">py_binary.default_python_version</a></p>
</td>
</tr>
<tr id="parfile_test.imports">
<td><code>imports</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>List of import directories to be added to the PYTHONPATH.</p>
<p>See <a href="http://www.bazel.io/docs/be/python.html#py_binary.imports">py_binary.imports</a></p>
</td>
</tr>
<tr id="parfile_test.main">
<td><code>main</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Required</code></p>
<p>The name of the source file that is the main entry point of
the application.</p>
<p>See <a href="http://www.bazel.io/docs/be/python.html#py_binary.main">py_binary.main</a></p>
</td>
</tr>
<tr id="parfile_test.zip_safe">
<td><code>zip_safe</code></td>
<td>
<p><code>Boolean; Optional; Default is True</code></p>
<p>Whether to import Python code and read datafiles directly
from the zip archive. Otherwise, if False, all files are
extracted to a temporary directory on disk each time the
par file executes.</p>
</td>
</tr>
</tbody>
</table>
</div>
<footer class="mdl-mini-footer">
<div class="mdl-mini-footer__left-section">
<div class="mdl-logo">Bazel</div>
<ul class="mdl-mini-footer__link-list">
<li><a href="https://bazel.build">Home</a></li>
<li><a href="https://github.com/bazelbuild">GitHub</a></li>
</ul>
</div>
</footer>
</main>
</div>
</body>
</html>