setup.py
This file
Path
setup.py
132 lines · 3.9 KiB · Python
Last changed by
test on py3.12 (#6448)Thomas Graingerbefore adoptionb639e66
History of this fileTake it
1#!/usr/bin/env python2import os3import sys4from codecs import open56from setuptools import setup7from setuptools.command.test import test as TestCommand89CURRENT_PYTHON = sys.version_info[:2]10REQUIRED_PYTHON = (3, 7)1112if CURRENT_PYTHON < REQUIRED_PYTHON:13 sys.stderr.write(14 """15==========================16Unsupported Python version17==========================18This version of Requests requires at least Python {}.{}, but19you're trying to install it on Python {}.{}. To resolve this,20consider upgrading to a supported Python version.2122If you can't upgrade your Python version, you'll need to23pin to an older version of Requests (<2.28).24""".format(25 *(REQUIRED_PYTHON + CURRENT_PYTHON)26 )27 )28 sys.exit(1)293031class PyTest(TestCommand):32 user_options = [("pytest-args=", "a", "Arguments to pass into py.test")]3334 def initialize_options(self):35 TestCommand.initialize_options(self)36 try:37 from multiprocessing import cpu_count3839 self.pytest_args = ["-n", str(cpu_count()), "--boxed"]40 except (ImportError, NotImplementedError):41 self.pytest_args = ["-n", "1", "--boxed"]4243 def finalize_options(self):44 TestCommand.finalize_options(self)45 self.test_args = []46 self.test_suite = True4748 def run_tests(self):49 import pytest5051 errno = pytest.main(self.pytest_args)52 sys.exit(errno)535455# 'setup.py publish' shortcut.56if sys.argv[-1] == "publish":57 os.system("python setup.py sdist bdist_wheel")58 os.system("twine upload dist/*")59 sys.exit()6061requires = [62 "charset_normalizer>=2,<4",63 "idna>=2.5,<4",64 "urllib3>=1.21.1,<3",65 "certifi>=2017.4.17",66]67test_requirements = [68 "pytest-httpbin==2.0.0",69 "pytest-cov",70 "pytest-mock",71 "pytest-xdist",72 "PySocks>=1.5.6, !=1.5.7",73 "pytest>=3",74]7576about = {}77here = os.path.abspath(os.path.dirname(__file__))78with open(os.path.join(here, "requests", "__version__.py"), "r", "utf-8") as f:79 exec(f.read(), about)8081with open("README.md", "r", "utf-8") as f:82 readme = f.read()8384setup(85 name=about["__title__"],86 version=about["__version__"],87 description=about["__description__"],88 long_description=readme,89 long_description_content_type="text/markdown",90 author=about["__author__"],91 author_email=about["__author_email__"],92 url=about["__url__"],93 packages=["requests"],94 package_data={"": ["LICENSE", "NOTICE"]},95 package_dir={"requests": "requests"},96 include_package_data=True,97 python_requires=">=3.7",98 install_requires=requires,99 license=about["__license__"],100 zip_safe=False,101 classifiers=[102 "Development Status :: 5 - Production/Stable",103 "Environment :: Web Environment",104 "Intended Audience :: Developers",105 "License :: OSI Approved :: Apache Software License",106 "Natural Language :: English",107 "Operating System :: OS Independent",108 "Programming Language :: Python",109 "Programming Language :: Python :: 3",110 "Programming Language :: Python :: 3.7",111 "Programming Language :: Python :: 3.8",112 "Programming Language :: Python :: 3.9",113 "Programming Language :: Python :: 3.10",114 "Programming Language :: Python :: 3.11",115 "Programming Language :: Python :: 3 :: Only",116 "Programming Language :: Python :: Implementation :: CPython",117 "Programming Language :: Python :: Implementation :: PyPy",118 "Topic :: Internet :: WWW/HTTP",119 "Topic :: Software Development :: Libraries",120 ],121 cmdclass={"test": PyTest},122 tests_require=test_requirements,123 extras_require={124 "security": [],125 "socks": ["PySocks>=1.5.6, !=1.5.7"],126 "use_chardet_on_py3": ["chardet>=3.0.2,<6"],127 },128 project_urls={129 "Documentation": "https://requests.readthedocs.io",130 "Source": "https://github.com/psf/requests",131 },132)