Skip to content

Please use a crc library that provides a pure Python implementation #217

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

Closed
whitequark opened this issue Dec 22, 2023 · 5 comments · Fixed by #223
Closed

Please use a crc library that provides a pure Python implementation #217

whitequark opened this issue Dec 22, 2023 · 5 comments · Fixed by #223

Comments

@whitequark
Copy link
Member

Right now, Apycula cannot be used with Pyodide:

>>> await micropip.install('Apycula==0.10.0')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/lib/python3.11/site-packages/micropip/_commands/install.py", line 142, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 204, in gather_requirements
    await asyncio.gather(*requirement_promises)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 211, in add_requirement
    return await self.add_requirement_inner(Requirement(req))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 300, in add_requirement_inner
    await self._add_requirement_from_package_index(req)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 347, in _add_requirement_from_package_index
    await self.add_wheel(wheel, req.extras, specifier=str(req.specifier))
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 385, in add_wheel
    await self.gather_requirements(wheel.requires(extras))
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 204, in gather_requirements
    await asyncio.gather(*requirement_promises)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 208, in add_requirement
    return await self.add_requirement_inner(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 300, in add_requirement_inner
    await self._add_requirement_from_package_index(req)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 339, in _add_requirement_from_package_index
    wheel = find_wheel(metadata, req)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 431, in find_wheel
    raise ValueError(
ValueError: Can't find a pure Python 3 wheel for 'crcmod'.
See: https://pyodide.org/en/stable/usage/faq.html#why-can-t-micropip-find-a-pure-python-wheel-for-a-package
You can use `await micropip.install(..., keep_going=True)` to get a list of all packages with missing wheels.

This is the only problematic dependency AFAICT (numpy is supported).

@pepijndevos
Copy link
Member

Any suggestions for such a library?

@whitequark
Copy link
Member Author

@pepijndevos
Copy link
Member

pepijndevos commented Dec 28, 2023

It's only used here so the change should be simple.

crc16arc = mkPredefinedCrcFun('crc-16')

I'm guessing we'll need these parameters, that's the main tricky part
https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-arc

Actually, these are the current parameters:
https://crcmod.sourceforge.net/crcmod.predefined.html#predefined-crc-algorithms

@whitequark
Copy link
Member Author

>>> import crcmod.predefined
>>> crc16 = crcmod.predefined.mkPredefinedCrcFun('crc-16')
>>> crc16(b"abcd")
14743
>>> calc = crc.Calculator(crc.Configuration(width=16, polynomial=0x8005, reverse_input=True, reverse_output=True))
>>> calc.checksum(b"abcd")
14743

pepijndevos added a commit that referenced this issue Jan 20, 2024
Fixed #217 and hopefully makes peoply trying to to bundle/install
Apicual in weird ways a little happier for having to compile less C.
pepijndevos added a commit that referenced this issue Jan 20, 2024
* Switch crcmod to crc

Fixed #217 and hopefully makes peoply trying to to bundle/install
Apicual in weird ways a little happier for having to compile less C.

* the stupid thing isn't thread safe

* python scoping rules are dumb
@whitequark
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants