mirror of
https://github.com/facebookresearch/fairseq.git
synced 2024-09-11 17:25:31 +03:00
Summary: Pull Request resolved: https://github.com/fairinternal/fairseq-py/pull/852 Differential Revision: D17147452 Pulled By: myleott fbshipit-source-id: 5fd9c7da3cc019c7beec98d41db1aef1329ee57a
105 lines
2.9 KiB
Python
105 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
from setuptools import setup, find_packages, Extension
|
|
from setuptools.command.build_ext import build_ext
|
|
import sys
|
|
|
|
|
|
if sys.version_info < (3,):
|
|
sys.exit('Sorry, Python3 is required for fairseq.')
|
|
|
|
|
|
with open('README.md') as f:
|
|
readme = f.read()
|
|
|
|
|
|
if sys.platform == 'darwin':
|
|
extra_compile_args = ['-stdlib=libc++', '-O3']
|
|
else:
|
|
extra_compile_args = ['-std=c++11', '-O3']
|
|
|
|
|
|
extensions = [
|
|
Extension(
|
|
'fairseq.libbleu',
|
|
sources=[
|
|
'fairseq/clib/libbleu/libbleu.cpp',
|
|
'fairseq/clib/libbleu/module.cpp',
|
|
],
|
|
extra_compile_args=extra_compile_args,
|
|
),
|
|
Extension(
|
|
'fairseq.data.data_utils_fast',
|
|
sources=['fairseq/data/data_utils_fast.pyx'],
|
|
language='c++',
|
|
extra_compile_args=extra_compile_args,
|
|
),
|
|
Extension(
|
|
'fairseq.data.token_block_utils_fast',
|
|
sources=['fairseq/data/token_block_utils_fast.pyx'],
|
|
language='c++',
|
|
extra_compile_args=extra_compile_args,
|
|
),
|
|
]
|
|
|
|
|
|
class CustomBuildExtCommand(build_ext):
|
|
"""Source: https://stackoverflow.com/a/42163080"""
|
|
def run(self):
|
|
# Import numpy here, only when headers are needed
|
|
import numpy
|
|
self.include_dirs.append(numpy.get_include())
|
|
super().run()
|
|
|
|
|
|
setup(
|
|
name='fairseq',
|
|
version='0.8.0',
|
|
description='Facebook AI Research Sequence-to-Sequence Toolkit',
|
|
url='https://github.com/pytorch/fairseq',
|
|
classifiers=[
|
|
'Intended Audience :: Science/Research',
|
|
'License :: OSI Approved :: MIT License',
|
|
'Programming Language :: Python :: 3.5',
|
|
'Programming Language :: Python :: 3.6',
|
|
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
|
],
|
|
long_description=readme,
|
|
long_description_content_type='text/markdown',
|
|
setup_requires=[
|
|
'numpy',
|
|
'cython',
|
|
'numpy',
|
|
'setuptools>=18.0',
|
|
],
|
|
install_requires=[
|
|
'cffi',
|
|
'fastBPE',
|
|
'numpy',
|
|
'regex',
|
|
'sacrebleu',
|
|
'torch',
|
|
'tqdm',
|
|
],
|
|
packages=find_packages(exclude=['scripts', 'tests']),
|
|
ext_modules=extensions,
|
|
test_suite='tests',
|
|
entry_points={
|
|
'console_scripts': [
|
|
'fairseq-eval-lm = fairseq_cli.eval_lm:cli_main',
|
|
'fairseq-generate = fairseq_cli.generate:cli_main',
|
|
'fairseq-interactive = fairseq_cli.interactive:cli_main',
|
|
'fairseq-preprocess = fairseq_cli.preprocess:cli_main',
|
|
'fairseq-score = fairseq_cli.score:main',
|
|
'fairseq-train = fairseq_cli.train:cli_main',
|
|
'fairseq-validate = fairseq_cli.validate:cli_main',
|
|
],
|
|
},
|
|
cmdclass={'build_ext': CustomBuildExtCommand},
|
|
zip_safe=False,
|
|
)
|