setup.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. here = os.path.abspath(os.path.dirname(__file__))
  9. class PyTest(TestCommand):
  10. user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]
  11. def initialize_options(self):
  12. TestCommand.initialize_options(self)
  13. try:
  14. from multiprocessing import cpu_count
  15. self.pytest_args = ['-n', str(cpu_count()), '--boxed']
  16. except (ImportError, NotImplementedError):
  17. self.pytest_args = ['-n', '1', '--boxed']
  18. def finalize_options(self):
  19. TestCommand.finalize_options(self)
  20. self.test_args = []
  21. self.test_suite = True
  22. def run_tests(self):
  23. import pytest
  24. errno = pytest.main(self.pytest_args)
  25. sys.exit(errno)
  26. # 'setup.py publish' shortcut.
  27. if sys.argv[-1] == 'publish':
  28. os.system('python setup.py sdist bdist_wheel')
  29. os.system('twine upload dist/*')
  30. sys.exit()
  31. packages = ['requests']
  32. requires = [
  33. 'chardet>=3.0.2,<3.1.0',
  34. 'idna>=2.5,<2.7',
  35. 'urllib3>=1.21.1,<1.23',
  36. 'certifi>=2017.4.17'
  37. ]
  38. test_requirements = ['pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock', 'pytest-xdist', 'PySocks>=1.5.6, !=1.5.7', 'pytest>=2.8.0']
  39. about = {}
  40. with open(os.path.join(here, 'requests', '__version__.py'), 'r', 'utf-8') as f:
  41. exec(f.read(), about)
  42. with open('README.rst', 'r', 'utf-8') as f:
  43. readme = f.read()
  44. with open('HISTORY.rst', 'r', 'utf-8') as f:
  45. history = f.read()
  46. setup(
  47. name=about['__title__'],
  48. version=about['__version__'],
  49. description=about['__description__'],
  50. long_description=readme + '\n\n' + history,
  51. author=about['__author__'],
  52. author_email=about['__author_email__'],
  53. url=about['__url__'],
  54. packages=packages,
  55. package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']},
  56. package_dir={'requests': 'requests'},
  57. include_package_data=True,
  58. install_requires=requires,
  59. license=about['__license__'],
  60. zip_safe=False,
  61. classifiers=(
  62. 'Development Status :: 5 - Production/Stable',
  63. 'Intended Audience :: Developers',
  64. 'Natural Language :: English',
  65. 'License :: OSI Approved :: Apache Software License',
  66. 'Programming Language :: Python',
  67. 'Programming Language :: Python :: 2.6',
  68. 'Programming Language :: Python :: 2.7',
  69. 'Programming Language :: Python :: 3',
  70. 'Programming Language :: Python :: 3.4',
  71. 'Programming Language :: Python :: 3.5',
  72. 'Programming Language :: Python :: 3.6',
  73. 'Programming Language :: Python :: Implementation :: CPython',
  74. 'Programming Language :: Python :: Implementation :: PyPy'
  75. ),
  76. cmdclass={'test': PyTest},
  77. tests_require=test_requirements,
  78. extras_require={
  79. 'security': ['pyOpenSSL>=0.14', 'cryptography>=1.3.4', 'idna>=2.0.0'],
  80. 'socks': ['PySocks>=1.5.6, !=1.5.7'],
  81. 'socks:sys_platform == "win32" and (python_version == "2.7" or python_version == "2.6")': ['win_inet_pton'],
  82. },
  83. )