oss_setup.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Copyright 2017 Google Inc. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ==============================================================================
  15. """Packaging for SyntaxNet."""
  16. from __future__ import absolute_import
  17. from __future__ import division
  18. from __future__ import print_function
  19. import os
  20. import setuptools
  21. import setuptools.dist
  22. include_tensorflow = os.path.isdir('tensorflow')
  23. source_roots = ['dragnn', 'syntaxnet'] + (['tensorflow']
  24. if include_tensorflow else [])
  25. def data_files():
  26. """Return all non-Python files in the source directories."""
  27. for root in source_roots:
  28. for path, _, files in os.walk(root):
  29. for filename in files:
  30. if not (filename.endswith('.py') or filename.endswith('.pyc')):
  31. yield os.path.join(path, filename)
  32. class BinaryDistribution(setuptools.dist.Distribution):
  33. """Copied from TensorFlow's setup script: sets has_ext_modules=True.
  34. Distributions of SyntaxNet include shared object files, which are not
  35. cross-platform.
  36. """
  37. def has_ext_modules(self):
  38. return True
  39. with open('MANIFEST.in', 'w') as f:
  40. f.write(''.join('include {}\n'.format(filename) for filename in data_files()))
  41. setuptools.setup(
  42. name=('syntaxnet_with_tensorflow' if include_tensorflow else 'syntaxnet'),
  43. version='0.2',
  44. description='SyntaxNet: Neural Models of Syntax',
  45. long_description='',
  46. url='https://github.com/tensorflow/models/tree/master/syntaxnet',
  47. author='Google Inc.',
  48. author_email='opensource@google.com',
  49. # Contained modules and scripts.
  50. packages=setuptools.find_packages(),
  51. install_requires=([] if include_tensorflow else ['tensorflow']) +
  52. ['pygraphviz'],
  53. # Add in any packaged data. This uses "MANIFEST.in", which seems to be the
  54. # more reliable way of packaging wheel data.
  55. include_package_data=True,
  56. zip_safe=False,
  57. distclass=BinaryDistribution,
  58. # PyPI package information.
  59. classifiers=[
  60. 'Intended Audience :: Developers',
  61. 'Intended Audience :: Education',
  62. 'Intended Audience :: Science/Research',
  63. 'License :: OSI Approved :: Apache Software License',
  64. 'Programming Language :: Python :: 2.7',
  65. 'Topic :: Scientific/Engineering :: Mathematics',
  66. ],
  67. license='Apache 2.0',
  68. keywords='syntaxnet machine learning',)