Estou tentando instalar ligações de texto rápido do Facebook no Mac OSX 10.12 Sierra usando pip. Estou recebendo o seguinte erro ao executar sudo pip install fasttext
:
Collecting fasttext
Downloading fasttext-0.8.2.tar.gz (73kB)
100% |████████████████████████████████| 81kB 1.9MB/s
Requirement already satisfied: numpy>=1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy-1.12.0rc2-py2.7-macosx-10.6-intel.egg (from fasttext)
Requirement already satisfied: future in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from fasttext)
Installing collected packages: fasttext
Running setup.py install for fasttext ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-sxrbh9/fasttext/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-2vHzji-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.6-intel-2.7
creating build/lib.macosx-10.6-intel-2.7/fasttext
copying fasttext/__init__.py -> build/lib.macosx-10.6-intel-2.7/fasttext
copying fasttext/model.py -> build/lib.macosx-10.6-intel-2.7/fasttext
running build_ext
building '*' extension
creating build/temp.macosx-10.6-intel-2.7
creating build/temp.macosx-10.6-intel-2.7/fasttext
creating build/temp.macosx-10.6-intel-2.7/fasttext/cpp
creating build/temp.macosx-10.6-intel-2.7/fasttext/cpp/src
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c fasttext/fasttext.c -o build/temp.macosx-10.6-intel-2.7/fasttext/fasttext.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
clang: error: no such file or directory: 'fasttext/fasttext.c'
clang: error: no input files
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Para examinar o pacote, corro sudo pip install fasttext --no-clean
para manter o diretório do pacote temporário. Eu olho para ele e vejo que não há realmente nenhum arquivo fasttext/fasttext.c
, embora exista fasttext/fasttext.cpp
file. Se eu executar manualmente o comando de construção com fasttext.c
substituído por fasttext.cpp
, ele será concluído com êxito.
/usr/bin/clang <...> -c fasttext/fasttext.cpp <...>
Mas agora, para instalar o pacote, quero informar setup.py
para usar fasttext.cpp
em vez de fasttext.c
. E isso é algo que não sei fazer. Grep
ing a pasta não encontra nenhuma menção explícita de fasttext.c
, então eu suponho que é tomado implicitamente por alguma regra que eu não conheço. Aqui está o conteúdo completo do arquivo setup.py
:
from setuptools import setup, find_packages
from setuptools.extension import Extension
from Cython.Build import cythonize
from sys import platform
import unittest
# Define the C++ extension
if platform == "darwin":
extra_compile_args = ['-O3', '-pthread', '-funroll-loops', '-std=c++0x', '-stdlib=libc++', '-mmacosx-version-min=10.7']
else:
extra_compile_args = ['-O3', '-pthread', '-funroll-loops', '-std=c++0x']
extensions = [
Extension('*',
sources=[
'fasttext/fasttext.pyx',
'fasttext/interface.cc',
'fasttext/cpp/src/args.cc',
'fasttext/cpp/src/dictionary.cc',
'fasttext/cpp/src/matrix.cc',
'fasttext/cpp/src/model.cc',
'fasttext/cpp/src/utils.cc',
'fasttext/cpp/src/fasttext.cc',
'fasttext/cpp/src/vector.cc',
'fasttext/cpp/src/main.cc'
],
language='c++',
extra_compile_args=extra_compile_args)
]
# Package details
setup(
name='fasttext',
version='0.8.2',
author='Bayu Aldi Yansyah',
author_email='[email protected]',
url='https://github.com/pyk/fastText.py',
description='A Python interface for Facebook fastText library',
long_description=open('README.rst', 'r').read(),
license='BSD 3-Clause License',
packages=['fasttext'],
ext_modules = cythonize(extensions),
install_requires=[
'numpy>=1',
'future'
],
classifiers= [
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: C++',
'Programming Language :: Cython',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Scientific/Engineering :: Artificial Intelligence'
]
)
Você poderia me ajudar a instalar o pacote?