absl-py not working with Cython
- 主要語言
- Python
- 星號
- 2.5k
- 分支
- 279
- 平均合併
- 2 天 1 小時
- 30 天內合併 PR
- 1
描述
Hi, I want to compile my python app using absl-py into executable using Cython.
I tried it with just the example
from absl import app
from absl import flags
FLAGS = flags.FLAGS
flags.DEFINE_string("name", "David", "Your name.")
flags.DEFINE_integer("num_times", 1, "Number of times to print greeting.")
def main(argv):
del argv # Unused.
if __name__ == "__main__":
app.run(main)
I am compiling it using cython as **cython app.py --embed** (to make it executable)
After this app.c is generated, i am using gcc to compile it as
**gcc -Os $(pkg-config --cflags python3) app.c -lpython3.8 -o app**
which workes without any error.
however when i try to execute it, this is an error that i get :
Traceback (most recent call last):
File "app.py", line 5, in init app
flags.DEFINE_string("name", "David", "Your name.")
File "/usr/local/lib/python3.8/dist-packages/absl/flags/_defines.py", line 241, in DEFINE_string
DEFINE(parser, name, default, help, flag_values, serializer, **args)
File "/usr/local/lib/python3.8/dist-packages/absl/flags/_defines.py", line 81, in DEFINE
DEFINE_flag(_flag.Flag(parser, serializer, name, default, help, **args),
File "/usr/local/lib/python3.8/dist-packages/absl/flags/_defines.py", line 109, in DEFINE_flag
module, module_name = _helpers.get_calling_module_object_and_name()
File "/usr/local/lib/python3.8/dist-packages/absl/flags/_helpers.py", line 123, in get_calling_module_object_and_name
globals_for_frame = sys._getframe(depth).f_globals # pylint: disable=protected-access
ValueError: call stack is not deep enough
貢獻指南
研究方向
The error occurs in absl/flags/_helpers.py at get_calling_module_object_and_name when the call stack depth is insufficient during Cython compilation. Examine how absl-py introspects the stack and how Cython's --embed changes module loading. Start by reproducing the issue with the provided example, then look at sys._getframe usage in the helpers module. Determine if the module detection logic needs adjustment for embedded executables.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- build-system, cli
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100