Skip to content

Commit 26d4b6b

Browse files
committed
Migrate build system to hatchling
1 parent 131e506 commit 26d4b6b

File tree

3 files changed

+89
-113
lines changed

3 files changed

+89
-113
lines changed

pyproject.toml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,79 @@
1+
[build-system]
2+
requires = ["hatchling>=1.21.1"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "requests"
7+
description = "Python HTTP for Humans."
8+
readme = "README.md"
9+
license = { file = "LICENSE" }
10+
authors = [
11+
{ name = "Kenneth Reitz", email = "[email protected]" },
12+
]
13+
maintainers = [
14+
{name = "Ian Stapleton Cordasco", email="[email protected]"},
15+
{name = "Nate Prewitt", email="[email protected]"}
16+
]
17+
requires-python = ">=3.9"
18+
dependencies = [
19+
"charset_normalizer>=2,<4",
20+
"idna>=2.5,<4",
21+
"urllib3>=1.21.1,<3",
22+
"certifi>=2017.4.17"
23+
]
24+
dynamic = ["version"]
25+
26+
classifiers = [
27+
"Development Status :: 5 - Production/Stable",
28+
"Environment :: Web Environment",
29+
"Intended Audience :: Developers",
30+
"License :: OSI Approved :: Apache Software License",
31+
"Natural Language :: English",
32+
"Operating System :: OS Independent",
33+
"Programming Language :: Python",
34+
"Programming Language :: Python :: 3",
35+
"Programming Language :: Python :: 3.9",
36+
"Programming Language :: Python :: 3.10",
37+
"Programming Language :: Python :: 3.11",
38+
"Programming Language :: Python :: 3.12",
39+
"Programming Language :: Python :: 3.13",
40+
"Programming Language :: Python :: 3.14",
41+
"Programming Language :: Python :: 3 :: Only",
42+
"Programming Language :: Python :: Implementation :: CPython",
43+
"Programming Language :: Python :: Implementation :: PyPy",
44+
"Topic :: Internet :: WWW/HTTP",
45+
"Topic :: Software Development :: Libraries"
46+
]
47+
48+
[project.urls]
49+
Documentation = "https://requests.readthedocs.io"
50+
Source = "https://github.com/psf/requests"
51+
52+
[project.optional-dependencies]
53+
security = []
54+
socks = ["PySocks>=1.5.6, !=1.5.7"]
55+
use_chardet_on_py3 = ["chardet>=3.0.2,<6"]
56+
test = [
57+
"pytest-httpbin==2.1.0",
58+
"pytest-cov",
59+
"pytest-mock",
60+
"pytest-xdist",
61+
"PySocks>=1.5.6, !=1.5.7",
62+
"pytest>=3"
63+
]
64+
65+
[tool.hatch.version]
66+
path = "src/requests/__version__.py"
67+
68+
[tool.hatch.build.targets.sdist]
69+
include = [
70+
"src/requests",
71+
"LICENSE",
72+
"NOTICE",
73+
"README.md",
74+
"HISTORY.md"
75+
]
76+
177
[tool.isort]
278
profile = "black"
379
src_paths = ["src/requests", "test"]

setup.cfg

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
[metadata]
2-
license_file = LICENSE
3-
provides-extra =
4-
socks
5-
use_chardet_on_py3
6-
requires-dist =
7-
certifi>=2017.4.17
8-
charset_normalizer>=2,<4
9-
idna>=2.5,<4
10-
urllib3>=1.21.1,<3
11-
121
[flake8]
132
ignore = E203, E501, W503
143
per-file-ignores =

setup.py

Lines changed: 13 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,18 @@
1-
#!/usr/bin/env python
2-
import os
31
import sys
4-
from codecs import open
52

6-
from setuptools import setup
7-
8-
CURRENT_PYTHON = sys.version_info[:2]
9-
REQUIRED_PYTHON = (3, 9)
10-
11-
if CURRENT_PYTHON < REQUIRED_PYTHON:
12-
sys.stderr.write(
13-
"""
14-
==========================
15-
Unsupported Python version
16-
==========================
17-
This version of Requests requires at least Python {}.{}, but
18-
you're trying to install it on Python {}.{}. To resolve this,
19-
consider upgrading to a supported Python version.
20-
21-
If you can't upgrade your Python version, you'll need to
22-
pin to an older version of Requests (<2.32.0).
23-
""".format(
24-
*(REQUIRED_PYTHON + CURRENT_PYTHON)
3+
if __name__ == "__main__":
4+
if sys.version_info < (3, 9):
5+
sys.stderr.write("Requests requires Python 3.9 or later.\n")
6+
sys.exit(1)
7+
try:
8+
import hatchling # noqa: F401
9+
except ImportError:
10+
sys.stderr.write(
11+
"This package now uses pyproject.toml and PEP 517 for builds. "
12+
"Please upgrade pip (>=21.3) and setuptools.\n"
2513
)
26-
)
27-
sys.exit(1)
28-
29-
30-
# 'setup.py publish' shortcut.
31-
if sys.argv[-1] == "publish":
32-
os.system("python setup.py sdist bdist_wheel")
33-
os.system("twine upload dist/*")
34-
sys.exit()
35-
36-
requires = [
37-
"charset_normalizer>=2,<4",
38-
"idna>=2.5,<4",
39-
"urllib3>=1.21.1,<3",
40-
"certifi>=2017.4.17",
41-
]
42-
test_requirements = [
43-
"pytest-httpbin==2.1.0",
44-
"pytest-cov",
45-
"pytest-mock",
46-
"pytest-xdist",
47-
"PySocks>=1.5.6, !=1.5.7",
48-
"pytest>=3",
49-
]
50-
51-
about = {}
52-
here = os.path.abspath(os.path.dirname(__file__))
53-
with open(os.path.join(here, "src", "requests", "__version__.py"), "r", "utf-8") as f:
54-
exec(f.read(), about)
14+
sys.exit(1)
5515

56-
with open("README.md", "r", "utf-8") as f:
57-
readme = f.read()
16+
from setuptools import setup
5817

59-
setup(
60-
name=about["__title__"],
61-
version=about["__version__"],
62-
description=about["__description__"],
63-
long_description=readme,
64-
long_description_content_type="text/markdown",
65-
author=about["__author__"],
66-
author_email=about["__author_email__"],
67-
url=about["__url__"],
68-
packages=["requests"],
69-
package_data={"": ["LICENSE", "NOTICE"]},
70-
package_dir={"": "src"},
71-
include_package_data=True,
72-
python_requires=">=3.9",
73-
install_requires=requires,
74-
license=about["__license__"],
75-
zip_safe=False,
76-
classifiers=[
77-
"Development Status :: 5 - Production/Stable",
78-
"Environment :: Web Environment",
79-
"Intended Audience :: Developers",
80-
"License :: OSI Approved :: Apache Software License",
81-
"Natural Language :: English",
82-
"Operating System :: OS Independent",
83-
"Programming Language :: Python",
84-
"Programming Language :: Python :: 3",
85-
"Programming Language :: Python :: 3.9",
86-
"Programming Language :: Python :: 3.10",
87-
"Programming Language :: Python :: 3.11",
88-
"Programming Language :: Python :: 3.12",
89-
"Programming Language :: Python :: 3.13",
90-
"Programming Language :: Python :: 3.14",
91-
"Programming Language :: Python :: 3 :: Only",
92-
"Programming Language :: Python :: Implementation :: CPython",
93-
"Programming Language :: Python :: Implementation :: PyPy",
94-
"Topic :: Internet :: WWW/HTTP",
95-
"Topic :: Software Development :: Libraries",
96-
],
97-
tests_require=test_requirements,
98-
extras_require={
99-
"security": [],
100-
"socks": ["PySocks>=1.5.6, !=1.5.7"],
101-
"use_chardet_on_py3": ["chardet>=3.0.2,<6"],
102-
},
103-
project_urls={
104-
"Documentation": "https://requests.readthedocs.io",
105-
"Source": "https://github.com/psf/requests",
106-
},
107-
)
18+
setup()

0 commit comments

Comments
 (0)