Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xaltsc opened this issue Jul 19, 2024 · 4 comments
Open

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

xaltsc opened this issue Jul 19, 2024 · 4 comments

Comments

@xaltsc
Copy link

xaltsc commented Jul 19, 2024

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
Copy link
Collaborator

GuillaumeSeren commented Jul 20, 2024

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
Copy link
Author

xaltsc commented Jul 27, 2024

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
Copy link

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

@kofm
Copy link

kofm commented Nov 8, 2024

The way I've managed to make it work is to:
a) amend the readfp method call to read_file as per the link posted by @hendursaga suggests (see above pull request).
b) also amend the notmuch-python-bindings to accomodate the changes in configparser

If you have both the amended repos on your local paths you can:

pipx install /path/to/afew
pipx inject --force afew /path/to/notmuch-python-bindings
pipx inject afew setuptools

Now should work correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants