HVML / PurC

The prime HVML interpreter for C Language.
GNU Lesser General Public License v3.0
1.05k stars 54 forks source link

PurC 0.9.8 run Find Primes with python, xGUIpro flash and exit #59

Closed YongjieLuo closed 1 year ago

YongjieLuo commented 1 year ago

Firstly, thank you for your great work in HVML. Secondly, I meet exception when I follow this article:

在 HVML 程序中嵌入 Python https://mp.weixin.qq.com/s?__biz=Mzg5ODUyNjA4Mw==&mid=2247486519&idx=1&sn=f4e15b25a5ebb5f9d5263ff3682e7d9c&chksm=c06072dbf717fbcd41a300b7f43a224e68f2a747f46dbccbf8d9d36080fba7059177029611c9&scene=21#wechat_redirect

I copy this hello world source code:

$STREAM.stdout.writelines('Hello, world!')

Hello, World!

This paragraph is generated by HVML, and it is in HTML.

and run it by: $ purc -c socket hello.hvml the output of xGUIPro is the same with the screenshot in "在 HVML 程序中嵌入 Python" article. It is OK.

But when I try Find Primes HVML program (the file name I gave is embed-python-find-primes.hvml ): $ purc -c socket embed-python-find-primes.hvml the xGUIPro flash quickly and then exit. I can not see the content of the output page in the Tailored WebKit which I compiled by myself.

When I run it by: $ purc -c thread embed-python-find-primes.hvml there is blank output by Foil.

the DEBUG messages of Tailored WebKit are:

DEBUG >> webkit_web_extension_initialize_with_user_data: got desired user data: HVML DEBUG >> web_page_created_callback: Page 8 created for (null) DEBUG >> web_page_created_callback: Script world: 0x1232e70 DEBUG >> window_object_cleared_callback: window_object_cleared_callback called: uri (hvml://localhost/default) DEBUG >> window_object_cleared_callback: Failed to split HVML URI: hvml://localhost/default DEBUG >> webkit_web_extension_initialize_with_user_data: got desired user data: HVML DEBUG >> web_page_created_callback: Page 18 created for (null) DEBUG >> web_page_created_callback: Script world: 0x1074c70 DEBUG >> window_object_cleared_callback: window_object_cleared_callback called: uri (hvml://localhost/cn.fmsoft.hvml.purc/main/-/page-0?irId=REQXXXXX-00000000642F05F0-00000000122DC4CC-0000000000000001) DEBUG >> document_loaded_callback: uri: hvml://localhost/cn.fmsoft.hvml.purc/main/-/page-0?irId=REQXXXXX-00000000642F05F0-00000000122DC4CC-0000000000000001 DEBUG >> document_loaded_callback: injecting hvml.js to page (0x1009420) DEBUG >> hvml_set_property: set HVML.onrequest with a value (0x7f1f04016c80) DEBUG >> hvml_set_property: value (0x7f1f04016c80) is a function DEBUG >> document_loaded_callback: result of injected script: ((null)) DEBUG >> user_message_received_callback: Got a message with name (request) DEBUG >> document_loaded_callback: hvml.js injected DEBUG >> user_message_received_callback: result of onrequest: ({"requestId":"REQXXXXX-00000000642F05F0-000000001B53B0BB-0000000000000002","state":"Ok"})

Please help me to solve this problem. Thank you!

VincentWei commented 1 year ago

Thanks for your issue report.

I think that you should check the following things step by step:

  1. Whether the loadable dynamic object PY was built correctly? Please check the shared libraries under /usr/local/lib/purc-0.9/ to see whether there is a library called libpurc-dvobj-PY.so. If not, you may need to install CPython 3.11.x on you system, then configure, build, and install PurC again.
  2. If the PY library is there, please try to run purc -c thread -v embed-python-find-primes.hvml. You will get a verbose output about the errors which were encountered when running the program with -v or --verbose option.
  3. I guess that the most likely cause was some misspellings (lexical or grammar errors) in the source program. Indeed, you can find the program in hvml/ subdirectory in your building directory, or the Source/Samples/hvml/ directory in the source tree.

Hope this can help you. If there is still a problem, please add a description.

YongjieLuo commented 1 year ago

There is a libpurc-dvobj-PY.so in my /usr/local/lib/purc-0.9 directory : libpurc-dvobj-FS.so libpurc-dvobj-MATH.so libpurc-dvobj-PY.so

The output of purc -c thread -v embed-python-find-primes.hvml is :

purc 0.9.8 Copyright (C) 2022, 2023 FMSoft Technologies. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Executing HVML program from file:///home/myusername/Programming/MyHVML/PurC/build/hvml/embed-python-find-primes.hvml...

The document generated:

The main coroutine terminated due to an uncaught exception: OSFailure.

The executing stack frame(s):

Please note that the executing stack frame(s) does not displayed.

Actually I run the .hvml source files in hvml/ subdirctory in my building directory firstly before report this issue, and the phenomenon is the same. For example, when I run embed-python-looking-for-primes.hvml or embed-python-looking-for-primes-ul.hvml or embed-python-animated-3d-random-walk.hvml there are blank output by Foil, and the xGUIPro flash quickly and then exit.

The output of purc -c thread -v embed-python-animated-3d-random-walk.hvml is :

purc 0.9.8 Copyright (C) 2022, 2023 FMSoft Technologies. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Executing HVML program from file:///home/myusername/Programming/MyHVML/PurC/build/hvml/embed-python-animated-3d-random-walk.hvml...

The document generated:

The main coroutine terminated due to an uncaught exception: OSFailure.

The executing stack frame(s):

According to the verbose output about the errors, I guess there is something wrong with the CMakeLists.txt, because I use deepin Linux 20.8 community version..... Maybe in

-----------------------------------------------------------------------------

Determine the operating system

-----------------------------------------------------------------------------

if (UNIX) if (APPLE) set(WTF_OS_MAC_OS_X 1) elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") set(WTF_OS_LINUX 1) else () set(WTF_OS_UNIX 1) endif () elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") set(WTF_OS_WINDOWS 1) elseif (CMAKE_SYSTEM_NAME MATCHES "Fuchsia") set(WTF_OS_FUCHSIA 1) else () message(FATAL_ERROR "Unknown OS '${CMAKE_SYSTEM_NAME}'") endif ()

or other settings ? Or checking OS version failed at run time ?

VincentWei commented 1 year ago

The main coroutine terminated due to an uncaught exception: OSFailure.

It seems that purc failed when loading the external shared library for PY dynamic object. Please check the following things:

  1. Is hvml/hello-world.hvml ok? This sample dose not use any external shared library.
  2. Is hvml/list-hvml-files.hvml ok? This sample uses the external shared library for FS dynamic object.
  3. Have you been pull the latest code of PurC, built, and installed the libraries into your system?
  4. Although you can run purc in your building directory without install it into the system, you must install the shared libraries for the dynamic objects into your system, in order that purc can find the correct shared libraries.

If the issue is still there, you may check the version of your CPython.

Moreover, what is your system? Linux or macOS? If it is Linux, which distribution you are using?

YongjieLuo commented 1 year ago

Thanks a lot, Mr Wei.

  1. There are 15 hello-world*.hvml fils in hvml/ subdirectory. They can run correctly. It means my purc is OK when purc dose not use any external shared library.

  2. hvml/list-hvml-files.hvml is not OK, $purc -c thread -v list-hvml-files.hvml the outputs are:

purc 0.9.8 Copyright (C) 2022, 2023 FMSoft Technologies. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Executing HVML program from file:///home/myusername/Programming/MyHVML/PurC/build/hvml/list-hvml-files.hvml...

The document generated:

List HVML Files

The main coroutine terminated due to an uncaught exception: OSFailure.

The executing stack frame(s):

00: <init as="all_cases" with=$FS.list_prt( "$SYS.cwd/hvml", "*.hvml" )/>

ATTRIBUTES: as: "all_cases" with: OSFailure raised when evaluating the expression: $FS.list_prt( "$SYS.cwd/hvml", ".hvml" ) Variant Creation Model: callGetter(getElement(getVariable("FS"),"list_prt"),concatString(getElement(getVariable("SYS"),"cwd"),"/hvml"),".hvml") Exception: OSFailure Call stack: CONTENT: undefined CONTEXT VARIABLES: < null @ null ! {} : null = null % 0UL ^ null

01:

ATTRIBUTES: CONTENT: null CONTEXT VARIABLES: < null @ null ! {} : null = null % 0UL ^ null

02:

ATTRIBUTES: target: "html" CONTENT: undefined CONTEXT VARIABLES: < null @ null ! {} : null = null % 0UL ^ null

  1. Yes I pull the latest code of PurC which is version 0.9.8. After building process, the installation step to my Linux system is done.

  2. I use Deepin Linux 20.8 community version, and the default Python 3 version of Deepin 20.8 is 3.7.3, therefore I use conda virtual environment as my PurC's Python host. The version of this hosted Python is 3.9.16. Then I activate this virtual environment, build PurC, and then install it.

Maybe that is the root cause. Since I am afraid to corrupt Deepin system by updating the Python 3.7.3, I use virtual environment........

Is there a solution to build and install PurC with conda's environment correctlly? :-)

VincentWei commented 1 year ago

6. I use Deepin Linux 20.8 community version, and the default Python 3 version of Deepin 20.8 is 3.7.3, therefore I use conda virtual environment as my PurC's Python host. The version of this hosted Python is 3.9.16. Then I activate this virtual environment, build PurC, and then install it.

PurC needs CPython 3.9.0+. I have asked developers of Deepin distribution to check this issue.

However, it is strange that the external shared library for FS dynamic object had the same problem.

VincentWei commented 1 year ago

There is alternative: you can try to build CPython 3.11.0 or later by yourself for your Deepin system.

YongjieLuo commented 1 year ago

Thank you very much !

Yes I update my conda's virtual environment from version 3.9.16 to 3.12.2, and then rebuild PurC and reinstall it. It is interesting that the *.so files in the build/lib subdirectory are not recompiled completely.
The libpurc-dvobj-FS.so libpurc-dvobj-MATH.so libpurc-executor-CHOOSETIMER.so libpurc-executor-FUNC_DEMO.so are rebuilded and reinstalled to /usr/local/lib/purc-0.9/ subderictory, but the libpurc-dvobj-PY.so is not rebuilded, because the date of building time is still 3 days ago.

Therefore, I still guess the conda's virtual environment is the root cause. How I wish the developers of Deepin find the reason and solution.

Thank you again !

YongjieLuo commented 1 year ago

By the way, I run the files in /build/hvml subdirectory after the rebuilding,
and the output messages of purc -c thread -v command are the same as before.

VincentWei commented 1 year ago

Therefore, I still guess the conda's virtual environment is the root cause. How I wish the developers of Deepin find the reason and solution.

I think so. :)

BTW: I have asked the key maintainer of Deepin about this issue. He said that they will not update Python for Deepin 20, because the distribution had been in maintaining mode. They recommended that all users should consider to upgrade to Deepin 23. And they will build and pack the latest PurC and xGUI Pro for Deepin 23.

YongjieLuo commented 1 year ago

Nice :-) It seems that I have to be patient to Deepin 23... I study HVML itself now. It's good, "slow is fast". Thank you for your help, and great wishes to HVML !

VincentWei commented 1 year ago

Thank you for your help, and great wishes to HVML !

You are welcome!