afewmail / afew

an initial tagging script for notmuch mail
ISC License
325 stars 97 forks source link

Instructions on how to install `afew` with Python3.12(.3) #346

Open xaltsc opened 1 month ago

xaltsc commented 1 month ago

Hey,

As for my particular setup, I'm running Alpine with Python3.12.3. I couldn't find a way to (re)install afew as an unprivileged user.

I'm looking to install any version post the latest release, but the latest possible one would be ideal.

I essentially followed instructions here https://afew.readthedocs.io/en/latest/installation.html (with commit a3f6f6a as suggested by @GuillaumeSeren on IRC) and variations thereof, i.e.

$ python -m venv --system-site-packages .venv
$ source .venv/bin/activate
$ python setup.py install --prefix=~/.local

for which $ afew gives the following error

Traceback (most recent call last):
  File "/srv/user/.local/bin/afew", line 33, in <module>
    sys.exit(load_entry_point('afew==3.0.2.dev61+ga3f6f6a', 'console_scripts', 'afew')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/user/.local/bin/afew", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/srv/user/.local/lib/python3.12/site-packages/afew-3.0.2.dev58+gcbe4cdf-py3.12.egg/afew/commands.py", line 9, in <module>
    from afew.Database import Database
  File "/srv/user/.local/lib/python3.12/site-packages/afew-3.0.2.dev58+gcbe4cdf-py3.12.egg/afew/Database.py", line 8, in <module>
    import notmuch
  File "/srv/user/afew/.venv/lib/python3.12/site-packages/notmuch/__init__.py", line 54, in <module>
    from .database import Database
  File "/srv/user/afew/.venv/lib/python3.12/site-packages/notmuch/database.py", line 24, in <module>
    from .compat import SafeConfigParser
  File "/srv/user/afew/.venv/lib/python3.12/site-packages/notmuch/compat.py", line 50, in <module>
    from configparser import SafeConfigParser
ImportError: cannot import name 'SafeConfigParser' from 'configparser' (/usr/lib/python3.12/configparser.py). Did you mean: 'RawConfigParser'?
$ python -m venv  .venv
$ source .venv/bin/activate
$ pip install setuptools
$ pip install notmuch
$ python setup.py install --prefix=~/.local

for which $ afew gives the following error

Traceback (most recent call last):
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 397, in from_name
    return next(cls.discover(name=name))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/user/.local/bin/afew", line 33, in <module>
    sys.exit(load_entry_point('afew==3.0.2.dev61+ga3f6f6a', 'console_scripts', 'afew')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/user/.local/bin/afew", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 862, in distribution
    return Distribution.from_name(distribution_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 399, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for afew

I also tried to just pipx install afew with which running $ afew gives the following error:

Traceback (most recent call last):
  File "/srv/user/.local/bin/afew", line 5, in <module>
    from afew.commands import main
  File "/srv/user/.local/share/pipx/venvs/afew/lib/python3.12/site-packages/afew/commands.py", line 9, in <module>
    from afew.Database import Database
  File "/srv/user/.local/share/pipx/venvs/afew/lib/python3.12/site-packages/afew/Database.py", line 8, in <module>
    import notmuch
  File "/srv/user/.local/share/pipx/venvs/afew/lib/python3.12/site-packages/notmuch/__init__.py", line 54, in <module>
    from .database import Database
  File "/srv/user/.local/share/pipx/venvs/afew/lib/python3.12/site-packages/notmuch/database.py", line 24, in <module>
    from .compat import SafeConfigParser
  File "/srv/user/.local/share/pipx/venvs/afew/lib/python3.12/site-packages/notmuch/compat.py", line 50, in <module>
    from configparser import SafeConfigParser
ImportError: cannot import name 'SafeConfigParser' from 'configparser' (/usr/lib/python3.12/configparser.py). Did you mean: 'RawConfigParser'?

pipx install --python 3.11 --fetch-missing-python afew also fails because musl.

GuillaumeSeren commented 1 month ago

Hey @xaltsc , Can you try with a newer release like 3.0.1 + python3.12 ?

I think at least some of those issue where fixed already, also try a isolated venv without using system libs

xaltsc commented 1 month ago

The first two with 3.0.1 give the exact same errors.

What do you exactly mean by "an isolated venv without using system libs" ?

hendursaga commented 1 week ago

This looks like a duplicate of #341. See https://docs.python.org/3/whatsnew/3.12.html#configparser for why the error is shown.