posit-dev / py-shiny

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

shiny doesn't work along with the latest ipython version #1587

Open shrektan opened 3 months ago

shrektan commented 3 months ago

Package Compatibility Issue: ipython and shiny with Poetry

Summary

When using Poetry to manage a Python project that includes both ipython and shiny, a version conflict occurs due to incompatible dependencies on prompt-toolkit. This issue prevents the installation of both packages in their latest versions.

Error Message

Because no versions of questionary match >2.0.0,<2.0.1 || >2.0.1
 and questionary (2.0.0) depends on prompt_toolkit (>=2.0,<=3.0.36), questionary (>=2.0.0,<2.0.1 || >2.0.1) requires prompt_toolkit (>=2.0,<=3.0.36).
And because questionary (2.0.1) depends on prompt_toolkit (>=2.0,<=3.0.36), questionary (>=2.0.0) requires prompt_toolkit (>=2.0,<=3.0.36).
Because no versions of shiny match >1.0.0,<2.0.0
 and shiny (1.0.0) depends on questionary (>=2.0.0), shiny (>=1.0.0,<2.0.0) requires questionary (>=2.0.0).
Thus, shiny (>=1.0.0,<2.0.0) requires prompt_toolkit (>=2.0,<=3.0.36).
And because ipython (8.26.0) depends on prompt-toolkit (>=3.0.41,<3.1.0)
 and no versions of ipython match >8.26.0,<9.0.0, shiny (>=1.0.0,<2.0.0) is incompatible with ipython (>=8.26.0,<9.0.0).
So, because polarstar depends on both shiny (^1.0.0) and ipython (^8.26.0), version solving failed.

Steps to Reproduce

  1. Create a new directory (e.g., test)
  2. Initialize a new Poetry project:
    poetry init
  3. Add ipython to the project:
    poetry add ipython
  4. Attempt to add shiny to the project:
    poetry add shiny
  5. Observe the error message above

Root Cause

The conflict arises from incompatible version requirements for prompt-toolkit:

These requirements cannot be satisfied simultaneously, causing the dependency resolution to fail.

Workaround

Manually specify a lower version of ipython that is compatible with the required version of prompt-toolkit. For example:

poetry add ipython@8.18.0

Then add shiny:

poetry add shiny

Proposed Solutions

  1. Update shiny or its dependencies to support newer versions of prompt-toolkit.
  2. Investigate if ipython can be made compatible with a wider range of prompt-toolkit versions.
  3. Consider creating a compatibility layer or shim to allow these packages to coexist.
gadenbuie commented 3 months ago

Interesting, shiny requires questionary>=2.0.0, but poetry seems to be excluding questionary 2.0.1.

Can you try installing questionary v2.0.1, which requires prompt_toolkit = ">=2.0,<4.0"?

gadenbuie commented 3 months ago

Oh wait, I was looking at questionary's GitHub repo which has updates but is still at 2.0.1. It looks like questionary plans to push a new release soon that will remove the prompt_toolkit restriction.