Add specific compile flags for macOS (#862)

Summary:
Fairseq wouldn't install on macOS.
A workaround was found here: https://github.com/pytorch/fairseq/issues/289
This is now automatic in setup.py, maybe be there's a cleaner way to do it.

I checked that it compiles fine on Linux and macOS.
Pull Request resolved: https://github.com/pytorch/fairseq/pull/862

Differential Revision: D16142105

Pulled By: myleott

fbshipit-source-id: 998ac7781d7a1ac047f4f9239c1fe16eab4be0dd
This commit is contained in:
Louis MARTIN 2019-07-06 12:27:58 -07:00 committed by Facebook Github Bot
parent 5c241c8c5f
commit cc292afaed

View File

@ -16,14 +16,17 @@ if sys.version_info < (3,):
with open('README.md') as f:
readme = f.read()
if sys.platform == 'darwin':
extra_compile_args = ['-stdlib=libc++']
else:
extra_compile_args = ['-std=c++11']
bleu = Extension(
'fairseq.libbleu',
sources=[
'fairseq/clib/libbleu/libbleu.cpp',
'fairseq/clib/libbleu/module.cpp',
],
extra_compile_args=['-std=c++11'],
extra_compile_args=extra_compile_args,
)