abseil-py
abseil-py copied to clipboard
absl-py not working with Cython
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