setup.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/env python
  2. # Learn more: https://github.com/kennethreitz/setup.py
  3. import os
  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. 'charset_normalizer~=2.0.0; python_version >= "3"',
  34. 'chardet>=3.0.2,<5; python_version < "3"',
  35. 'idna>=2.5,<3; python_version < "3"',
  36. 'idna>=2.5,<4; python_version >= "3"',
  37. 'urllib3>=1.21.1,<1.27',
  38. 'certifi>=2017.4.17'
  39. ]
  40. test_requirements = [
  41. 'pytest-httpbin==0.0.7',
  42. 'pytest-cov',
  43. 'pytest-mock',
  44. 'pytest-xdist',
  45. 'PySocks>=1.5.6, !=1.5.7',
  46. 'pytest>=3'
  47. ]
  48. about = {}
  49. with open(os.path.join(here, 'requests', '__version__.py'), 'r', 'utf-8') as f:
  50. exec(f.read(), about)
  51. with open('README.md', 'r', 'utf-8') as f:
  52. readme = f.read()
  53. setup(
  54. name=about['__title__'],
  55. version=about['__version__'],
  56. description=about['__description__'],
  57. long_description=readme,
  58. long_description_content_type='text/markdown',
  59. author=about['__author__'],
  60. author_email=about['__author_email__'],
  61. url=about['__url__'],
  62. packages=packages,
  63. package_data={'': ['LICENSE', 'NOTICE']},
  64. package_dir={'requests': 'requests'},
  65. include_package_data=True,
  66. python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*",
  67. install_requires=requires,
  68. license=about['__license__'],
  69. zip_safe=False,
  70. classifiers=[
  71. 'Development Status :: 5 - Production/Stable',
  72. 'Environment :: Web Environment',
  73. 'Intended Audience :: Developers',
  74. 'License :: OSI Approved :: Apache Software License',
  75. 'Natural Language :: English',
  76. 'Operating System :: OS Independent',
  77. 'Programming Language :: Python',
  78. 'Programming Language :: Python :: 2',
  79. 'Programming Language :: Python :: 2.7',
  80. 'Programming Language :: Python :: 3',
  81. 'Programming Language :: Python :: 3.6',
  82. 'Programming Language :: Python :: 3.7',
  83. 'Programming Language :: Python :: 3.8',
  84. 'Programming Language :: Python :: 3.9',
  85. 'Programming Language :: Python :: 3.10',
  86. 'Programming Language :: Python :: Implementation :: CPython',
  87. 'Programming Language :: Python :: Implementation :: PyPy',
  88. 'Topic :: Internet :: WWW/HTTP',
  89. 'Topic :: Software Development :: Libraries',
  90. ],
  91. cmdclass={'test': PyTest},
  92. tests_require=test_requirements,
  93. extras_require={
  94. 'security': [],
  95. 'socks': ['PySocks>=1.5.6, !=1.5.7'],
  96. 'socks:sys_platform == "win32" and python_version == "2.7"': ['win_inet_pton'],
  97. 'use_chardet_on_py3': ['chardet>=3.0.2,<5']
  98. },
  99. project_urls={
  100. 'Documentation': 'https://requests.readthedocs.io',
  101. 'Source': 'https://github.com/psf/requests',
  102. },
  103. )