rndusr / stig

TUI and CLI for the BitTorrent client Transmission
GNU General Public License v3.0
554 stars 24 forks source link

Python 3.11 #232

Closed mikaelz closed 1 year ago

mikaelz commented 1 year ago

Hi, please help.

Installed stig version 0.12.3a0 Arch Linux updated Python to 3.11.3

now I'm getting the following error

Traceback (most recent call last):
  File "/usr/bin/stig", line 33, in <module>
    sys.exit(load_entry_point('stig==0.12.3a0', 'console_scripts', 'stig')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/stig/__init__.py", line 25, in run
    main.run()
  File "/usr/lib/python3.11/site-packages/stig/main.py", line 102, in run
    if not tui.run(run_commands):
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/stig/tui/main.py", line 60, in run
    tuiobjects.urwidloop.run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 320, in run
    self._run()
  File "/usr/lib/python3.11/site-packages/urwid/event_loop/main_loop.py", line 423, in _run
    self.event_loop.run()
  File "/usr/lib/python3.11/site-packages/stig/tui/urwidpatches.py", line 193, in run
    if self._exc_info:
       ^^^^^^^^^^^^^^
AttributeError: 'AsyncioEventLoop_patched' object has no attribute '_exc_info'
rndusr commented 1 year ago

Works for me:

$ python3 --version
Python 3.11.3
$ stig
[TUI is running]

How do I reproduce this?

I think I fixed it in the master branch (maybe you can pull and confirm?), but I'm curious how you got to this issue.

mikaelz commented 1 year ago

Using Arch Linux, https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=stig It's using the https://github.com/rndusr/stig/archive/v0.12.3a0.tar.gz

stig starts but hangs, doesn't connect to transmission, when I quit stig the traceback is shown

rndusr commented 1 year ago

I'm not going to install Arch.

blibers commented 1 year ago

Hey rndusr!

I was having the same issue that mikaelz described before the last commit on Artix It seems to be partially fixed now, I mean, I can start the application, but the screen is not being properly updated. If start stig, it "freezes" and updates only when the window is resized. If I type any commands, it seems that the screen is lagging one frame behind. Sorry about the terminology, I'm not a developer so it's hard for me to describe. I can record the issue if it helps.

PS: thanks for your hardwork! I've been using stig for about two years now, and it's one of my favorite apps! I just love the vim way of managing my torrents. Just out of curiosity since you snobbed Arch lol, which OS are you currently using?

rndusr commented 1 year ago

Thank you for testing.

I assume you used the current master to get this new issue?

Which urwid version are you using?

I think I can imagine the issue from your explanation, so no need to record.

I'm using Debian, so I'm probably behind in some way. But I'm using pyenv got run Python 3.11.3 and I'm installing all the latest Python packages from pypi. I'm not sure what could cause this.

mikaelz commented 1 year ago

On a different system I didn't update and stig works in Arch Linux

Spotted that mentioned urwid was updated to python-urwid-2.1.2.r56.gabc098c-1 The following packages upgrade might cause the issue

python-3.11.3-1
python-aiohttp-3.8.3-6
python-aiosignal-1.3.1-3
python-appdirs-1.4.4-8
python-asn1crypto-1.5.1-2
python-async-timeout-4.0.2-3
python-attrs-22.2.0-3
python-autocommand-2.2.2-4
python-blinker-1.5-2
python-cachecontrol-1:0.12.11-2
python-certifi-2022.12.07-3
python-cffi-1.15.1-3
python-chardet-5.1.0-3
python-charset-normalizer-3.1.0-3
python-colorama-0.4.6-2
python-commonmark-0.9.1-9
python-contextlib2-21.6.0-2
python-cryptography-40.0.2-1
python-defusedxml-0.7.1-5
python-distlib-0.3.6-3
python-distro-1.8.0-3
python-docutils-1:0.19-6
python-fastjsonschema-2.16.3-4
python-frozenlist-1.3.3-2
python-future-0.18.2-8
python-html5lib-1.1-12
python-idna-3.4-3
python-inflect-6.0.4-2
python-jaraco.context-4.3.0-3
python-jaraco.functools-3.6.0-3
python-jaraco.text-3.11.1-3
python-markdown-it-py-2.2.0-3
python-mdurl-0.1.2-4
python-more-itertools-9.1.1-4
python-msgpack-1.0.4-2
python-multidict-6.0.4-2
python-natsort-8.3.1-2
python-nspektr-0.4.0-3
python-ordered-set-4.1.0-4
python-packaging-23.0-3
python-pip-23.1.2-1
python-platformdirs-3.5.0-2
python-ply-3.11-12
python-psutil-5.9.5-1
python-pycparser-2.21-5
python-pydantic-1.10.7-4
python-pygments-2.15.1-1
python-pyopenssl-23.1.1-2
python-pyparsing-3.0.9-3
python-pyxdg-0.28-2
python-requests-2.28.2-4
python-resolvelib-1.0.1-1
python-retrying-1.3.3-16
python-rich-13.3.5-1
python-setuptools-1:67.7.0-1
python-six-1.16.0-8
python-tenacity-8.2.2-3
python-toml-0.10.2-9
python-tomli-2.0.1-3
python-trove-classifiers-2023.4.22-1
python-typing_extensions-4.5.0-4
python-uc-micro-py-1.0.1-4
python-ujson-5.7.0-2
python-urllib3-1.26.15-1
python-urwid-2.1.2.r56.gabc098c-1
python-urwidtrees-1.0.3-9
python-validate-pyproject-0.12.2-3
python-webencodings-0.5.1-10
python-wheel-0.40.0-3
rndusr commented 1 year ago

Spotted that mentioned urwid was updated to python-urwid-2.1.2.r56.gabc098c-1

Thank you, looks like that's it. I can reproduce the "TUI is not updated periodically" issue by installing urwid master:

pip install https://github.com/urwid/urwid/archive/master.tar.gz --force

It is most likely related to this breaking change: https://github.com/urwid/urwid/pull/541

You are essentially running urwid 3.0 while it is still labeled 2.1.2.

You should be able to fix this by installing the proper 2.1.2 version.

I'll look into it, but I'm not sure how much work it is and I'd rather work on the rewrite.

mikaelz commented 1 year ago

Tried downgrading to python-urwidtrees-1.0.3-8 and python-urwid-2.1.2.r55.gbac20db, but

$ stig
Traceback (most recent call last):
  File "/usr/bin/stig", line 33, in <module>
    sys.exit(load_entry_point('stig==0.12.3a0', 'console_scripts', 'stig')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/stig/__init__.py", line 25, in run
    main.run()
  File "/usr/lib/python3.11/site-packages/stig/main.py", line 102, in run
    if not tui.run(run_commands):
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/stig/tui/main.py", line 36, in run
    from . import hooks  # noqa
    ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/stig/tui/hooks.py", line 17, in <module>
    from .views.file import TUICOLUMNS as FILE_COLUMNS
  File "/usr/lib/python3.11/site-packages/stig/tui/views/__init__.py", line 16, in <module>
    from .file_list import FileItemWidget, FileListWidget
  File "/usr/lib/python3.11/site-packages/stig/tui/views/file_list.py", line 16, in <module>
    import urwidtrees
ModuleNotFoundError: No module named 'urwidtrees'

Tried also downgrade to python-3.10.10-1, but then

 $ stig
Traceback (most recent call last):
  File "/usr/bin/stig", line 33, in <module>
    sys.exit(load_entry_point('stig==0.12.3a0', 'console_scripts', 'stig')())
  File "/usr/bin/stig", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 969, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 548, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for stig

I'm a PHP dev so don't know how package dependencies and their caching works in python :/

rndusr commented 1 year ago

As far as I can tell, this issue is not related to Python or urwidtrees, only urwid.

Install all packages as they were previously. Then remove the urwid package and somehow install the official current urwid release (2.1.2 without any of that rXX.yaddayadda).

Alternatively, uninstall aur-stig, install pipx and run:

$ pipx install stig

This will install stig with all dependencies in ~/.local/pipx/venvs/stig and you can remove all that by running:

$ pipx uninstall stig

The Arch package maintainer switched to installing urwid from github, which introduced the breaking change I linked above. That should have increased the major version to 3.x.x, but it's still 2.1.x.

Anything before this commit should be ok: https://github.com/archlinux/svntogit-packages/commit/01b97d342b0ad5bf35ac5a08d729ba1e6765525e

rndusr commented 1 year ago

I can start the application, but the screen is not being properly updated.

This should be mostly fixed.

I had to redraw the screen manually on key presses and list updates. There are probably more places where a manual redraw is required, but I couldn't find any.

blibers commented 1 year ago

Oh wow, you nailed it! Uninstalling urwid from pacman and installing using pip solved the issue Thank you!

rndusr commented 1 year ago

I made a new release with the fix.

mikaelz commented 1 year ago

Awesome, thank you very much. The new git version works.