setup.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import re
  5. import sys
  6. import codecs
  7. import setuptools
  8. import setuptools.command.test
  9. if sys.version_info < (2, 7):
  10. raise Exception('vine requires Python 2.7 or higher.')
  11. NAME = 'vine'
  12. # -*- Classifiers -*-
  13. classes = """
  14. Development Status :: 5 - Production/Stable
  15. Programming Language :: Python
  16. Programming Language :: Python :: 2
  17. Programming Language :: Python :: 2.7
  18. Programming Language :: Python :: 3
  19. Programming Language :: Python :: 3.4
  20. Programming Language :: Python :: 3.5
  21. Programming Language :: Python :: 3.6
  22. Programming Language :: Python :: 3.7
  23. Programming Language :: Python :: Implementation :: CPython
  24. Programming Language :: Python :: Implementation :: PyPy
  25. License :: OSI Approved :: BSD License
  26. Intended Audience :: Developers
  27. Operating System :: OS Independent
  28. """
  29. classifiers = [s.strip() for s in classes.split('\n') if s]
  30. # -*- Distribution Meta -*-
  31. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  32. re_doc = re.compile(r'^"""(.+?)"""')
  33. def add_default(m):
  34. attr_name, attr_value = m.groups()
  35. return ((attr_name, attr_value.strip("\"'")),)
  36. def add_doc(m):
  37. return (('doc', m.groups()[0]),)
  38. pats = {re_meta: add_default,
  39. re_doc: add_doc}
  40. here = os.path.abspath(os.path.dirname(__file__))
  41. with open(os.path.join(here, 'vine', '__init__.py')) as meta_fh:
  42. meta = {}
  43. for line in meta_fh:
  44. if line.strip() == '# -eof meta-':
  45. break
  46. for pattern, handler in pats.items():
  47. m = pattern.match(line.strip())
  48. if m:
  49. meta.update(handler(m))
  50. # -*- Installation Requires -*-
  51. py_version = sys.version_info
  52. is_jython = sys.platform.startswith('java')
  53. is_pypy = hasattr(sys, 'pypy_version_info')
  54. def strip_comments(l):
  55. return l.split('#', 1)[0].strip()
  56. def reqs(f):
  57. return filter(None, [strip_comments(l) for l in open(
  58. os.path.join(os.getcwd(), 'requirements', f)).readlines()])
  59. # -*- Long Description -*-
  60. if os.path.exists('README.rst'):
  61. long_description = codecs.open('README.rst', 'r', 'utf-8').read()
  62. else:
  63. long_description = 'See https://pypi.org/project/vine/'
  64. # -*- Entry Points -*- #
  65. # -*- %%% -*-
  66. class pytest(setuptools.command.test.test):
  67. user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
  68. def initialize_options(self):
  69. setuptools.command.test.test.initialize_options(self)
  70. self.pytest_args = []
  71. def run_tests(self):
  72. import pytest
  73. sys.exit(pytest.main(self.pytest_args))
  74. setuptools.setup(
  75. name=NAME,
  76. packages=setuptools.find_packages(exclude=['t', 't.*']),
  77. version=meta['version'],
  78. description=meta['doc'],
  79. long_description=long_description,
  80. keywords='promise promises lazy future futures',
  81. author=meta['author'],
  82. author_email=meta['contact'],
  83. url=meta['homepage'],
  84. platforms=['any'],
  85. classifiers=classifiers,
  86. license='BSD',
  87. python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
  88. install_requires=[],
  89. tests_require=reqs('test.txt'),
  90. cmdclass={'test': pytest},
  91. zip_safe=False,
  92. include_package_data=False,
  93. )