Switch to Flit as a build-system
MODIFY
.github/CODEOWNERS
.github/CODEOWNERS
.github/CODEOWNERS @sethmlarson @shazow
src/urllib3/_version.py @sethmlarson @shazow
setup.py @sethmlarson @shazow
+pyproject.toml @sethmlarson @shazow
ci/ @sethmlarson @shazow
-.travis.yml @sethmlarson @shazow

MODIFY
.github/PULL_REQUEST_TEMPLATE/release.md
.github/PULL_REQUEST_TEMPLATE/release.md
* [ ] Get the release pull request approved by a [CODEOWNER](https://github.com/urllib3/urllib3/blob/main/.github/CODEOWNERS)
* [ ] Squash merge the release pull request with message "`Release <VERSION>`"
* [ ] Tag with X.Y.Z, push tag on urllib3/urllib3 (not on your fork, update `<REMOTE>` accordingly)
-
* Notice that the `<VERSION>` shouldn't have a `v` prefix (Use `1.26.6` instead of `v.1.26.6`)
* ```
git tag -a '<VERSION>' -m 'Release: <VERSION>'
git push <REMOTE> --tags
```
* [ ] Push to PyPI
-
* ```
cd /tmp
git clone ssh://git@github.com/urllib3/urllib3
source venv/bin/activate
python -m pip install -U pip
python -m pip install -U twine setuptools wheel build
+
+ # Set 'SOURCE_DATE_EPOCH' for build reproducibility.
+ export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
+ echo $SOURCE_DATE_EPOCH
+
python -m build
twine check dist/*

MODIFY
.github/workflows/ci.yml
.github/workflows/ci.yml
@@ -47,7 +47,7 @@ jobs:
- python-version: "2.7"
os: ubuntu-latest
experimental: false
- nox-session: unsupported_python2
+ nox-session: unsupported_setup_py
- python-version: "3.9"
os: ubuntu-latest
experimental: false
@@ -99,7 +99,7 @@ jobs:
NOX_SESSION: ${{ matrix.nox-session }}
- name: Upload Coverage
- if: ${{ matrix.nox-session != 'unsupported_python2' }}
+ if: ${{ matrix.nox-session != 'unsupported_setup_py' }}
uses: "actions/upload-artifact@v2"
with:
name: coverage-data

MODIFY
noxfile.py
noxfile.py
@@ -58,17 +58,17 @@ def test(session: nox.Session) -> None:
@nox.session(python=["2.7"])
-def unsupported_python2(session: nox.Session) -> None:
+def unsupported_setup_py(session: nox.Session) -> None:
# Can't check both returncode and output with session.run
process = subprocess.run(
- ["pip", "install", "."],
+ ["python", "setup.py", "install"],
env={**session.env},
text=True,
capture_output=True,
)
assert process.returncode == 1
print(process.stderr)
- assert "Unsupported Python version" in process.stderr
+ assert "Please use `python -m pip install .` instead." in process.stderr
@nox.session(python=["3"])

ADD
pyproject.toml
+# This file is protected via CODEOWNERS
+
+[build-system]
+requires = ["flit_core >=3.2,<4"]
+build-backend = "flit_core.buildapi"
+
+[project]
+name = "urllib3"
+description = "HTTP library with thread-safe connection pooling, file post, and more."
+readme = "README.md"
+keywords = ["urllib", "httplib", "threadsafe", "filepost", "http", "https", "ssl", "pooling"]
+authors = [
+ {name = "Andrey Petrov", email = "andrey.petrov@shazow.net"}
+]
+maintainers = [
+ {name = "Seth Michael Larson", email="sethmichaellarson@gmail.com"},
+ {name = "Quentin Pradet", email="quentin@pradet.me"},
+]
+classifiers = [
+ "Environment :: Web Environment",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3 :: Only",
+ "Programming Language :: Python :: Implementation :: CPython",
+ "Programming Language :: Python :: Implementation :: PyPy",
+ "Topic :: Internet :: WWW/HTTP",
+ "Topic :: Software Development :: Libraries",
+]
+requires-python = ">=3.7, <4"
+dynamic = ["version"]
+
+[project.optional-dependencies]
+brotli = [
+ "brotli>=1.0.9; platform_python_implementation == 'CPython'",
+ "brotlicffi>=0.8.0; platform_python_implementation != 'CPython'"
+]
+secure = [
+ "pyOpenSSL>=0.14",
+ "cryptography>=1.3.4",
+ "idna>=2.0.0",
+ "certifi",
+]
+socks = [
+ "PySocks>=1.5.6,<2.0,!=1.5.7",
+]
+
+[project.urls]
+"Documentation" = "https://urllib3.readthedocs.io"
+"Code" = "https://github.com/urllib3/urllib3"
+"Issue tracker" = "https://github.com/urllib3/urllib3/issues"

MODIFY
setup.cfg
setup.cfg
@@ -3,21 +3,6 @@ ignore = E501, E203, W503, W504
exclude=./docs/conf.py
max-line-length=99
-[metadata]
-license_file = LICENSE.txt
-provides_extra =
- secure
- socks
- brotli
-requires_dist =
- pyOpenSSL>=0.14; extra == 'secure'
- cryptography>=1.3.4; extra == 'secure'
- idna>=2.0.0; extra == 'secure'
- certifi; extra == 'secure'
- PySocks>=1.5.6,<2.0,!=1.5.7; extra == 'socks'
- brotli>=1.0.9; platform_python_implementation == 'CPython' and extra == 'brotli'
- brotlicffi>=0.8.0; platform_python_implementation != 'CPython' and extra == 'brotli'
-
[tool:pytest]
xfail_strict = true
python_classes = Test *TestCase

MODIFY
setup.py
setup.py
#!/usr/bin/env python
# This file is protected via CODEOWNERS
-import os
-import re
import sys
-from setuptools import setup
-
-CURRENT_PYTHON = sys.version_info[:2]
-REQUIRED_PYTHON = (3, 7)
-
-# This check and everything above must remain compatible with Python 2.7.
-if CURRENT_PYTHON < REQUIRED_PYTHON:
sys.stderr.write(
"""
-==========================
-Unsupported Python version
-==========================
-This version of urllib3 requires Python {}.{}, but you're trying to
-install it on Python {}.{}.
-This may be because you are using a version of pip that doesn't
-understand the python_requires classifier. Make sure you
-have pip >= 9.0 and setuptools >= 24.2, then try again:
- $ python -m pip install --upgrade pip setuptools
- $ python -m pip install urllib3
-This will install the latest version of urllib3 which works on your
-version of Python. If you can't upgrade your pip (or Python), request
-an older version of urllib3:
- $ python -m pip install "urllib3<2"
-""".format(
- *(REQUIRED_PYTHON + CURRENT_PYTHON)
- )
- )
- sys.exit(1)
-
+===============================
+Unsupported installation method
+===============================
-base_path = os.path.dirname(__file__)
+This version of urllib3 has dropped support for Python 2.7 and no longer supports
+installation with `python setup.py install`.
-# Get the version (borrowed from SQLAlchemy)
-with open(os.path.join(base_path, "src", "urllib3", "_version.py")) as fp:
- VERSION = (
- re.compile(r""".*__version__ = ["'](.*?)['"]""", re.S).match(fp.read()).group(1)
- )
-
-
-with open("README.md", encoding="utf-8") as fp:
- readme = fp.read()
-
-version = VERSION
-
-setup(
- name="urllib3",
- version=version,
- description="HTTP library with thread-safe connection pooling, file post, and more.",
- long_description=readme,
- long_description_content_type="text/markdown",
- classifiers=[
- "Environment :: Web Environment",
- "Intended Audience :: Developers",
- "License :: OSI Approved :: MIT License",
- "Operating System :: OS Independent",
- "Programming Language :: Python",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.7",
- "Programming Language :: Python :: 3.8",
- "Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10",
- "Programming Language :: Python :: 3.11",
- "Programming Language :: Python :: 3 :: Only",
- "Programming Language :: Python :: Implementation :: CPython",
- "Programming Language :: Python :: Implementation :: PyPy",
- "Topic :: Internet :: WWW/HTTP",
- "Topic :: Software Development :: Libraries",
- ],
- keywords="urllib httplib threadsafe filepost http https ssl pooling",
- author="Andrey Petrov",
- author_email="andrey.petrov@shazow.net",
- url="https://urllib3.readthedocs.io",
- project_urls={
- "Documentation": "https://urllib3.readthedocs.io",
- "Code": "https://github.com/urllib3/urllib3",
- "Issue tracker": "https://github.com/urllib3/urllib3/issues",
- },
- license="MIT",
- packages=[
- "urllib3",
- "urllib3.contrib",
- "urllib3.contrib._securetransport",
- "urllib3.util",
- ],
- package_data={
- "urllib3": ["py.typed"],
- },
- package_dir={"": "src"},
- requires=[],
- python_requires=">=3.7, <4",
- extras_require={
- "brotli": [
- "brotli>=1.0.9; platform_python_implementation == 'CPython'",
- "brotlicffi>=0.8.0; platform_python_implementation != 'CPython'",
- ],
- "secure": [
- "pyOpenSSL>=0.14",
- "cryptography>=1.3.4",
- "idna>=2.0.0",
- "certifi",
- ],
- "socks": ["PySocks>=1.5.6,<2.0,!=1.5.7"],
- },
+Please use `python -m pip install .` instead.
+"""
)
+sys.exit(1)

Switch to Flit as a build-system