add python script to chromium code

87 views
Skip to first unread message

eden david

unread,
Mar 19, 2021, 11:26:28 AM3/19/21
to Chromium-dev

hey,
I want to run a python script from the function:

voidSaveUpdateBubbleController::OnSaveClicked() - in cpp file.

I tried to run the script with the following code:
    
      Py_Initialize();

      fp = _Py_fopen(filename, "r");
      PyRun_SimpleFile(fp, filename);

      Py_Finalize();


but when I compile the code I get the errors:     

"undefined symbol: Py_Initialize", "undefined symbol: _Py_fopen", "undefined symbol: PyRun_SimpleFileExFlags", "undefined symbol: Py_Finalize".

even if i include python library.

thanks...

K. Moon

unread,
Mar 19, 2021, 11:46:02 AM3/19/21
to עדן דוד, Chromium-dev
You'll need to include more details on how you're "including" the Python library. Note that in C++, it's not sufficient to just #include a header; you also need to make sure the corresponding binary library is linked in.

That said, what you're trying to do is probably a bad idea. Functions like Py_Initialize()/Py_Finalize() typically should run once per program execution, not every time the OnSaveClicked() is called. Furthermore, Chrome isn't designed to run a Python interpreter inside the browser process, so you're probably on your own to debug any problems with this combination.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/e3f65857-961f-4bf5-b906-ce9822760833n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages