Upload hf_env/lib/python3.14/site-packages/pip/_vendor/requests/packages.py with huggingface_hub
Browse files
hf_env/lib/python3.14/site-packages/pip/_vendor/requests/packages.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
|
| 3 |
+
from .compat import chardet
|
| 4 |
+
|
| 5 |
+
# This code exists for backwards compatibility reasons.
|
| 6 |
+
# I don't like it either. Just look the other way. :)
|
| 7 |
+
|
| 8 |
+
for package in ("urllib3", "idna"):
|
| 9 |
+
vendored_package = "pip._vendor." + package
|
| 10 |
+
locals()[package] = __import__(vendored_package)
|
| 11 |
+
# This traversal is apparently necessary such that the identities are
|
| 12 |
+
# preserved (requests.packages.urllib3.* is urllib3.*)
|
| 13 |
+
for mod in list(sys.modules):
|
| 14 |
+
if mod == vendored_package or mod.startswith(vendored_package + '.'):
|
| 15 |
+
unprefixed_mod = mod[len("pip._vendor."):]
|
| 16 |
+
sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]
|
| 17 |
+
|
| 18 |
+
if chardet is not None:
|
| 19 |
+
target = chardet.__name__
|
| 20 |
+
for mod in list(sys.modules):
|
| 21 |
+
if mod == target or mod.startswith(f"{target}."):
|
| 22 |
+
imported_mod = sys.modules[mod]
|
| 23 |
+
sys.modules[f"requests.packages.{mod}"] = imported_mod
|
| 24 |
+
mod = mod.replace(target, "chardet")
|
| 25 |
+
sys.modules[f"requests.packages.{mod}"] = imported_mod
|