33::::{envvar} RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS
44
55This variable allows for additional arguments to be provided to the Python interpreter
6- at bootstrap time when the ` bash ` bootstrap is used . If
6+ at bootstrap time. If
77` RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS ` were provided as ` -Xaaa ` , then the command
88would be:
99
@@ -20,6 +20,12 @@ in the command executed being:
2020python /path/to/debugger.py --port 12345 --file /path/to/file.py
2121```
2222
23+ The Bash entry point parses the first line with ` read -a ` and places these
24+ arguments before the target's ` interpreter_args ` . Python entry points use
25+ ` shlex.split ` and place them after the target arguments. This preserves each
26+ entry point's existing precedence. The variable is removed before the
27+ application runs, so nested launchers do not apply it again.
28+
2329:::{seealso}
2430The {bzl: obj }` interpreter_args ` attribute.
2531
@@ -31,13 +37,16 @@ The guide on {any}`How to integrate a debugger`
3137:::{versionchanged} 1.7.0
3238Support added for {bzl: flag }` --bootstrap_impl=system_python ` .
3339:::
40+ :::{versionchanged} VERSION_NEXT_PATCH
41+ Target and additional interpreter arguments also apply to ` python app.zip ` .
42+ :::
3443
3544::::
3645
3746:::{envvar} RULES_PYTHON_BOOTSTRAP_VERBOSE
3847
3948When ` 1 ` , debug information about bootstrapping of a program is printed to
40- stderr.
49+ stderr. Temporary runtime directories are retained to help diagnose failures.
4150:::
4251
4352:::{envvar} RULES_PYTHON_BZLMOD_DEBUG
@@ -57,23 +66,61 @@ be removed in a subsequent major `rules_python` version. Defaults to `0` if unse
5766Directory to use as the root for creating files necessary for bootstrapping so
5867that a binary can run.
5968
60- Only applicable when {bzl: flag }` --venvs_use_declare_symlink=no ` is used.
61-
62- When set, a binary will attempt to find a unique, reusable, location within this
63- directory for the files it needs to create to aid startup. The files may not be
64- deleted upon program exit; it is the responsibility of the caller to ensure
65- cleanup.
66-
67- Manually specifying the directory is useful to lower the overhead of
68- extracting/creating files on every program execution. By using a location
69- outside /tmp, longer lived programs don't have to worry about files in /tmp
70- being cleaned up by the OS.
71-
72- If not set, then a temporary directory will be created and deleted upon program
73- exit.
69+ Applies to runtime-created virtual environments and to ` py_zipapp_binary ` and
70+ ` py_zipapp_test ` . Legacy executable ZIPs always use temporary extraction; their
71+ virtual environments cannot persist because they refer to that extraction.
72+
73+ When set, a binary reuses files beneath this directory. The caller owns their
74+ lifetime and must arrange cleanup. ZIP applications prepare a unique staging
75+ directory and publish it only after setup succeeds. Concurrent launches reuse
76+ the completed result. Startup refuses an incomplete existing cache rather than
77+ removing files another process may be using. Use a fresh extract root if an
78+ existing entry is damaged.
79+
80+ Each new cache entry is a directory symlink to a completed image in a hidden
81+ backing directory beside it. Publishing the symlink cannot replace another
82+ entry, including one created concurrently. The backing belongs to the caller
83+ once published. Removing just the symlink does not reclaim its image; clean
84+ the extract root when its applications are no longer running. Older cache
85+ entries stored directly as directories remain readable.
86+
87+ ZIP cache identities include application files, permissions, bootstrap code,
88+ interpreter options and resolved external-runtime facts. Updating a binary can
89+ leave older cache entries behind. Shell and Python entry points share the same
90+ image identity. Published directories follow the caller's umask.
91+
92+ When unset, bootstraps create temporary runtime directories. Bash entry points
93+ use ` TMPDIR ` or ` /tmp ` ; Python entry points follow ` tempfile ` 's directory
94+ selection. On POSIX, an independent process removes these directories
95+ asynchronously after the original interpreter PID exits, including across
96+ exec. The application keeps its native PID, signal delivery and terminal job.
97+ Windows waits for the application child before removing its runtime. Console
98+ Ctrl-C is delivered by Windows; the bootstrap waits for the application's own
99+ cleanup and exit status without forwarding another interrupt.
100+
101+ The temporary lifetime ends with the original interpreter, even if a forked
102+ child outlives it. Such applications need a persistent extract root. Linux
103+ namespace PID 1 and child subreapers can adopt the cleanup process; waiting for
104+ every child can then block until application exit. Persistent extraction avoids
105+ that process. Namespace or cgroup shutdown can kill it before removal finishes,
106+ and SIGKILL during setup before registration cannot guarantee cleanup. On
107+ systems without a native exit watch or suitable Linux procfs, PID reuse can
108+ delay removal.
109+
110+ The lifetime and publication behavior above applies to the default application
111+ launchers. Raw templates and older custom rules exposing only ` PyExecutableInfo `
112+ retain their existing behavior. Their Windows ZIP adapter re-extracts a persistent
113+ cache on every launch; directory links can make a repeated launch fail. Use
114+ temporary extraction for that compatibility path.
74115
75116:::{versionadded} 1.2.0
76117:::
118+
119+ :::{versionchanged} VERSION_NEXT_PATCH
120+ Ordinary and ZIP entry points preserve native POSIX execution and share
121+ failure-safe temporary cleanup. ZIP caches are published after preparation and
122+ include bootstrap inputs in their identity.
123+ :::
77124::::
78125
79126:::{envvar} RULES_PYTHON_GAZELLE_VERBOSE
0 commit comments