Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

absl-py not working with Cython #146

Open
hlacikd opened this issue Jul 12, 2020 · 0 comments
Open

absl-py not working with Cython #146

hlacikd opened this issue Jul 12, 2020 · 0 comments

Comments

@hlacikd
Copy link

hlacikd commented Jul 12, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant