ElementsProject/lightning

nix build on recent master fails

vincenzopalazzo opened this issue · 2 comments

configure: error: cannot import Python module "distutils".
Please check your Python installation. The error was:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'distutils'
make: *** [external/Makefile:88: external/build-x86_64-unknown-linux-gnu/libwally-core-build/src/secp256k1/libsecp256k1.la] Error 1
make: *** Waiting for unfinished jobs....
yes
checking whether C compiler accepts -mavx512f... yes
checking for AVX512F instructions set... yes
checking whether C compiler accepts -mavx512f... (cached) yes

I also ran into an error when building in a nix shell under NixOS 24.05:

python3 -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/node.proto --python_out=contrib/pyln-grpc-proto/pyln/grpc/ --grpc_python_out=contrib/pyln-grpc-proto/pyln/grpc/ --experimental_allow_proto3_optional
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/user/.cache/pypoetry/virtualenvs/cln-meta-project-eKO3ra09-py3.11/lib/python3.11/site-packages/grpc_tools/protoc.py", line 20, in <module>
    from grpc_tools import _protoc_compiler
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
make: *** [Makefile:394: contrib/pyln-grpc-proto/pyln/grpc/primitives_pb2.py] Error 1
make: *** Waiting for unfinished jobs....

I tried around with installing a lot of different nix and python packages, but wasn't able to get rid of this error. The closest I've come was to add the missing python package mako and remove duplicates in the nix-shell command:

diff --git a/doc/getting-started/getting-started/installation.md b/doc/getting-started/getting-started/installation.md
index fba2a3e8b..6a187165d 100644
--- a/doc/getting-started/getting-started/installation.md
+++ b/doc/getting-started/getting-started/installation.md
@@ -314,8 +314,8 @@ Finally, build `c-lightning`:
 Use nix-shell launch a shell with a full Core Lightning dev environment:
 
 ```shell
-nix-shell -Q -p gdb sqlite autoconf git clang libtool sqlite autoconf \
-autogen automake gmp zlib gettext libsodium poetry 'python3.withPackages (p: [p.bitcoinlib])' \
+nix-shell -Q -p gdb autoconf git clang libtool sqlite \
+autogen automake gmp zlib gettext libsodium poetry 'python3.withPackages (p: [p.bitcoinlib p.mako])' \
 valgrind --run "./configure && poetry shell"
 poetry install
 make

My guess is that I need to manually add a library to python in the shell along the lines of this post, but that's where my nix abilities end.

Still need to look into it, but thanks for this diff will be really helpful