Skip to content

Commit c65b3dd

Browse files
committed
add docs
1 parent 41011be commit c65b3dd

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

python/private/py_executable.bzl

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,15 @@ def _is_tool_config(ctx):
18171817
return py_internal.is_tool_configuration(ctx)
18181818

18191819
def _add_provider_default_info(providers, ctx, *, executable, default_outputs, runfiles_details):
1820+
"""Adds the DefaultInfo provider.
1821+
1822+
Args:
1823+
providers: list of providers to append to.
1824+
ctx: The rule ctx.
1825+
executable: File; the target's executable file.
1826+
default_outputs: depset of Files; the files for DefaultInfo.files
1827+
runfiles_details: runfiles that will become the default and data runfiles.
1828+
"""
18201829
providers.append(DefaultInfo(
18211830
executable = executable,
18221831
files = default_outputs,
@@ -1831,9 +1840,24 @@ def _add_provider_default_info(providers, ctx, *, executable, default_outputs, r
18311840
))
18321841

18331842
def _add_provider_instrumented_files_info(providers, ctx):
1843+
"""Adds the InstrumentedFilesInfo provider.
1844+
1845+
Args:
1846+
providers: list of providers to append to.
1847+
ctx: The rule ctx.
1848+
"""
18341849
providers.append(create_instrumented_files_info(ctx))
18351850

18361851
def _add_provider_run_environment_info(providers, ctx, inherited_environment):
1852+
"""Adds the RunEnvironmentInfo provider.
1853+
1854+
Args:
1855+
providers: list of providers to append to.
1856+
ctx: The rule ctx.
1857+
inherited_environment: list of strings; Environment variable names
1858+
that should be inherited from the environment the executuble
1859+
is run within.
1860+
"""
18371861
expanded_env = {}
18381862
for key, value in ctx.attr.env.items():
18391863
expanded_env[key] = _py_builtins.expand_location_and_make_variables(
@@ -1862,6 +1886,21 @@ def _add_provider_py_executable_info(
18621886
venv_interpreter_runfiles,
18631887
venv_interpreter_symlinks,
18641888
venv_python_exe):
1889+
"""Adds the PyExecutableInfo provider.
1890+
1891+
Args:
1892+
providers: list of providers to append to.
1893+
app_runfiles: runfiles; the runfiles for the application (deps, etc).
1894+
build_data_file: File; a file with build stamp information.
1895+
interpreter_args: list of strings; arguments to pass to the interpreter.
1896+
interpreter_path: str; path to the Python interpreter.
1897+
main: File; the main .py entry point.
1898+
runfiles_without_exe: runfiles; the default runfiles, but without the executable.
1899+
stage2_bootstrap: File; the stage 2 bootstrap script.
1900+
venv_interpreter_runfiles: runfiles; runfiles specific to the interpreter for the venv.
1901+
venv_interpreter_symlinks: depset[ExplicitSymlink]; interpreter-specific symlinks to create for the venv.
1902+
venv_python_exe: File; the python executable in the venv.
1903+
"""
18651904
providers.append(PyExecutableInfo(
18661905
app_runfiles = app_runfiles,
18671906
build_data_file = build_data_file,
@@ -1876,6 +1915,12 @@ def _add_provider_py_executable_info(
18761915
))
18771916

18781917
def _add_provider_py_runtime_info(providers, runtime_details):
1918+
"""Adds the PyRuntimeInfo provider.
1919+
1920+
Args:
1921+
providers: list of providers to append to.
1922+
runtime_details: struct of runtime information; see _get_runtime_details()
1923+
"""
18791924
# TODO - The effective runtime can be None for Windows + auto detecting toolchain.
18801925
# This can be removed once that's fixed; see maybe_get_runtime_from_ctx().
18811926
if runtime_details.effective_runtime:
@@ -1903,6 +1948,14 @@ def _add_provider_py_runtime_info(providers, runtime_details):
19031948
))
19041949

19051950
def _add_provider_py_cc_link_params_info(providers, cc_info):
1951+
"""Adds the PyCcLinkParamsInfo provider.
1952+
1953+
Args:
1954+
providers: list of providers to append to.
1955+
cc_info: optional CcInfo; Linking information to propagate as
1956+
PyCcLinkParamsInfo. Note that only the linking information
1957+
is propagated, not the whole CcInfo.
1958+
"""
19061959
# TODO(b/163083591): Remove the PyCcLinkParamsInfo once binaries-in-deps
19071960
# are cleaned up.
19081961
if cc_info:
@@ -1920,6 +1973,27 @@ def _add_provider_py_info(
19201973
implicit_pyc_files,
19211974
implicit_pyc_source_files,
19221975
imports):
1976+
"""Adds the PyInfo provider.
1977+
1978+
Args:
1979+
providers: list of providers to append to.
1980+
ctx: The rule ctx.
1981+
original_sources: `depset[File]` the direct `.py` sources for the
1982+
target that were the original input sources.
1983+
required_py_files: `depset[File]` the direct, `.py` sources for the
1984+
target that **must** be included by downstream targets. This should
1985+
only be Python source files. It should not include pyc files.
1986+
required_pyc_files: `depset[File]` the direct `.pyc` files this target
1987+
produces.
1988+
implicit_pyc_files: `depset[File]` pyc files that are only used if pyc
1989+
collection is enabled.
1990+
implicit_pyc_source_files: `depset[File]` source files for implicit pyc
1991+
files that are used when the implicit pyc files are not.
1992+
imports: depset of strings; the import paths to propagate
1993+
1994+
Returns:
1995+
tuple of (PyInfo, BuiltinPyInfo|None).
1996+
"""
19231997
py_info, builtin_py_info = create_py_info(
19241998
ctx,
19251999
original_sources = original_sources,
@@ -1935,6 +2009,13 @@ def _add_provider_py_info(
19352009
return py_info, builtin_py_info
19362010

19372011
def _add_provider_output_group_info(providers, py_info, output_groups):
2012+
"""Adds the OutputGroupInfo provider.
2013+
2014+
Args:
2015+
providers: list of providers to append to.
2016+
py_info: PyInfo; the PyInfo provider.
2017+
output_groups: dict[str, depset[File]]; used to create OutputGroupInfo
2018+
"""
19382019
providers.append(create_output_group_info(py_info.transitive_sources, output_groups))
19392020

19402021

0 commit comments

Comments
 (0)