abseil / abseil/abseil-py

absl-py not working with Cython

オープン
#146 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
2.5k
フォーク
279
平均マージ
2日 1時間
マージ済み PR(30日)
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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。