caeroc icon indicating copy to clipboard operation
caeroc copied to clipboard

pyscript capability

Open Neon22 opened this issue 11 months ago • 6 comments

I'm starting a dedicated thread here:

I am getting an error when I import caeroc directly. Its about Can't find a pure Python 3 wheel for: 'numpy<2,>=1.21'

I think this is defined in the caeroc packaging:

  • pyproject.toml in the dependencies section.
  • also in uv.lock where the version 1.2.6 is specifically mentioned
  • Alas I have no idea how uv.lock works... :(

I am not sure why pyodide is not handling it but I wonder if there is a way to specifiy it so we can get it to work.

  • perhaps pick a specific numpy version that pyodide has a version for,
  • or possibly move to numpy 2 ?
    • Here is the migration guide. https://numpy.org/devdocs/numpy_2_0_migration_guide.html
    • https://www.datacamp.com/tutorial/numpy-2-release

Neon22 avatar Feb 11 '25 02:02 Neon22

uv.lock exists only to work with the tool, uv. Running uv sync should in principle get you the right versions.

However in pyscript, micropip is used and do you know where the numpy wheels are sourced from?

Going for Numpy 2 is the cleanest approach, but I don't recall why I pinned it.

ashwinvis avatar Feb 11 '25 04:02 ashwinvis

Here:

  • https://pyodide.org/en/stable/usage/packages-in-pyodide.html it appears that the numpy that is included in current pyodide used by pyscript is Numpy 2.0.2

I think there is a way to install any package if a wheel is available:

  • https://docs.pyscript.net/2025.2.2/faq/#code-archive-ziptgzwhl

Haven't tried to do it before...

As for numpy 2 migration. seems like things like this are the main problem:

  • np.float32(6) + 6.
  • which should be using something like int which is a 'proper' type
  • I have not scraped your code looking for how you use numpy. I mean it might just work...

Neon22 avatar Feb 11 '25 09:02 Neon22

I made a change to allow Numpy 2 50939a0f8f15fa72f9491f6981c270e7efe7dd05

See if you can install from Github directly as shown here

https://pip.pypa.io/en/stable/reference/requirement-specifiers/#examples

Otherwise, I can push a release later

ashwinvis avatar Feb 11 '25 21:02 ashwinvis

well that looks like it migth work. Alas pypi is still looking at original so I see this error:

Uncaught (in promise) PythonError: Traceback (most recent call last):
  File "/lib/python3.12/site-packages/micropip/package_manager.py", line 133, in install
    return await install(
           ^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/install.py", line 57, in install
    raise ValueError(
ValueError: Can't find a pure Python 3 wheel for: 'numpy<2,>=1.21'
See: https://pyodide.org/en/stable/usage/faq.html#why-can-t-micropip-find-a-pure-python-wheel-for-a-package

and that's because the pyodide we are using (mandated by pyscript) brings in a numpy 2.0.2 and so it just can't resolve this.

I might be able to make a whole pile of individual rawgithub links but its painful. I will wait for a release. if you want to make it an alpha or something as long as pypi can hold it for me I can test with it.

Sorry to bug you about this.

Neon22 avatar Feb 12 '25 02:02 Neon22

There you go https://pypi.org/project/caeroc/0.0.4a0/

ashwinvis avatar Feb 13 '25 12:02 ashwinvis

Oh wow. Its working. Loading successfully:

Caeroc loads the following packages:

  • Pillow, contourpy, cycler, fonttools, kiwisolver, matplotlib, matplotlib-pyodide,
  • numpy, openblas, pyparsing, python-dateutil, pytz, scipy, six, typing-extensions

Thanks heaps. I'll continue forwards

Neon22 avatar Feb 13 '25 20:02 Neon22