unioslo / zabbix-cli

Command-line interface for Zabbix
https://unioslo.github.io/zabbix-cli/
GNU General Public License v3.0
208 stars 105 forks source link

ImportError: cannot import name '_make_rich_rext' from 'typer.rich_utils' #259

Closed fauust closed 3 days ago

fauust commented 4 days ago

Hi! I am trying to install and use zabbix-cli but I am probably doing something wrong:

❯ zabbix-cli
Traceback (most recent call last):
  File "/home/faust/.venv/bin/zabbix-cli", line 5, in <module>
    from zabbix_cli.main import main
  File "/home/faust/.venv/lib/python3.12/site-packages/zabbix_cli/__init__.py", line 5, in <module>
    patch_all()
  File "/home/faust/.venv/lib/python3.12/site-packages/zabbix_cli/_patches/__init__.py", line 8, in patch_all
    typer.patch()
  File "/home/faust/.venv/lib/python3.12/site-packages/zabbix_cli/_patches/typer.py", line 314, in patch
    patch_help_text_spacing()
  File "/home/faust/.venv/lib/python3.12/site-packages/zabbix_cli/_patches/typer.py", line 63, in patch_help_text_spacing
    from typer.rich_utils import _make_rich_rext
ImportError: cannot import name '_make_rich_rext' from 'typer.rich_utils' (/home/faust/.venv/lib/python3.12/site-packages/typer/rich_utils.py). Did you mean: '_make_rich_text'?

I am on Alpine Linux 3.20.

I also tested it in various Debian version (11 and 12), same problem, see below:

❯ podman run -it debian:11 bash
root@953854425d06:/# apt update && apt upgrade -y && apt install -y curl
root@953854425d06:/# curl -LsSf https://astral.sh/uv/install.sh | sh
root@953854425d06:/# source $HOME/.local/bin/env
root@953854425d06:/# uv tool install zabbix-cli-uio
root@953854425d06:/# zabbix-cli
Traceback (most recent call last):
  File "/root/.local/bin/zabbix-cli", line 5, in <module>
    from zabbix_cli.main import main
  File "/root/.local/share/uv/tools/zabbix-cli-uio/lib/python3.13/site-packages/zabbix_cli/__init__.py", line 5, in <module>
    patch_all()
    ~~~~~~~~~^^
  File "/root/.local/share/uv/tools/zabbix-cli-uio/lib/python3.13/site-packages/zabbix_cli/_patches/__init__.py", line 8, in patch_all
    typer.patch()
    ~~~~~~~~~~~^^
  File "/root/.local/share/uv/tools/zabbix-cli-uio/lib/python3.13/site-packages/zabbix_cli/_patches/typer.py", line 314, in patch
    patch_help_text_spacing()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/root/.local/share/uv/tools/zabbix-cli-uio/lib/python3.13/site-packages/zabbix_cli/_patches/typer.py", line 63, in patch_help_text_spacing
    from typer.rich_utils import _make_rich_rext
ImportError: cannot import name '_make_rich_rext' from 'typer.rich_utils' (/root/.local/share/uv/tools/zabbix-cli-uio/lib/python3.13/site-packages/typer/rich_utils.py)

What am I doing wrong (or am I hitting a buggy dependency?).

pederhan commented 3 days ago

Hm, that is weird. I bumped the minimum Typer requirement to 0.13.1, which changed this internal name (https://github.com/fastapi/typer/pull/959). Somehow I must have forgotten to commit this change before building the newest version. I'll build a new version shortly that fixes this.

I'll also look into adding a compatibility shim and make that more robust (we shouldn't use internal functions from other libraries, but Typer is not very customizable, so we have to use some dirty hacks).

fauust commented 3 days ago

thanks @pederhan !

pederhan commented 3 days ago

Fixed in https://github.com/unioslo/zabbix-cli/releases/tag/3.4.0. Thanks for bringing this to my notice!