Python: use PyQt6 within an virtual environment (venv)

Still no success with with flakes (at least not when pyqt6-webengine is included), even after hours including the xth libraries and debugging…

But my newest approach works with setting PYTHONHOME (thanks to the idea from here):

  1. Make nix-shell including packages: nix-shell -p 'python312.withPackages (p: [ p.pyqt6 p.pyqt6-webengine ])'
  2. Create venv including site packages: python -m venv --system-site-packages .venv
  3. Activate: . .venv/bin/activate
  4. Get derivation path: which python (e.g. /nix/store/am5...-python3-3.12.12-env/bin/python)
  5. Set PYTHONHOME to the env: export PYTHONHOME=/nix/store/am5...-python3-3.12.12-env (excluding /bin/python)
  6. Voila! Feel free to install additional packages with pip