holzschu / Carnets

Carnets is a stand-alone Jupyter notebook server and client. Edit your notebooks on the go, even where there is no network.
https://holzschu.github.io/Carnets_Jupyter/
BSD 3-Clause "New" or "Revised" License
552 stars 32 forks source link

py_mini_racer support ? _build_ext_handle() error #330

Open wangyuanhong2 opened 2 weeks ago

wangyuanhong2 commented 2 weeks ago

Hi, Is it possible to support py_mini_racer in order to use embedded v8? Thanks!

319 """ --> 320 js_functions = py_mini_racer.MiniRacer() 321 js_functions.eval(hash_code) 322 token = js_functions.call("hex", datetime.now().date().isoformat()).lower() File /var/mobile/Containers/Data/Application/130A4DEB-141A-4F53-9F2D-1047950A561C/Library/lib/python3.11/site-packages/py_mini_racer/py_mini_racer.py:185, in MiniRacer.init(self) 183 def init(self): 184 if self.class.ext is None: --> 185 self.class.ext = _build_ext_handle() 187 self.ctx = self.ext.mr_init_context(" ".join(self.v8_flags).encode("utf-8")) 188 self.lock = threading.Lock() File /var/mobile/Containers/Data/Application/130A4DEB-141A-4F53-9F2D-1047950A561C/Library/lib/python3.11/site-packages/py_mini_racer/py_mini_racer.py:132, in _build_ext_handle() 130 def _build_ext_handle(): 131 if EXTENSION_PATH is None or not os.path.exists(EXTENSION_PATH): --> 132 raise RuntimeError("Native library not available at {}".format(EXTENSION_PATH)) 134 _ext_handle = ctypes.CDLL(EXTENSION_PATH) 136 _ext_handle.mr_init_context.argtypes = [ctypes.c_char_p] RuntimeError: Native library not available at /var/mobile/Containers/Data/Application/130A4DEB-141A-4F53-9F2D-1047950A561C/Library/lib/python3.11/site-packages/py_mini_racer/libmini_racer.dylib

holzschu commented 2 weeks ago

It's not entirely clear from the description, but it seems that py_mini_racer assumes that there is a V8 JavaScript engine available. That is not the case on iOS: we only have the WkWebView JS engine, which is different from V8. I'll give it a try.

Note for myself: the lastest version of the package is: https://github.com/bpcreech/PyMiniRacer?tab=readme-ov-file