googleapis / python-storage

Apache License 2.0
448 stars 154 forks source link

Micropi cannot install the package #1330

Closed ClearSafety closed 3 months ago

ClearSafety commented 3 months ago

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

Steps to reproduce

  1. Publish the app using the command flet publish approval_request_form.py -a assets with a file called requirements.txt having a list of the packages flet, pillow and google-cloud-storage
  2. Run the app in browser using the command flet publish approval_request_form.py -a assets

Code example

import flet as ft

def main(page: ft.Page):
    page.window.always_on_top=True
    page.bgcolor="#2A685A"  # Color grab from Clear Safety website
    page.adaptive=True
    page.title='Clear Safety: Approval Request'
    page.horizontal_alignment=ft.CrossAxisAlignment.CENTER
    page.vertical_alignment=ft.MainAxisAlignment.START
    page.padding=ft.padding.all(0)

    header = ft.Text(value='Hello World', size=50, color=ft.colors.WHITE)

    page.add(header)

ft.app(target=main, assets_dir='assets', upload_dir='assets/uploads')

Stack trace

After running the app in browser, its console displays this log. It seems the the .whl file is not compatible with Micropi:

Uncaught (in promise) PythonError: Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 571, in eval_code_async
    await CodeRunner(
  File "/lib/python311.zip/_pyodide/_base.py", line 396, in run_async
    await coroutine
  File "<exec>", line 11, 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 'google-crc32c<2.0dev,>=1.0'.
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.

    at new_error (pyodide.asm.js:9:12519)
    at pyodide.asm.wasm:0x158827
    at pyodide.asm.wasm:0x15fcd5
    at _PyCFunctionWithKeywords_TrampolineCall (pyodide.asm.js:9:123052)
    at pyodide.asm.wasm:0x1a3091
    at pyodide.asm.wasm:0x289e4d
    at pyodide.asm.wasm:0x1e3f77
    at pyodide.asm.wasm:0x1a3579
    at pyodide.asm.wasm:0x1a383a
    at pyodide.asm.wasm:0x1a38dc
    at pyodide.asm.wasm:0x2685c5
    at pyodide.asm.wasm:0x26e3d0
    at pyodide.asm.wasm:0x1a3a04
    at pyodide.asm.wasm:0x1a3694
    at pyodide.asm.wasm:0x15f45e
    at Module.callPyObjectKwargs (pyodide.asm.js:9:81732)
    at Module.callPyObject (pyodide.asm.js:9:82066)
    at wrapper (pyodide.asm.js:9:58562)

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

andrewsg commented 3 months ago

Hi, the problem here is with our google-crc32c dependency library, which does not publish pure-Python packages as it is intended to be a pure C extension. We compile for several platforms, but this is the first time we've encountered an environment that does not accept any wheel format that is not pure-Python.

Please open a bug at https://github.com/googleapis/python-crc32c and we will investigate, but as it is a C extension library there may not be many options.

According to the Micropip FAQ, there is a way to package C extensions for Micropi, so probably that will be your best bet: https://pyodide.org/en/stable/usage/faq.html#why-can-t-micropip-find-a-pure-python-wheel-for-a-package