Issue running binaries compiled using current git head on Arch linux within a venv

Hello,

I didn’t create this in the github because of the text that directs non-contributors to avoid doing so. I understand building from source is a niche activity. I am compelled either way to install Anki within a venv due to a plugin that requires this (due to some python dependencies they import conflicting with system packages), and because future commits seem likely to break that plugin (for other reasons). I like to compile against the current development head to track when exactly that happens (so I can stay at the most recent head where it works while I work on a fix).

libxml2 was updated recently on Arch. When I build within a .venv it will build fine, but when I go to run the resulting binaries, I get an error:

hearth@hearth ~/D/a/anki (main)> anki
Traceback (most recent call last):
  File "/usr/bin/anki", line 5, in <module>
    from aqt import run
  File "/home/hearth/Development/anki/ankienv/lib/python3.12/site-packages/aqt/__init__.py", line 63, in <module>
    from aqt import gui_hooks
  File "/home/hearth/Development/anki/ankienv/lib/python3.12/site-packages/aqt/gui_hooks.py", line 11, in <module>
    from _aqt.hooks import *
  File "/home/hearth/Development/anki/ankienv/lib/python3.12/site-packages/_aqt/hooks.py", line 18, in <module>
    from aqt.qt import QDialog, QEvent, QMenu, QModelIndex, QWidget, QMimeData
  File "/home/hearth/Development/anki/ankienv/lib/python3.12/site-packages/aqt/qt/__init__.py", line 22, in <module>
    from .qt6 import *
  File "/home/hearth/Development/anki/ankienv/lib/python3.12/site-packages/aqt/qt/qt6.py", line 19, in <module>
    from PyQt6.QtWebEngineCore import *
ImportError: libxml2.so.2: cannot open shared object file: No such file or directory

This implies something Anki is pulling is compiled against the old version. This happens regardless of whether I create the venv with --system-site-packages or not, and regardless of whether I run from a symlink under /usr/bin/anki, the anki binary in the venv with the venv sourced (eg. ankienv/bin/anki), or the runanki script under the qt directory.

Interestingly, the AUR anki-git package builds and also runs fine. The main difference I notice in it (besides setting clang directly) compared to what I am doing is its pip install call:

PIP_CONFIG_FILE=/dev/null pip install --isolated --root="$pkgdir" --ignore-installed --no-warn-script-location --root-user-action=ignore --no-deps out/wheels/*.whl

This lead me to discover that running pip install with --isolated resolves the issue. However, it’s not clear to me exactly why it resolves the issue, where running pip install within the venv does not. I notice that running with uv via uv pip install --isolated --upgrade out/wheels/*.whl also doesn’t work, even with --no-config/--isolated.

Any pointers on what exactly might cause this issue would be warmly welcomed.

Hmm, now I am a bit confused.

Earlier, the --isolated flag made the installed binaries work. I also tried building against the most recent tagged release and the two current beta tags. These worked without the --isolated flag. However, some time passed, and the same binary that worked before no longer works! I now cannot produce a working build at all form inside a venv.

Further updates:

  • Any venv created with virtualenv don’t work.
  • Any venv created with python -m venv work, regardless of pip --isolated, but only for python 3.13. This is a problem for me, as one of the plugin’s dependencies is tied to python 3.12, and it’s unclear how soon there will be a version bump…

I suppose it may be unlikely/unexpectable that versions under 3.12 will be updated to work with newer libxml2 versions. As such I would imagine my options are to link against the old libxml2 (which seems a pretty bad idea on a system level on a desktop system), to figure out how to make some compatibility library linked specifically/only for the relevant binaries, or to downgrade Anki to an older version (I hadn’t updated for a while, hence only noticing these issues in the last day.)

Further edit: scratch that, it’s back to not working again, with exactly the same conditions!