bazel-contrib / bazel-contrib/rules_python

pre-compile is failing for binary targets if there is no main specified

未关闭
#2,881 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
core-rules type: bug
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
76

描述

With #2768 optional, it is possible to have zero `.py` files or the `main` is not used or specify `main_module`.

Then I get errors:
```
providers = py_executable_impl(
File "/home/ignas-anikevicius/.cache/bazel/_bazel_ignas-anikevicius/e1764a0ec8835154284d951e9bb11b85/external/rules_python+/python/private/py_executable.bzl", line 256, column 35, in py_executable_impl
return py_executable_base_impl(
File "/home/ignas-anikevicius/.cache/bazel/_bazel_ignas-anikevicius/e1764a0ec8835154284d951e9bb11b85/external/rules_python+/python/private/py_executable.bzl", line 1049, column 50, in py_executable_base_impl
main_py = precompile_result.py_to_pyc_map[main_py]
Error: key None not found in dictionary
```

It seems that we may have forgotten to handle the `main_module` in precompilation.

贡献指南

打开贡献指南

调研方向

从 python/private/py_executable.bzl 中的 py_executable_impl 和 py_executable_base_impl 附近开始,尤其关注第 1049 行的预编译查找。复现一个没有 .py 文件、未指定 main 或 main_module 的二进制目标,然后验证预编译能够处理选定的入口点,而不会在 py_to_pyc_map 中查找 None。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
build-system
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。