How to install mercurial_keyring?

I installed ‘mercurial’ from the official repositories (extra).

I run TortoiseHg from source because it has an annoying bug that they don’t seem to be willing to fix, for which the fix is just a one-line change in the source code; so I patch it myself, then every once in a while I update it and patch it again, and so on.

Everything else required by TortoiseHg and Mercurial I have installed with Pamac.

I need the mercurial_keyring extension but there doesn’t seem to be a package for that (not in the AUR either).

So I tried pip install --user mercurial_keyring but I get this error:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

The second paragraph (create a virtual environment) seems like a viable solution; however, if I do that, I don’t know how to tell Mercurial and TortoiseHg to use the python in the virtual environment rather than the system-wide one…

Why not third paragraph? Or you can create your own PKGBUILDs.

Because mercurial_keyring is not an application, I think? It’s a mercurial extension.
And ssuming tortoisehg exists as a pipx application, that wouldn’t be a solution because as I mentioned I need to run it from source.

Unless I’m missing something.

It takes you 3 minutes to try it.

:person_facepalming: I had missed this note at the end of the output from pip install :

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.

(bold added by me) I missed it because I stopped reading after “if you believe this is a mistake please contact…”

That’s the solution that I was looking for and it worked.
So, that was:

pip install --user --break-system-packages mercurial_keyring

after having installed as many dependencies as possible from Pamac (which were correctly recognized as already satisfied packages).