Setting up Electrum on OpenBSD 7.8
I recently had a need to install the Electrum bitcoin wallet on OpenBSD. I was hoping I could simply doas pkg_add electrum but nope! I had to install from source. Even one of the dependencies, in particular the secp256k1 library, needed to be built from source as well.
Note that I have not independently verified this on another OpenBSD 7.8 system, so there very well could be missing dependencies.
Steps
1. Download Electrum Source: download the .tar.gz file from https://electrum.org/#download with signature, and verify the signature with gpg --verify Electrum-4.7.1.tar.gz.asc. If you import ThomasV's GnuPG key using the link at the top and then run gpg --fingerprint 'thomas voegtlin', you should see the fingerprint of his 2011 key: 6694 D8DE 7BE8 EE56 31BE D950 2BD5 824B 7F94 70E6.
2. Setup a Python virtualenv (virtual environment): Create a directory, say ~/manual_build/electrum and cd into it. Run python3 -m venv venv and then source venv/bin/activate (this last step will have to happen for each new Terminal window). The goal now is to be able to run python3 -m pip install ~/Downloads/Electrum-4.7.1.tar.gz followed by electrum to launch it, however you need dependencies. This is where sh*t gets real..
3. Install a few packaged dependencies: doas pkg_add autoconf automake libtool cmake py3-cryptography py3-qt6.
4. Download and build secp256k1: go to the releases page for secp256k1 and download the .tar.gz file for v0.6.0. cd into ~/manual_build and extract it with tar xzf v0.6.0.tar.gz and cd secp256k1-0.6.0. Here is the doozy of a command: cmake -B build -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON && cmake --build build && ctest --test-dir build && doas cmake --install build.
5. Continue with the Python virtualenv: back in ~/manual_build/electrum, ensure you are still in the virtualenv, and now edit venv/pyvenv.cfg to change include-system-site-packages to true. This feels a little naughty but oh well. Finally, now you should be able to run python3 -m pip install ~/Downloads/Electrum-4.7.1.tar.gz and launch electrum.
Conclusion
I hope this was helpful to someone. If you have any praise, scorn, or corrections, please reply to my Mastodon post.