Back to Bazel

PyRuntimeInfo

docs/versions/7.2.0/rules/lib/providers/PyRuntimeInfo.mdx

9.1.09.8 KB
Original Source
<html devsite> <head> <meta name="project_path" value="/_project.yaml"> <meta name="book_path" value="/versions/7.2.0/_book.yaml"> </head> <body> <h1 class="page-title" id="modules.PyRuntimeInfo">PyRuntimeInfo</h1>

{% dynamic setvar source_file "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java" %} {% dynamic setvar version "7.2.0" %} {% dynamic setvar original_path "/rules/lib/providers/PyRuntimeInfo" %} {% include "_buttons.html" %}

<!-- {% raw %} -->

Contains information about a Python runtime, as returned by the <code>py_runtime</code>rule.<p>A Python runtime describes either a <em>platform runtime</em> or an <em>in-build runtime</em>. A platform runtime accesses a system-installed interpreter at a known path, whereas an in-build runtime points to a <code>File</code> that acts as the interpreter. In both cases, an "interpreter" is really any executable binary or wrapper script that is capable of running a Python script passed on the command line, following the same conventions as the standard CPython interpreter.

<h2>Members</h2> <ul> <li> <a href="#PyRuntimeInfo">PyRuntimeInfo</a> </li> <li> <a href="#bootstrap_template">bootstrap_template</a> </li> <li> <a href="#coverage_files">coverage_files</a> </li> <li> <a href="#coverage_tool">coverage_tool</a> </li> <li> <a href="#files">files</a> </li> <li> <a href="#interpreter">interpreter</a> </li> <li> <a href="#interpreter_path">interpreter_path</a> </li> <li> <a href="#python_version">python_version</a> </li> <li> <a href="#stub_shebang">stub_shebang</a> </li> </ul>
  <h2 id="PyRuntimeInfo">PyRuntimeInfo</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../providers/PyRuntimeInfo.html">PyRuntimeInfo</a> PyRuntimeInfo(interpreter_path=None, interpreter=None, files=None, coverage_tool=None, coverage_files=None, python_version, stub_shebang=None, bootstrap_template=None)</pre></p>

The <code>PyRuntimeInfo</code> constructor.

      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="PyRuntimeInfo.interpreter_path">
          <code>interpreter_path</code>
        </td>
        <td>
                      <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>;
                                 default is <code>None</code>

                      The value for the new object's <code>interpreter_path</code> field. Do not give a value for this argument if you pass in <code>interpreter</code>.
        </td>
      </tr>
              <tr>
        <td id="PyRuntimeInfo.interpreter">
          <code>interpreter</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/File.html">File</a>; or <code>None</code>;
                                 default is <code>None</code>

                      The value for the new object's <code>interpreter</code> field. Do not give a value for this argument if you pass in <code>interpreter_path</code>.
        </td>
      </tr>
              <tr>
        <td id="PyRuntimeInfo.files">
          <code>files</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/depset.html">depset</a> of <a class="anchor" href="../builtins/File.html">File</a>s; or <code>None</code>;
                                 default is <code>None</code>

                      The value for the new object's <code>files</code> field. Do not give a value for this argument if you pass in <code>interpreter_path</code>. If <code>interpreter</code> is given and this argument is <code>None</code>, <code>files</code> becomes an empty <code>depset</code> instead.
        </td>
      </tr>
              <tr>
        <td id="PyRuntimeInfo.coverage_tool">
          <code>coverage_tool</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/File.html">File</a>; or <code>None</code>;
                                 default is <code>None</code>

                      The value for the new object's <code>coverage_tool</code> field.
        </td>
      </tr>
              <tr>
        <td id="PyRuntimeInfo.coverage_files">
          <code>coverage_files</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/depset.html">depset</a> of <a class="anchor" href="../builtins/File.html">File</a>s; or <code>None</code>;
                                 default is <code>None</code>

                      The value for the new object's <code>coverage_files</code> field. Do not give a value for this argument if you do not also pass in <code>coverage_tool</code>.
        </td>
      </tr>
              <tr>
        <td id="PyRuntimeInfo.python_version">
          <code>python_version</code>
        </td>
        <td>
                                 required

                      The value for the new object's <code>python_version</code> field.
        </td>
      </tr>
              <tr>
        <td id="PyRuntimeInfo.stub_shebang">
          <code>stub_shebang</code>
        </td>
        <td>
                      <a class="anchor" href="../core/string.html">string</a>;
                                 default is <code>None</code>

                      The value for the new object's <code>stub_shebang</code> field. If None or not specified, <code>#!/usr/bin/env python3</code> is used.
        </td>
      </tr>
              <tr>
        <td id="PyRuntimeInfo.bootstrap_template">
          <code>bootstrap_template</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/File.html">File</a>; or <code>None</code>;
                                 default is <code>None</code>


        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="bootstrap_template">bootstrap_template</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/File.html">File</a> PyRuntimeInfo.bootstrap_template</pre></p>

The stub script template file to use. Should have %python_binary%, %workspace_name%, %main%, and %imports%. See @bazel_tools//tools/python:python_bootstrap_template.txt for more variables.


    <h2 id="coverage_files">coverage_files</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/depset.html">depset</a> PyRuntimeInfo.coverage_files</pre></p>

The files required at runtime for using <code>coverage_tool</code>. Will be <code>None</code> if no <code>coverage_tool</code> was provided.

     May return <code>None</code>.

    <h2 id="coverage_tool">coverage_tool</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/File.html">File</a> PyRuntimeInfo.coverage_tool</pre></p>

If set, this field is a <code>File</code> representing tool used for collecting code coverage information from python tests. Otherwise, this is <code>None</code>.

     May return <code>None</code>.

    <h2 id="files">files</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/depset.html">depset</a> PyRuntimeInfo.files</pre></p>

If this is an in-build runtime, this field is a <code>depset</code> of <code>File</code>s that need to be added to the runfiles of an executable target that uses this runtime (in particular, files needed by <code>interpreter</code>). The value of <code>interpreter</code> need not be included in this field. If this is a platform runtime then this field is <code>None</code>.

     May return <code>None</code>.

    <h2 id="interpreter">interpreter</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/File.html">File</a> PyRuntimeInfo.interpreter</pre></p>

If this is an in-build runtime, this field is a <code>File</code> representing the interpreter. Otherwise, this is <code>None</code>. Note that an in-build runtime can use either a prebuilt, checked-in interpreter or an interpreter built from source.

     May return <code>None</code>.

    <h2 id="interpreter_path">interpreter_path</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../core/string.html">string</a> PyRuntimeInfo.interpreter_path</pre></p>

If this is a platform runtime, this field is the absolute filesystem path to the interpreter on the target platform. Otherwise, this is <code>None</code>.

     May return <code>None</code>.

    <h2 id="python_version">python_version</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../core/string.html">string</a> PyRuntimeInfo.python_version</pre></p>

Indicates whether this runtime uses Python major version 2 or 3. Valid values are (only) <code>"PY2"</code> and <code>"PY3"</code>.


    <h2 id="stub_shebang">stub_shebang</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../core/string.html">string</a> PyRuntimeInfo.stub_shebang</pre></p>

"Shebang" expression prepended to the bootstrapping Python stub script used when executing <code>py_binary</code> targets.  Does not apply to Windows.
</body> </html> <!-- {% endraw %} -->