setup.py 3.6 KB

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