Skip to content
Myr

setup.py

This file

Path

setup.py

133 lines · 3.9 KiB · Python

Last changed by

Move to src directory (#6506)Nate Prewittbefore adoptiond63e94f

History of this file

Take 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, "src", "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={"": "src"},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.12",116        "Programming Language :: Python :: 3 :: Only",117        "Programming Language :: Python :: Implementation :: CPython",118        "Programming Language :: Python :: Implementation :: PyPy",119        "Topic :: Internet :: WWW/HTTP",120        "Topic :: Software Development :: Libraries",121    ],122    cmdclass={"test": PyTest},123    tests_require=test_requirements,124    extras_require={125        "security": [],126        "socks": ["PySocks>=1.5.6, !=1.5.7"],127        "use_chardet_on_py3": ["chardet>=3.0.2,<6"],128    },129    project_urls={130        "Documentation": "https://requests.readthedocs.io",131        "Source": "https://github.com/psf/requests",132    },133)