posit-dev / py-shiny

Shiny for Python
https://shiny.posit.co/py/
MIT License
1.2k stars 69 forks source link

Incompatible `typing-extensions` Version in Shiny for Python App with Shinylive #1092

Open aarontovars opened 7 months ago

aarontovars commented 7 months ago

Description

I'm encountering a version conflict with the typing-extensions package in my Shiny for Python app, which I'm trying to export using Shinylive. The core of the issue lies in the dependencies of two critical packages:

Both of these packages necessitate typing-extensions version >= 4.6.0. However, I'm facing discrepancies in the version requirements as stated in different documentation:

Despite explicitly setting typing-extensions == 4.9.0 in my requirements.txt, a version check in app.py reveals that the version being used is still 4.4.0.

Concern

I might be overlooking something in the configuration or the build process. Any insights or suggestions to resolve this version mismatch would be greatly appreciated. Is there a specific configuration step I might be missing, or could there be an issue with how Shinylive handles dependencies?

wch commented 7 months ago

Shinylive is currently using Pyodide 0.22.1, not the latest, which is 0.25.0. Note that Pyodide 0.22.1 includes typing-extensions 4.4.0. It may be possible to bring in a newer version of typing-extensions by putting a pypi URL in the requirements.txt, but I don't know for sure.

We are planning on updating to a newer version of Pyodide in the next few weeks, so if you are able to wait, then you shouldn't have to do anything else to make it work.

I see that on our Shinylive page, we haven't mentioned the Pyodide version, but we do link to the latest Pyodide docs, so that discrepancy could be confusing. We can update the docs to make the Pyodide version more clear.

aarontovars commented 7 months ago

Thanks @wch for your answer!

I have tried putting the pypi URL in the requirements.txt but it doen't even try to install it, probably cause it recognizes that typing-extensions is already installed.

I may be able to wait a few weeks, but I would like to know if there is any possible workaround I can try for the moment.

wch commented 7 months ago

If you are using the Python shinylive package to do the export (as opposed to just using the app from shinylive.io), you could try doing this:

After you do all that, try doing a shinylive export and see how it goes.

aarontovars commented 7 months ago

I did everything you mentioned, but after executing shinylive export and checking the result, still getting this error. Maybe I should reload the dependencies or doing some execution without cache?

Error > skull > Error starting app! > Traceback (most recent call last): > File "", line 368, in _start_app > File "", line 302, in _install_requirements_from_dir > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 573, in install > await transaction.gather_requirements(requirements) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 333, in gather_requirements > await gather(*requirement_promises) > File "/lib/python3.10/asyncio/futures.py", line 284, in __await__ > yield self # This tells Task to wait for completion. > File "/lib/python3.10/asyncio/tasks.py", line 304, in __wakeup > future.result() > File "/lib/python3.10/asyncio/futures.py", line 201, in result > raise self._exception > File "/lib/python3.10/asyncio/tasks.py", line 234, in __step > result = coro.throw(exc) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 340, in add_requirement > return await self.add_requirement_inner(Requirement(req)) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 448, in add_requirement_inner > await self.add_wheel(wheel, req.extras) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 463, in add_wheel > await self.gather_requirements(wheel.requires(extras)) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 333, in gather_requirements > await gather(*requirement_promises) > File "/lib/python3.10/asyncio/futures.py", line 284, in __await__ > yield self # This tells Task to wait for completion. > File "/lib/python3.10/asyncio/tasks.py", line 304, in __wakeup > future.result() > File "/lib/python3.10/asyncio/futures.py", line 201, in result > raise self._exception > File "/lib/python3.10/asyncio/tasks.py", line 234, in __step > result = coro.throw(exc) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 337, in add_requirement > return await self.add_requirement_inner(req) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 448, in add_requirement_inner > await self.add_wheel(wheel, req.extras) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 463, in add_wheel > await self.gather_requirements(wheel.requires(extras)) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 333, in gather_requirements > await gather(*requirement_promises) > File "/lib/python3.10/asyncio/futures.py", line 284, in __await__ > yield self # This tells Task to wait for completion. > File "/lib/python3.10/asyncio/tasks.py", line 304, in __wakeup > future.result() > File "/lib/python3.10/asyncio/futures.py", line 201, in result > raise self._exception > File "/lib/python3.10/asyncio/tasks.py", line 232, in __step > result = coro.send(None) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 337, in add_requirement > return await self.add_requirement_inner(req) > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 418, in add_requirement_inner > if self.check_version_satisfied(req): > File "/lib/python3.10/site-packages/micropip/_micropip.py", line 364, in check_version_satisfied > raise ValueError( > ValueError: Requested 'typing-extensions>=4.6.0', but typing-extensions==4.4.0 is already installed
wch commented 7 months ago

Can you check the repodata.json that's in the newly-created export and check if it has the correct version of typing-extensions?

aarontovars commented 7 months ago

It is now solved, I needed to modify as well the repodata.orig.json.

However, when I export the app and try to open the website, it is shaded, with the only error from terminal:

python3 -m http.server --directory _site --bind localhost 8008 Serving HTTP on ::1 port 8008 (http://[::1]:8008/) ... ::1 - - [01/Feb/2024 09:33:49] "GET / HTTP/1.1" 200 - ::1 - - [01/Feb/2024 09:33:49] "GET /app.json HTTP/1.1" 200 - ::1 - - [01/Feb/2024 09:33:51] "GET /shinylive-sw.js HTTP/1.1" 304 - ::1 - - [01/Feb/2024 09:33:51] "GET /shinylive/pyodide/certifi-2022.12.7-py3-none-any.whl HTTP/1.1" 200 - ::1 - - [01/Feb/2024 09:33:52] code 404, message File not found ::1 - - [01/Feb/2024 09:33:52] "GET /shinylive/libsecret-1.so.0 HTTP/1.1" 404 - ::1 - - [01/Feb/2024 09:33:54] "GET /shinylive-sw.js HTTP/1.1" 304 -

Any hint on how to debug this error?

wch commented 7 months ago

I'm not sure, but it's possible that adding ceritifi to your requirements.txt will fix it.

aarontovars commented 7 months ago

I have added the following requirements: certifi, requests and cryptography, but the same error message appears when I run the _site webpage, with a shaded app and no reactivity:

python3 -m http.server --directory _site --bind localhost 8008 Serving HTTP on ::1 port 8008 (http://[::1]:8008/) ... ::1 - - [02/Feb/2024 11:34:48] "GET / HTTP/1.1" 200 - ::1 - - [02/Feb/2024 11:34:48] "GET /app.json HTTP/1.1" 200 - ::1 - - [02/Feb/2024 11:34:50] "GET /shinylive-sw.js HTTP/1.1" 304 - ::1 - - [02/Feb/2024 11:34:51] code 404, message File not found ::1 - - [02/Feb/2024 11:34:51] "GET /shinylive/libsecret-1.so.0 HTTP/1.1" 404 - ::1 - - [02/Feb/2024 11:34:53] "GET /shinylive-sw.js HTTP/1.1" 304 -

wch commented 7 months ago

If you look in your browser's JS console, it might provide some more useful information.