pytries / marisa-trie

Static memory-efficient Trie-like structures for Python based on marisa-trie C++ library.
https://marisa-trie.readthedocs.io/en/latest/
MIT License
1.03k stars 91 forks source link

Build fails on MacOS Mojave, January 2019 #50

Closed djbpitt closed 3 years ago

djbpitt commented 5 years ago

I don't know whether this is user error, a return of Issue #34, or something new (since #34 seems to have been closed as resolved), but I just tried and failed to build marisa-trie under MacOS Mojave. Details below.

Vombatus:SciFi djb$ pip install marisa-trie
Collecting marisa-trie
  Using cached https://files.pythonhosted.org/packages/20/95/d23071d0992dabcb61c948fb118a90683193befc88c23e745b050a29e7db/marisa-trie-0.7.5.tar.gz
Building wheels for collected packages: marisa-trie
  Running setup.py bdist_wheel for marisa-trie ... error
  Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/46/5fcnvzts14527hn_3ryrqr100000gn/T/pip-install-f2s2mhpn/marisa-trie/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/46/5fcnvzts14527hn_3ryrqr100000gn/T/pip-wheel-syviv4xc --python-tag cp37:
  running bdist_wheel
  running build
  running build_clib
  building 'libmarisa-trie' library
  creating build
  creating build/temp.macosx-10.7-x86_64-3.7
  creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie
  creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib
  creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa
  creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire
  creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire/io
  creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire/trie
  creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire/vector
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/trie.cc -o build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/trie.o
  warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
  In file included from marisa-trie/lib/marisa/trie.cc:1:
  marisa-trie/include/marisa/stdio.h:4:10: fatal error: 'cstdio' file not found
  #include <cstdio>
           ^~~~~~~~
  1 warning and 1 error generated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for marisa-trie
  Running setup.py clean for marisa-trie
Failed to build marisa-trie
Installing collected packages: marisa-trie
  Running setup.py install for marisa-trie ... error
    Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/46/5fcnvzts14527hn_3ryrqr100000gn/T/pip-install-f2s2mhpn/marisa-trie/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/46/5fcnvzts14527hn_3ryrqr100000gn/T/pip-record-539k0cjv/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_clib
    building 'libmarisa-trie' library
    creating build
    creating build/temp.macosx-10.7-x86_64-3.7
    creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie
    creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib
    creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa
    creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire
    creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire/io
    creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire/trie
    creating build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/grimoire/vector
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -Imarisa-trie/lib -Imarisa-trie/include -c marisa-trie/lib/marisa/trie.cc -o build/temp.macosx-10.7-x86_64-3.7/marisa-trie/lib/marisa/trie.o
    warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
    In file included from marisa-trie/lib/marisa/trie.cc:1:
    marisa-trie/include/marisa/stdio.h:4:10: fatal error: 'cstdio' file not found
    #include <cstdio>
             ^~~~~~~~
    1 warning and 1 error generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/46/5fcnvzts14527hn_3ryrqr100000gn/T/pip-install-f2s2mhpn/marisa-trie/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/46/5fcnvzts14527hn_3ryrqr100000gn/T/pip-record-539k0cjv/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/46/5fcnvzts14527hn_3ryrqr100000gn/T/pip-install-f2s2mhpn/marisa-trie/
bodak commented 5 years ago

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg from https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave

plus export MACOSX_DEPLOYMENT_TARGET=10.9

djbpitt commented 5 years ago

@bodak Thank you! Working now!

To summarize, I needed to:

  1. Install updated command-line tools, as described at the link above.
  2. Set export CPATH=/Library/Developer/CommandLineTools/usr/include/c++/v1, as described in Nigel’s response at https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave.
upagupta2003 commented 4 years ago

This error came back with the upgrade to macOS-Cataline in December 2019.

peteriz commented 4 years ago

for macOS Catalina this worked for me:

upagupta2003 commented 4 years ago

Thanks @peteriz those steps worked for me.

JonathanRaiman commented 4 years ago

I could get those fixes to work for me, however making a single compilation unit did the trick. WIP PR is here: https://github.com/pytries/marisa-trie/pull/54

arghyaiitb commented 4 years ago

for macOS Catalina this worked for me:

  • install command-line tools
  • export CPATH=/Library/Developer/CommandLineTools/usr/include/c++/v1
  • export CFLAGS=-stdlib=libc++

After 4 hours of struggle this saved my life. macOS Catalina 10.15.6

BoboTiG commented 3 years ago

Have a look at #66 ;)