Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

setup.py 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2017-present, Facebook, Inc.
  3. # All rights reserved.
  4. #
  5. # This source code is licensed under the license found in the LICENSE file in
  6. # the root directory of this source tree. An additional grant of patent rights
  7. # can be found in the PATENTS file in the same directory.
  8. #
  9. from setuptools import setup, find_packages, Extension
  10. from setuptools.command.build_py import build_py
  11. import sys
  12. from torch.utils.ffi import create_extension
  13. if sys.version_info < (3,):
  14. sys.exit('Sorry, Python3 is required for fairseq.')
  15. with open('README.md') as f:
  16. readme = f.read()
  17. with open('LICENSE') as f:
  18. license = f.read()
  19. with open('requirements.txt') as f:
  20. reqs = f.read()
  21. bleu = Extension(
  22. 'fairseq.libbleu',
  23. sources=[
  24. 'fairseq/clib/libbleu/libbleu.cpp',
  25. 'fairseq/clib/libbleu/module.cpp',
  26. ],
  27. extra_compile_args=['-std=c++11'],
  28. )
  29. conv_tbc = create_extension(
  30. 'fairseq.temporal_convolution_tbc',
  31. relative_to='fairseq',
  32. headers=['fairseq/clib/temporal_convolution_tbc/temporal_convolution_tbc.h'],
  33. sources=['fairseq/clib/temporal_convolution_tbc/temporal_convolution_tbc.cpp'],
  34. define_macros=[('WITH_CUDA', None)],
  35. with_cuda=True,
  36. extra_compile_args=['-std=c++11'],
  37. source_extension='.cpp',
  38. )
  39. class build_py_hook(build_py):
  40. def run(self):
  41. conv_tbc.build()
  42. build_py.run(self)
  43. setup(
  44. name='fairseq',
  45. version='0.3.0',
  46. description='Facebook AI Research Sequence-to-Sequence Toolkit',
  47. long_description=readme,
  48. license=license,
  49. install_requires=reqs.strip().split('\n'),
  50. packages=find_packages(),
  51. ext_modules=[bleu],
  52. # build and install PyTorch extensions
  53. package_data={
  54. 'fairseq': ['temporal_convolution_tbc/*.so'],
  55. },
  56. include_package_data=True,
  57. cmdclass={
  58. 'build_py': build_py_hook,
  59. },
  60. )
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...