-
Notifications
You must be signed in to change notification settings - Fork 40
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
Attempting to run mathjax from PythonMonkey: export declarations may only appear the top level of a module...etc. #452
Comments
Glad to hear your in interest in the project!! Initial roadblocks with your mathjax-full journey:
You can sort of think of PythonMonkey more like a full JavaScript runtime, it just happens to be used as a Python library with easy to use high level bindings. Like other JavaScript runtimes, (Firefox, Chrome, Node, Bun, etc) there are compatibility issues between them due to different APIs being available. HOWEVER!!!!! If you're willing to put a little work into polyfilling the environment, you may be able to get things running smoothly which were originally meant to run in a different environment (like NodeJS or the browser) --- we did that to port https://socket.io/ to Python, and our Python SDK for distributed computing is also just a port of our JS SDK using PythonMonkey via polyfilling. I played around with your example code but eventually came across errors due to |
Wow! Thank you for such a detailed (and fast) response. I see the problem more clearly now. Thank you, again, for this response. |
How did you get around the export error to hit this error? |
I modified the code in the node module lol I changed
to
in file Not sure if that's the best path to start going down, but it's just something I played around with |
Excellent, thank you! |
Issue type
Bug
How did you install PythonMonkey?
Installed from pip
OS platform and distribution
Linux Ubuntu 22.04
Python version (
python --version
)3.11
PythonMonkey version (
pip show pythonmonkey
)1.0.0
Bug Description
Hi PythonMonkey maintainers!
I love what you have done with this library and have been following it for the last year (congrats on v1.0!). I am quite comfortable in Python but I am a Javascript noob (please bear with me).
My use case is to try and run mathjax from Python. Here is what I am trying to do (see First attempt, below).
This fails when it tries to access the
export {init}
from the "node-main.js" submodule. (See stack trace below).So, I tried creating an external submodule that executes
.init
within the Javascript (see Second attempt, below).This runs the init (success!) but gets stuck on the export within my "tex2svg.js" sub module.
Am I doing this wrong or is this actually a bug? Any help or insight is deeply appreciated.
Standalone code to reproduce the issue
First attempt
Second attempt
Relevant log output or backtrace
Second attempt (Using
pym.require("../tex2svg.js")
):Additional info if applicable
Here is the contents of my javascript submodule ("tex2svg.js"):
What branch of PythonMonkey were you developing on? (If applicable)
No response
The text was updated successfully, but these errors were encountered: