You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello there,
it's my first contact with Brython and I'm stuck trying to get a certain package running.
Goal
Using the music21-package.
(within a worker and inside a nuxt/vuejs project)
Short backstory
I have successfully integrated the package with polyscript/pyodide, the only problem is, compared to it's CPython execution, the operations are mostly 5 times slower. Most operations (per api call) take already 200+ms with CPython, which results in consistently 1+ seconds for any operation, which is unacceptable. Before I give up and build a server API, I wanted to try a Python to Javascript transpiler and Brython seems the most mature.
What I tried so far and my current problems
I have a devcontainer with python 3.12 and used the brython-cli tool to install a demo app environment.
I use music21 with minimum required packages (without matplotlib or numpy). I checked, and it seems the package itself and all required packages provide pure python wheels, thus should not require c extensions.
As music21 is a large package with many modules, I tried to use the make_package command, which gave an error. Thus I decided to get it first running with just using the standard mechanism.
So I used add_package for music21 and it's required packages and their required packages (I'm not sure if there is a simpler way as to manually trying to check for dependencies of dependencies as add_package seems to be just a copy operation).
The first problem I had here, the package more-itertools could not be added with add_package more-itertools but with add_package more_itertools which might by normal.
Then I added some code using the music21-package to the index.html and set the debug-level to 2.
Then used the dev server with start_server.
Then, I guess, a compiler error happend?
brython.js:15192 Traceback (most recent call last):
File "http://127.0.0.1:8042/#__main__", line 2, in<module>
from music21.stream import Score, Part, Measure, Voice
File "http://127.0.0.1:8042/Lib/site-packages/music21/__init__.py", line 176, in<module>
from music21 import base # noqa: E402
File "http://127.0.0.1:8042/Lib/site-packages/music21/base.py", line 52, in<module>
from music21 import common
File "http://127.0.0.1:8042/Lib/site-packages/music21/common/__init__.py", line 44, in<module>
from music21.common.classTools import *# including isNum, isListLike
File "http://127.0.0.1:8042/Lib/site-packages/music21/common/classTools.py", line 46, in<module>
def isNum(usrData: t.Any) -> t.TypeGuard[t.Union[float, int, Fraction]]:
ImportError: cannot import name 'base' from 'music21' (http://127.0.0.1:8042/Lib/site-packages/music21/__init__.py)
So the parser seems to have a problem with def isNum(usrData: t.Any) -> t.TypeGuard[t.Union[float, int, Fraction]]:?
The relevant context in the mentioned class:
Is this already the end of my journey, and the parser is in general not capable to parse this kind of function definition?
Or what might be the next steps to find out what the actual cause is?
Best regards,
Manuel
The text was updated successfully, but these errors were encountered:
The commit referenced above fixes a bug related to annotations.
But after fixing it, there is another issue: the package imports module xml, which is not supported by Brython because the CPython module uses a library written in C, and there is no pure-Python replacement.
Wow, thank you very much that you looked into it in detail. I really appreciate it.
Indeed I didn't thought about the python standard libs.
And great news that you work on the xml module.
Hello there,
it's my first contact with Brython and I'm stuck trying to get a certain package running.
Goal
Using the
music21
-package.(within a worker and inside a nuxt/vuejs project)
Short backstory
I have successfully integrated the package with
polyscript
/pyodide
, the only problem is, compared to it's CPython execution, the operations are mostly 5 times slower. Most operations (per api call) take already 200+ms with CPython, which results in consistently 1+ seconds for any operation, which is unacceptable. Before I give up and build a server API, I wanted to try a Python to Javascript transpiler and Brython seems the most mature.What I tried so far and my current problems
I have a devcontainer with python 3.12 and used the
brython-cli
tool to install a demo app environment.I use music21 with minimum required packages (without
matplotlib
ornumpy
). I checked, and it seems the package itself and all required packages provide pure python wheels, thus should not require c extensions.As music21 is a large package with many modules, I tried to use the
make_package
command, which gave an error. Thus I decided to get it first running with just using the standard mechanism.So I used
add_package
for music21 and it's required packages and their required packages (I'm not sure if there is a simpler way as to manually trying to check for dependencies of dependencies asadd_package
seems to be just a copy operation).The first problem I had here, the package
more-itertools
could not be added withadd_package more-itertools
but withadd_package more_itertools
which might by normal.Then I added some code using the music21-package to the index.html and set the debug-level to 2.
Then used the dev server with
start_server
.Then, I guess, a compiler error happend?
So the parser seems to have a problem with
def isNum(usrData: t.Any) -> t.TypeGuard[t.Union[float, int, Fraction]]:
?The relevant context in the mentioned class:
Is this already the end of my journey, and the parser is in general not capable to parse this kind of function definition?
Or what might be the next steps to find out what the actual cause is?
Best regards,
Manuel
The text was updated successfully, but these errors were encountered: