libp2p / libp2p/py-libp2p

Build failure on MacOS requires manual overrides

Open
#519 6 comments 1 reaction 1 assignee View on GitHub

@dhuseby is already working on this.

Since Feb 26, 2025.

Dominant language
Python
Stars
624
Forks
256
Avg merge
1d 34m
Merged PRs (30d)
47

Description

Summary

I used brew to install cmake, pkg-config, and libgmp (i.e. brew install cmake pkg-config gmp

I then followed the instructions to do the install step and the fastecdsa build is failing because it can't find the gmp.h header file. The file does exist:

%. pkg-config --cflags gmp
-I/opt/homebrew/Cellar/gmp/6.3.0/include

% ls /opt/homebrew/Cellar/gmp/6.3.0/include
gmp.h	gmpxx.h

For some reason the cmake files and/or the fastecdsa build files aren't picking up the pkg-config paths for gmp.

Expected behavior

The python3 -m pip install -e ".[dev]" command completes successfully if the dependencies are installed.

Actual behavior

For some reason the cmake files or the build files for fastecdsa are not picking up the pkg-config include flags. The error shows that it's running the following command:

clang -fno-strict-overflow -Wsign-compare -Wunreachable-code \
    -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Isrc/ \
    -I/Users/paperaviation/py-libp2p/venv/include \
    -I/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/include/python3.13 \
    -c src/curve.c -o build/temp.macosx-15.0-arm64-cpython-313/src/curve.o -O2


      In file included from src/curve.c:1:
      src/curve.h:4:10: fatal error: 'gmp.h' file not found
          4 | #include "gmp.h"
            |          ^~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
Relevant log output
N/A
Possible Solution

I was able to get it to build though by manually adding in the CFLAGS and LDFLAGS like so:

% CFLAGS="`pkg-config --cflags gmp`" LDFLAGS="`pkg-config --libs gmp`" python3 -m pip install -e ".[dev]"

I'm not sure what the fix is other than to do it the hard way.

Environment
Python version:
3.13.1 (main, Dec  3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)]

Operating System: macOS-15.3.1-arm64-arm-64bit-Mach-O

python -m pip freeze result:
alabaster==1.0.0
annotated-types==0.7.0
anyio==1.4.0
asn1crypto==1.5.1
asttokens==3.0.0
async-exit-stack==1.0.1
async-generator==1.10
attrs==25.1.0
babel==2.17.0
base58==2.1.1
bracex==2.5.post1
build==1.2.2.post1
bump-my-version==0.32.2
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
coincurve==20.0.0
colorama==0.4.6
cryptography==44.0.1
cytoolz==1.0.1
decorator==5.2.1
distlib==0.3.9
docutils==0.21.2
eth-hash==0.7.1
eth-typing==5.2.0
eth-utils==5.2.0
execnet==2.1.1
executing==2.2.0
factory-boy==2.12.0
Faker==36.1.1
fastecdsa==1.7.5
filelock==3.17.0
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
id==1.5.0
identify==2.6.8
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.0.0
ipython==8.32.0
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jedi==0.19.2
Jinja2==3.1.5
keyring==25.6.0
-e git+https://github.com/libp2p/py-libp2p@d7eab27564fbc104bd862a678088a4facf7cdb80#egg=libp2p
lru-dict==1.3.0
markdown-it-py==3.0.0
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mdurl==0.1.2
more-itertools==10.6.0
multiaddr==0.0.9
mypy==1.10.0
mypy-extensions==1.0.0
mypy-protobuf==3.6.0
netaddr==1.3.0
nh3==0.2.20
nodeenv==1.9.1
noiseprotocol==0.3.1
outcome==1.3.0.post0
p2pclient==0.2.0
packaging==24.2
parso==0.8.4
pexpect==4.9.0
platformdirs==4.3.6
pluggy==1.5.0
pre_commit==4.1.0
prompt_toolkit==3.0.50
protobuf==5.29.3
ptyprocess==0.7.0
pure_eval==0.2.3
pycparser==2.22
pycryptodome==3.21.0
pydantic==2.10.6
pydantic-settings==2.8.0
pydantic_core==2.27.2
Pygments==2.19.1
pymultihash==0.8.2
PyNaCl==1.5.0
pyproject-api==1.9.0
pyproject_hooks==1.2.0
pytest==8.3.4
pytest-trio==0.8.0
pytest-xdist==3.6.1
python-dotenv==1.0.1
PyYAML==6.0.2
questionary==2.1.0
readme_renderer==44.0
requests==2.32.3
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==13.9.4
rich-click==1.8.6
roman-numerals-py==3.1.0
rpcudp==5.0.0
six==1.17.0
sniffio==1.3.1
snowballstemmer==2.2.0
sortedcontainers==2.4.0
Sphinx==8.2.1
sphinx-rtd-theme==3.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
stack-data==0.6.3
tomlkit==0.13.2
toolz==1.0.0
towncrier==24.8.0
tox==4.24.1
traitlets==5.14.3
trio==0.29.0
trio-typing==0.10.0
twine==6.1.0
types-protobuf==5.29.1.20250208
typing_extensions==4.12.2
tzdata==2025.1
u-msgpack-python==2.8.0
urllib3==2.3.0
varint==1.0.2
virtualenv==20.29.2
wcmatch==10.0
wcwidth==0.2.13
wheel==0.45.1
zipp==3.21.0
Would you like to work on fixing this bug ?

Maybe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.