From f4e0b3fa7452137744e6abfad4f53565b171909e Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Fri, 28 Aug 2026 10:08:49 -0700 Subject: [PATCH] fix(zipapp): guard against null runtime files When creating a zipapp with a Python runtime whose `files` attribute is None (such as a system interpreter), adding `py_runtime.files` to the runfiles builder raises an error. Add a guard to only add `py_runtime.files` if it is not None. --- news/py_zipapp_runtime_files.fixed.md | 2 ++ python/private/zipapp/py_zipapp_rule.bzl | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 news/py_zipapp_runtime_files.fixed.md diff --git a/news/py_zipapp_runtime_files.fixed.md b/news/py_zipapp_runtime_files.fixed.md new file mode 100644 index 0000000000..bc1343c1da --- /dev/null +++ b/news/py_zipapp_runtime_files.fixed.md @@ -0,0 +1,2 @@ +(zipapp) Fixed handling of {obj}`PyRuntimeInfo` with `files = None` so creating +zipapp archives does not error. diff --git a/python/private/zipapp/py_zipapp_rule.bzl b/python/private/zipapp/py_zipapp_rule.bzl index b1a9399e90..7e11b06b1b 100644 --- a/python/private/zipapp/py_zipapp_rule.bzl +++ b/python/private/zipapp/py_zipapp_rule.bzl @@ -133,7 +133,8 @@ def _create_zip(ctx, py_runtime, py_executable, stage2_bootstrap): runfiles = builders.RunfilesBuilder() - runfiles.add(py_runtime.files) + if py_runtime.files != None: + runfiles.add(py_runtime.files) if py_executable.venv_python_exe: runfiles.add(py_executable.venv_python_exe)