setup.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/usr/bin/env python
  2. # Learn more: https://github.com/kennethreitz/setup.py
  3. import os
  4. import re
  5. import sys
  6. from codecs import open
  7. from setuptools import setup
  8. from setuptools.command.test import test as TestCommand
  9. here = os.path.abspath(os.path.dirname(__file__))
  10. class PyTest(TestCommand):
  11. user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]
  12. def initialize_options(self):
  13. TestCommand.initialize_options(self)
  14. try:
  15. from multiprocessing import cpu_count
  16. self.pytest_args = ['-n', str(cpu_count()), '--boxed']
  17. except (ImportError, NotImplementedError):
  18. self.pytest_args = ['-n', '1', '--boxed']
  19. def finalize_options(self):
  20. TestCommand.finalize_options(self)
  21. self.test_args = []
  22. self.test_suite = True
  23. def run_tests(self):
  24. import pytest
  25. errno = pytest.main(self.pytest_args)
  26. sys.exit(errno)
  27. # 'setup.py publish' shortcut.
  28. if sys.argv[-1] == 'publish':
  29. os.system('python setup.py sdist bdist_wheel')
  30. os.system('twine upload dist/*')
  31. sys.exit()
  32. packages = ['requests']
  33. requires = [
  34. #'chardet>=3.0.2,<4', # LGPL and imports have been removed
  35. 'idna>=2.5,<3',
  36. 'urllib3>=1.21.1,<1.26,!=1.25.0,!=1.25.1',
  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. with open('HISTORY.md', 'r', 'utf-8') as f:
  53. history = f.read()
  54. setup(
  55. name=about['__title__'],
  56. version=about['__version__'],
  57. description=about['__description__'],
  58. long_description=readme,
  59. long_description_content_type='text/markdown',
  60. author=about['__author__'],
  61. author_email=about['__author_email__'],
  62. url=about['__url__'],
  63. packages=packages,
  64. package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']},
  65. package_dir={'requests': 'requests'},
  66. include_package_data=True,
  67. python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
  68. install_requires=requires,
  69. license=about['__license__'],
  70. zip_safe=False,
  71. classifiers=[
  72. 'Development Status :: 5 - Production/Stable',
  73. 'Intended Audience :: Developers',
  74. 'Natural Language :: English',
  75. 'License :: OSI Approved :: Apache Software License',
  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.5',
  81. 'Programming Language :: Python :: 3.6',
  82. 'Programming Language :: Python :: 3.7',
  83. 'Programming Language :: Python :: 3.8',
  84. 'Programming Language :: Python :: Implementation :: CPython',
  85. 'Programming Language :: Python :: Implementation :: PyPy'
  86. ],
  87. cmdclass={'test': PyTest},
  88. tests_require=test_requirements,
  89. extras_require={
  90. 'security': ['pyOpenSSL >= 0.14', 'cryptography>=1.3.4'],
  91. 'socks': ['PySocks>=1.5.6, !=1.5.7'],
  92. 'socks:sys_platform == "win32" and python_version == "2.7"': ['win_inet_pton'],
  93. },
  94. project_urls={
  95. 'Documentation': 'https://requests.readthedocs.io',
  96. 'Source': 'https://github.com/psf/requests',
  97. },
  98. )