mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
[rh:requests] Patch support for requests
2.32.2+ (#9992)
Authored by: Grub4K
This commit is contained in:
parent
4ccd73fea0
commit
3f7999533e
5 changed files with 36 additions and 13 deletions
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
|
@ -360,7 +360,7 @@ jobs:
|
||||||
- name: Install Requirements
|
- name: Install Requirements
|
||||||
run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
|
run: | # Custom pyinstaller built with https://github.com/yt-dlp/pyinstaller-builds
|
||||||
python devscripts/install_deps.py -o --include build
|
python devscripts/install_deps.py -o --include build
|
||||||
python devscripts/install_deps.py --include py2exe --include curl-cffi
|
python devscripts/install_deps.py --include curl-cffi
|
||||||
python -m pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-5.8.0-py3-none-any.whl"
|
python -m pip install -U "https://yt-dlp.github.io/Pyinstaller-Builds/x86_64/pyinstaller-5.8.0-py3-none-any.whl"
|
||||||
|
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
|
@ -369,12 +369,20 @@ jobs:
|
||||||
python devscripts/make_lazy_extractors.py
|
python devscripts/make_lazy_extractors.py
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
python -m bundle.py2exe
|
|
||||||
Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
|
|
||||||
python -m bundle.pyinstaller
|
python -m bundle.pyinstaller
|
||||||
python -m bundle.pyinstaller --onedir
|
python -m bundle.pyinstaller --onedir
|
||||||
|
Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_real.exe
|
||||||
Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
|
Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip
|
||||||
|
|
||||||
|
- name: Install Requirements (py2exe)
|
||||||
|
run: |
|
||||||
|
python devscripts/install_deps.py --include py2exe
|
||||||
|
- name: Build (py2exe)
|
||||||
|
run: |
|
||||||
|
python -m bundle.py2exe
|
||||||
|
Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe
|
||||||
|
Move-Item ./dist/yt-dlp_real.exe ./dist/yt-dlp.exe
|
||||||
|
|
||||||
- name: Verify --update-to
|
- name: Verify --update-to
|
||||||
if: vars.UPDATE_TO_VERIFICATION
|
if: vars.UPDATE_TO_VERIFICATION
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -263,7 +263,7 @@ You can also run `make yt-dlp` instead to compile only the binary without updati
|
||||||
|
|
||||||
### Standalone Py2Exe Builds (Windows)
|
### Standalone Py2Exe Builds (Windows)
|
||||||
|
|
||||||
While we provide the option to build with [py2exe](https://www.py2exe.org), it is recommended to build [using PyInstaller](#standalone-pyinstaller-builds) instead since the py2exe builds **cannot contain `pycryptodomex`/`certifi`/`requests` and need VC++14** on the target computer to run.
|
While we provide the option to build with [py2exe](https://www.py2exe.org), it is recommended to build [using PyInstaller](#standalone-pyinstaller-builds) instead since the py2exe builds **cannot contain `pycryptodomex`/`certifi` and need VC++14** on the target computer to run.
|
||||||
|
|
||||||
If you wish to build it anyway, install Python (if it is not already installed) and you can run the following commands:
|
If you wish to build it anyway, install Python (if it is not already installed) and you can run the following commands:
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ def main():
|
||||||
# py2exe cannot import Crypto
|
# py2exe cannot import Crypto
|
||||||
'Crypto',
|
'Crypto',
|
||||||
'Cryptodome',
|
'Cryptodome',
|
||||||
# py2exe builds fail to run with requests >=2.32.0
|
# py2exe appears to confuse this with our socks library.
|
||||||
'requests',
|
# We don't use pysocks and urllib3.contrib.socks would fail to import if tried.
|
||||||
'urllib3'
|
'urllib3.contrib.socks'
|
||||||
],
|
],
|
||||||
'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
|
'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
|
||||||
# Modules that are only imported dynamically must be added here
|
# Modules that are only imported dynamically must be added here
|
||||||
|
|
|
@ -46,7 +46,7 @@ dependencies = [
|
||||||
"certifi",
|
"certifi",
|
||||||
"mutagen",
|
"mutagen",
|
||||||
"pycryptodomex",
|
"pycryptodomex",
|
||||||
"requests>=2.32.0,<3",
|
"requests>=2.31.0,<3",
|
||||||
"urllib3>=1.26.17,<3",
|
"urllib3>=1.26.17,<3",
|
||||||
"websockets>=12.0",
|
"websockets>=12.0",
|
||||||
]
|
]
|
||||||
|
@ -73,7 +73,10 @@ pyinstaller = [
|
||||||
"pyinstaller>=6.3; sys_platform!='darwin'",
|
"pyinstaller>=6.3; sys_platform!='darwin'",
|
||||||
"pyinstaller==5.13.2; sys_platform=='darwin'", # needed for curl_cffi
|
"pyinstaller==5.13.2; sys_platform=='darwin'", # needed for curl_cffi
|
||||||
]
|
]
|
||||||
py2exe = ["py2exe>=0.12"]
|
py2exe = [
|
||||||
|
"py2exe>=0.12",
|
||||||
|
"requests==2.31.*",
|
||||||
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Documentation = "https://github.com/yt-dlp/yt-dlp#readme"
|
Documentation = "https://github.com/yt-dlp/yt-dlp#readme"
|
||||||
|
|
|
@ -21,13 +21,14 @@ urllib3_version = tuple(int_or_none(x, default=0) for x in urllib3.__version__.s
|
||||||
if urllib3_version < (1, 26, 17):
|
if urllib3_version < (1, 26, 17):
|
||||||
raise ImportError('Only urllib3 >= 1.26.17 is supported')
|
raise ImportError('Only urllib3 >= 1.26.17 is supported')
|
||||||
|
|
||||||
if requests.__build__ < 0x023200:
|
if requests.__build__ < 0x023100:
|
||||||
raise ImportError('Only requests >= 2.32.0 is supported')
|
raise ImportError('Only requests >= 2.31.0 is supported')
|
||||||
|
|
||||||
import requests.adapters
|
import requests.adapters
|
||||||
import requests.utils
|
import requests.utils
|
||||||
import urllib3.connection
|
import urllib3.connection
|
||||||
import urllib3.exceptions
|
import urllib3.exceptions
|
||||||
|
import urllib3.util
|
||||||
|
|
||||||
from ._helper import (
|
from ._helper import (
|
||||||
InstanceStoreMixin,
|
InstanceStoreMixin,
|
||||||
|
@ -180,14 +181,25 @@ class RequestsHTTPAdapter(requests.adapters.HTTPAdapter):
|
||||||
extra_kwargs['proxy_ssl_context'] = self._proxy_ssl_context
|
extra_kwargs['proxy_ssl_context'] = self._proxy_ssl_context
|
||||||
return super().proxy_manager_for(proxy, **proxy_kwargs, **self._pm_args, **extra_kwargs)
|
return super().proxy_manager_for(proxy, **proxy_kwargs, **self._pm_args, **extra_kwargs)
|
||||||
|
|
||||||
|
# Skip `requests` internal verification; we use our own SSLContext
|
||||||
|
# requests 2.31.0+
|
||||||
def cert_verify(*args, **kwargs):
|
def cert_verify(*args, **kwargs):
|
||||||
# Lean on our SSLContext for cert verification
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# requests 2.31.0-2.32.1
|
||||||
def _get_connection(self, request, *_, proxies=None, **__):
|
def _get_connection(self, request, *_, proxies=None, **__):
|
||||||
# Lean on our SSLContext for cert verification
|
|
||||||
return self.get_connection(request.url, proxies)
|
return self.get_connection(request.url, proxies)
|
||||||
|
|
||||||
|
# requests 2.32.2+: Reimplementation without `_urllib3_request_context`
|
||||||
|
def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
|
||||||
|
url = urllib3.util.parse_url(request.url).url
|
||||||
|
|
||||||
|
manager = self.poolmanager
|
||||||
|
if proxy := select_proxy(url, proxies):
|
||||||
|
manager = self.proxy_manager_for(proxy)
|
||||||
|
|
||||||
|
return manager.connection_from_url(url)
|
||||||
|
|
||||||
|
|
||||||
class RequestsSession(requests.sessions.Session):
|
class RequestsSession(requests.sessions.Session):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue