fix(zipapp): guard against null runtime files (#4119) When building a zipapp archive 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. Only add \`py_runtime.files\` to the runfiles builder when it is not \`None\`.
diff --git a/news/py_zipapp_runtime_files.fixed.md b/news/py_zipapp_runtime_files.fixed.md new file mode 100644 index 0000000..bc1343c --- /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 b1a9399..7e11b06 100644 --- a/python/private/zipapp/py_zipapp_rule.bzl +++ b/python/private/zipapp/py_zipapp_rule.bzl
@@ -133,7 +133,8 @@ 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)