coccoc / coccoc-tokenizer

high performance tokenizer for Vietnamese language
GNU Lesser General Public License v3.0
394 stars 125 forks source link

Error when install verson of Python on Mac #5

Closed TruongKhang closed 5 years ago

TruongKhang commented 5 years ago

I got this error. Please help me to fix this:

running install running build running build_ext skipping 'CocCocTokenizer.cpp' Cython extension (up-to-date) building 'CocCocTokenizer' extension gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/lap00986/anaconda3/include -arch x86_64 -I/Users/lap00986/anaconda3/include -arch x86_64 -I. -I/Users/lap00986/Documents/product-matching/env/include -I/Users/lap00986/anaconda3/include/python3.7m -c CocCocTokenizer.cpp -o build/temp.macosx-10.7-x86_64-3.7/CocCocTokenizer.o -Wno-cpp -Wno-unused-function -O2 -march=native warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found] CocCocTokenizer.cpp:610:10: fatal error: 'ios' file not found

include "ios"

     ^~~~~

1 warning and 1 error generated. error: command 'gcc' failed with exit status 1

txdat commented 5 years ago

can you try changing setup.py based on this issue?

bachan commented 5 years ago

I've helped him yesterday @txdat. I also did some updates for the builiding and I think I will do one more update to actually pass compiler flags to python builder from CMAKE (because CMAKE knows platform-dependend flags better). For now he hotfixed it by fixing setup.py in his local copy.

kewin1807 commented 5 years ago

i have same problem @@. Please tell me how to fix issue

TruongKhang commented 5 years ago

specially thank @bachan. @hoangtubatu123 you should change file setup.py to this:

from __future__ import absolute_import, division, print_function`
from Cython.Distutils import build_ext
from distutils.core import setup
from distutils.extension import Extension

import os
os.environ['CC'] = 'g++'
os.environ['CXX'] = 'g++'

ext_modules = [
    Extension(
        name="CocCocTokenizer",
        sources=["CocCocTokenizer.pyx"],
        extra_compile_args=["-Wno-cpp", "-Wno-unused-function", "-O2", "-march=native", '-stdlib=libc++', '-std=c++11'],
        extra_link_args=["-O2", "-march=native", '-stdlib=libc++'],
        language="c++",
        include_dirs=["."],
    )
]

setup(
    name="coccoc-tokenizer", ext_modules=ext_modules, cmdclass={"build_ext": build_ext}
)

Or I see @bachan has changed the building for python. You can try that first

bachan commented 5 years ago

My last patch will still not work on MacOS, so for now just @hoangtubatu123 just use workaround from @TruongKhang, please. :)

I will release the code to pass build options from cmake to python tonight or tomorrow. Then we will test with @TruongKhang's Mac (I don't have a Mac, don't like them haha)

kewin1807 commented 5 years ago

yes. thanks you. Bug in mojave version

kewin1807 commented 5 years ago

Workaround for me I'm using macOS mojave

bachan commented 5 years ago

I've just added the same workaround into build_python.sh, now you can build using:

$ cmake -DBUILD_PYTHON=1 ..
# make install

README.md is also updated.