the-virtual-brain / tvb-gdist

Geodesic Library (adaptation by TVB Team)
Other
47 stars 30 forks source link

Build fails on macOS 12.6 #74

Open maedoc opened 1 year ago

maedoc commented 1 year ago

Build fails on macOS 12.6 with CLI tools installed,

% pipenv install tvb-gdist
Installing tvb-gdist...
⠋ Installing tvb-gdist...[31m[1mError: [0m An error occurred while installing [32mtvb-gdist[0m!
Error text: Collecting tvb-gdist
  Using cached tvb-gdist-2.1.0.tar.gz (115 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: numpy in /Users/duke/.local/share/virtualenvs/tvb_library-PXIrKLig/lib/python3.9/site-packages (from tvb-gdist->-r 
/var/folders/pd/lgy721hs7cv0rrldbwqr935m0000gn/T/pipenv-de7z428p-requirements/pipenv-4jx2ayvq-requirement.txt (line 1)) (1.23.5)
Collecting cython
  Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
Requirement already satisfied: scipy in /Users/duke/.local/share/virtualenvs/tvb_library-PXIrKLig/lib/python3.9/site-packages (from tvb-gdist->-r 
/var/folders/pd/lgy721hs7cv0rrldbwqr935m0000gn/T/pipenv-de7z428p-requirements/pipenv-4jx2ayvq-requirement.txt (line 1)) (1.9.3)
Building wheels for collected packages: tvb-gdist
  Building wheel for tvb-gdist (pyproject.toml): started
  Building wheel for tvb-gdist (pyproject.toml): finished with status 'error'
Failed to build tvb-gdist

[36m  error: subprocess-exited-with-error

  × Building wheel for tvb-gdist (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'gdist' extension
      creating build
      creating build/temp.macosx-10.9-universal2-cpython-39
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders 
-iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DNDEBUG=1 
-I/private/var/folders/pd/lgy721hs7cv0rrldbwqr935m0000gn/T/pip-build-env-m4jg5tpq/overlay/lib/python3.9/site-packages/numpy/core/include -Igeodesic_library 
-I/private/var/folders/pd/lgy721hs7cv0rrldbwqr935m0000gn/T/pip-build-env-m4jg5tpq/overlay/lib/python3.9/site-packages/numpy/core/include -I/Users/duke/.local/share/virtualenvs/tvb_library-PXIrKLig/include
-I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c gdist.cpp -o build/temp.macosx-10.9-universal2-cpython-39/gdist.o --std=c++1y
      gdist.cpp:47:10: fatal error: 'Python.h' file not found
      #include "Python.h"
               ^~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tvb-gdist
ERROR: Could not build wheels for tvb-gdist, which is required to install pyproject.toml-based projects
[0m
✘ Installation Failed

It seems one needs to find the right header file location, then build

% Python_h=$(find /Library/Developer/CommandLineTools -name Python.h | grep $(python3 -V | cut -f2 -d' ' | cut -f1,2 -d.))
% export CFLAGS="-I $(dirname $Python_h)"
% pipenv install tvb-gdist
Installing tvb-gdist...
Pipfile.lock (02a170) out of date, updating to (6c0d9d)...
Locking [packages] dependencies...
Locking [dev-packages] dependencies...
Updated Pipfile.lock (8f184b89cda8dbd60f3d0ae9b31a0507799ae7275aab844b34fda017436c0d9d)!
Installing dependencies from Pipfile.lock (6c0d9d)...
% python3 -c 'import gdist'
maedoc commented 1 year ago