setup.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env python
  2. import os
  3. import re
  4. import sys
  5. from codecs import open
  6. from setuptools import setup
  7. from setuptools.command.test import test as TestCommand
  8. class PyTest(TestCommand):
  9. user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]
  10. def initialize_options(self):
  11. TestCommand.initialize_options(self)
  12. self.pytest_args = []
  13. def finalize_options(self):
  14. TestCommand.finalize_options(self)
  15. self.test_args = []
  16. self.test_suite = True
  17. def run_tests(self):
  18. import pytest
  19. errno = pytest.main(self.pytest_args)
  20. sys.exit(errno)
  21. if sys.argv[-1] == 'publish':
  22. os.system('python setup.py sdist upload')
  23. sys.exit()
  24. packages = [
  25. 'requests',
  26. 'requests.packages',
  27. 'requests.packages.chardet',
  28. 'requests.packages.urllib3',
  29. 'requests.packages.urllib3.packages',
  30. 'requests.packages.urllib3.contrib',
  31. 'requests.packages.urllib3.util',
  32. 'requests.packages.urllib3.packages.ssl_match_hostname',
  33. ]
  34. requires = []
  35. test_requirements = ['pytest>=2.8.0', 'pytest-httpbin==0.0.7', 'pytest-cov']
  36. with open('requests/__init__.py', 'r') as fd:
  37. version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
  38. fd.read(), re.MULTILINE).group(1)
  39. if not version:
  40. raise RuntimeError('Cannot find version information')
  41. with open('README.rst', 'r', 'utf-8') as f:
  42. readme = f.read()
  43. with open('HISTORY.rst', 'r', 'utf-8') as f:
  44. history = f.read()
  45. setup(
  46. name='requests',
  47. version=version,
  48. description='Python HTTP for Humans.',
  49. long_description=readme + '\n\n' + history,
  50. author='Kenneth Reitz',
  51. author_email='me@kennethreitz.com',
  52. url='http://python-requests.org',
  53. packages=packages,
  54. package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']},
  55. package_dir={'requests': 'requests'},
  56. include_package_data=True,
  57. install_requires=requires,
  58. license='Apache 2.0',
  59. zip_safe=False,
  60. classifiers=(
  61. 'Development Status :: 5 - Production/Stable',
  62. 'Intended Audience :: Developers',
  63. 'Natural Language :: English',
  64. 'License :: OSI Approved :: Apache Software License',
  65. 'Programming Language :: Python',
  66. 'Programming Language :: Python :: 2.6',
  67. 'Programming Language :: Python :: 2.7',
  68. 'Programming Language :: Python :: 3',
  69. 'Programming Language :: Python :: 3.3',
  70. 'Programming Language :: Python :: 3.4',
  71. 'Programming Language :: Python :: 3.5',
  72. 'Programming Language :: Python :: Implementation :: CPython',
  73. 'Programming Language :: Python :: Implementation :: PyPy'
  74. ),
  75. cmdclass={'test': PyTest},
  76. tests_require=test_requirements,
  77. extras_require={
  78. 'security': ['pyOpenSSL>=0.13', 'ndg-httpsclient', 'pyasn1'],
  79. 'socks': ['PySocks>=1.5.6'],
  80. },
  81. )