2017-09-25 20:17:43 +03:00
|
|
|
#!/usr/bin/env python3
|
2019-07-30 17:45:13 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2017-09-15 03:22:43 +03:00
|
|
|
#
|
2019-07-30 17:45:13 +03:00
|
|
|
# This source code is licensed under the MIT license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
2017-09-15 03:22:43 +03:00
|
|
|
|
|
|
|
from setuptools import setup, find_packages, Extension
|
2019-08-31 23:43:00 +03:00
|
|
|
from setuptools.command.build_ext import build_ext
|
2017-09-15 03:22:43 +03:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info < (3,):
|
|
|
|
sys.exit('Sorry, Python3 is required for fairseq.')
|
|
|
|
|
2019-08-27 20:06:26 +03:00
|
|
|
|
2017-09-15 03:22:43 +03:00
|
|
|
with open('README.md') as f:
|
|
|
|
readme = f.read()
|
|
|
|
|
2019-08-27 20:06:26 +03:00
|
|
|
|
2019-07-06 22:27:58 +03:00
|
|
|
if sys.platform == 'darwin':
|
2019-08-27 17:10:35 +03:00
|
|
|
extra_compile_args = ['-stdlib=libc++', '-O3']
|
2019-07-06 22:27:58 +03:00
|
|
|
else:
|
2019-08-27 17:10:35 +03:00
|
|
|
extra_compile_args = ['-std=c++11', '-O3']
|
2017-09-15 03:22:43 +03:00
|
|
|
|
2019-08-27 17:10:35 +03:00
|
|
|
|
2019-08-27 20:06:26 +03:00
|
|
|
extensions = [
|
|
|
|
Extension(
|
|
|
|
'fairseq.libbleu',
|
|
|
|
sources=[
|
|
|
|
'fairseq/clib/libbleu/libbleu.cpp',
|
|
|
|
'fairseq/clib/libbleu/module.cpp',
|
|
|
|
],
|
2019-08-27 17:10:35 +03:00
|
|
|
extra_compile_args=extra_compile_args,
|
2019-08-27 20:06:26 +03:00
|
|
|
),
|
|
|
|
Extension(
|
|
|
|
'fairseq.data.data_utils_fast',
|
|
|
|
sources=['fairseq/data/data_utils_fast.pyx'],
|
|
|
|
language='c++',
|
2019-08-27 17:10:35 +03:00
|
|
|
extra_compile_args=extra_compile_args,
|
2019-08-27 20:06:26 +03:00
|
|
|
),
|
|
|
|
Extension(
|
|
|
|
'fairseq.data.token_block_utils_fast',
|
|
|
|
sources=['fairseq/data/token_block_utils_fast.pyx'],
|
|
|
|
language='c++',
|
|
|
|
extra_compile_args=extra_compile_args,
|
|
|
|
),
|
|
|
|
]
|
2019-08-27 17:10:35 +03:00
|
|
|
|
|
|
|
|
2019-08-31 23:43:00 +03:00
|
|
|
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()
|
2019-08-27 17:10:35 +03:00
|
|
|
|
2017-09-15 03:22:43 +03:00
|
|
|
|
|
|
|
setup(
|
|
|
|
name='fairseq',
|
2019-08-14 15:00:05 +03:00
|
|
|
version='0.8.0',
|
2017-09-15 03:22:43 +03:00
|
|
|
description='Facebook AI Research Sequence-to-Sequence Toolkit',
|
2019-02-09 09:00:46 +03:00
|
|
|
url='https://github.com/pytorch/fairseq',
|
|
|
|
classifiers=[
|
|
|
|
'Intended Audience :: Science/Research',
|
2019-07-30 17:45:13 +03:00
|
|
|
'License :: OSI Approved :: MIT License',
|
2019-06-11 14:06:52 +03:00
|
|
|
'Programming Language :: Python :: 3.5',
|
2019-02-09 09:00:46 +03:00
|
|
|
'Programming Language :: Python :: 3.6',
|
|
|
|
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
|
|
|
],
|
2017-09-15 03:22:43 +03:00
|
|
|
long_description=readme,
|
2019-06-20 16:23:49 +03:00
|
|
|
long_description_content_type='text/markdown',
|
2019-08-26 17:18:01 +03:00
|
|
|
setup_requires=[
|
2019-08-27 17:10:35 +03:00
|
|
|
'numpy',
|
2019-08-26 17:18:01 +03:00
|
|
|
'cython',
|
2019-08-27 20:06:26 +03:00
|
|
|
'numpy',
|
2019-08-26 17:18:01 +03:00
|
|
|
'setuptools>=18.0',
|
|
|
|
],
|
2019-02-09 09:00:46 +03:00
|
|
|
install_requires=[
|
|
|
|
'cffi',
|
2019-08-02 16:20:46 +03:00
|
|
|
'fastBPE',
|
2019-02-09 09:00:46 +03:00
|
|
|
'numpy',
|
2019-08-02 16:20:46 +03:00
|
|
|
'regex',
|
2019-02-28 18:51:55 +03:00
|
|
|
'sacrebleu',
|
2019-03-16 07:27:03 +03:00
|
|
|
'torch',
|
2019-02-09 09:00:46 +03:00
|
|
|
'tqdm',
|
|
|
|
],
|
|
|
|
packages=find_packages(exclude=['scripts', 'tests']),
|
2019-08-27 20:06:26 +03:00
|
|
|
ext_modules=extensions,
|
2018-02-28 01:09:42 +03:00
|
|
|
test_suite='tests',
|
2019-02-05 18:46:44 +03:00
|
|
|
entry_points={
|
|
|
|
'console_scripts': [
|
2019-02-09 09:00:46 +03:00
|
|
|
'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',
|
2019-08-13 23:03:40 +03:00
|
|
|
'fairseq-train = fairseq_cli.train:cli_main',
|
|
|
|
'fairseq-validate = fairseq_cli.validate:cli_main',
|
2019-02-05 18:46:44 +03:00
|
|
|
],
|
|
|
|
},
|
2019-08-31 23:43:00 +03:00
|
|
|
cmdclass={'build_ext': CustomBuildExtCommand},
|
2019-08-23 17:31:18 +03:00
|
|
|
zip_safe=False,
|
2017-09-15 03:22:43 +03:00
|
|
|
)
|