setup.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import sys
  2. import os
  3. VERSION = '1.3.7'
  4. py_vers_tag = '-%s.%s' % sys.version_info[:2]
  5. test_dirs = ['functional_tests', 'unit_tests', os.path.join('doc','doc_tests'), 'nose']
  6. if sys.version_info >= (3,):
  7. try:
  8. import setuptools
  9. except ImportError:
  10. from distribute_setup import use_setuptools
  11. use_setuptools()
  12. extra = {'use_2to3': True,
  13. 'test_dirs': test_dirs,
  14. 'test_build_dir': 'build/tests',
  15. 'pyversion_patching': True,
  16. }
  17. else:
  18. extra = {}
  19. try:
  20. from setup3lib import setup
  21. from setuptools import find_packages
  22. addl_args = dict(
  23. zip_safe = False,
  24. packages = find_packages(),
  25. entry_points = {
  26. 'console_scripts': [
  27. 'nosetests = nose:run_exit',
  28. 'nosetests%s = nose:run_exit' % py_vers_tag,
  29. ],
  30. 'distutils.commands': [
  31. ' nosetests = nose.commands:nosetests',
  32. ],
  33. },
  34. test_suite = 'nose.collector',
  35. )
  36. addl_args.update(extra)
  37. # This is required by multiprocess plugin; on Windows, if
  38. # the launch script is not import-safe, spawned processes
  39. # will re-run it, resulting in an infinite loop.
  40. if sys.platform == 'win32':
  41. import re
  42. from setuptools.command.easy_install import easy_install
  43. def wrap_write_script(self, script_name, contents, *arg, **kwarg):
  44. if script_name.endswith('.exe'):
  45. return self._write_script(script_name, contents, *arg, **kwarg)
  46. bad_text = re.compile(
  47. "\n"
  48. "sys.exit\(\n"
  49. " load_entry_point\(([^\)]+)\)\(\)\n"
  50. "\)\n")
  51. good_text = (
  52. "\n"
  53. "if __name__ == '__main__':\n"
  54. " sys.exit(\n"
  55. r" load_entry_point(\1)()\n"
  56. " )\n"
  57. )
  58. contents = bad_text.sub(good_text, contents)
  59. return self._write_script(script_name, contents, *arg, **kwarg)
  60. easy_install._write_script = easy_install.write_script
  61. easy_install.write_script = wrap_write_script
  62. except ImportError:
  63. from distutils.core import setup
  64. addl_args = dict(
  65. packages = ['nose', 'nose.ext', 'nose.plugins', 'nose.sphinx',
  66. 'nose.tools'],
  67. scripts = ['bin/nosetests'],
  68. )
  69. setup(
  70. name = 'nose',
  71. version = VERSION,
  72. author = 'Jason Pellerin',
  73. author_email = 'jpellerin+nose@gmail.com',
  74. description = ('nose extends unittest to make testing easier'),
  75. long_description = \
  76. """nose extends the test loading and running features of unittest, making
  77. it easier to write, find and run tests.
  78. By default, nose will run tests in files or directories under the current
  79. working directory whose names include "test" or "Test" at a word boundary
  80. (like "test_this" or "functional_test" or "TestClass" but not
  81. "libtest"). Test output is similar to that of unittest, but also includes
  82. captured stdout output from failing tests, for easy print-style debugging.
  83. These features, and many more, are customizable through the use of
  84. plugins. Plugins included with nose provide support for doctest, code
  85. coverage and profiling, flexible attribute-based test selection,
  86. output capture and more. More information about writing plugins may be
  87. found on in the nose API documentation, here:
  88. http://readthedocs.org/docs/nose/
  89. If you have recently reported a bug marked as fixed, or have a craving for
  90. the very latest, you may want the development version instead:
  91. https://github.com/nose-devs/nose/tarball/master#egg=nose-dev
  92. """,
  93. license = 'GNU LGPL',
  94. keywords = 'test unittest doctest automatic discovery',
  95. url = 'http://readthedocs.org/docs/nose/',
  96. data_files = [('man/man1', ['nosetests.1'])],
  97. package_data = {'': ['*.txt',
  98. 'examples/*.py',
  99. 'examples/*/*.py']},
  100. classifiers = [
  101. 'Development Status :: 5 - Production/Stable',
  102. 'Intended Audience :: Developers',
  103. 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
  104. 'Natural Language :: English',
  105. 'Operating System :: OS Independent',
  106. 'Programming Language :: Python',
  107. 'Programming Language :: Python :: 3',
  108. 'Topic :: Software Development :: Testing'
  109. ],
  110. **addl_args
  111. )