From b2fb2917c0a9147e625c64c62bf712057a299242 Mon Sep 17 00:00:00 2001 From: StardustDL Date: Sun, 28 Jan 2024 18:55:12 +0800 Subject: [PATCH] remove requests dependency --- src/aexpy/preprocessing/download.py | 7 ++++--- src/aexpy/preprocessing/wheel.py | 14 -------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/aexpy/preprocessing/download.py b/src/aexpy/preprocessing/download.py index 93d7e287..7e23eb73 100644 --- a/src/aexpy/preprocessing/download.py +++ b/src/aexpy/preprocessing/download.py @@ -6,11 +6,10 @@ from pathlib import Path from typing import override from urllib import parse +import urllib.request import os import subprocess -import requests - from ..models import Release from .wheel import CompatibilityTag from . import Preprocessor @@ -254,7 +253,9 @@ def downloadRawWheel( if not cacheFile.exists(): logger.info(f"Download wheel @ {url}.") try: - content = requests.get(url, timeout=60).content + req = urllib.request.Request(url) + with urllib.request.urlopen(req, timeout=60) as res: + content = res.read() if info.sha256: if hashlib.sha256(content).hexdigest() != info.sha256: raise Exception(f"Release download sha256 mismatch: {info}.") diff --git a/src/aexpy/preprocessing/wheel.py b/src/aexpy/preprocessing/wheel.py index 1f638d96..7e98731f 100644 --- a/src/aexpy/preprocessing/wheel.py +++ b/src/aexpy/preprocessing/wheel.py @@ -1,26 +1,12 @@ -import hashlib -import platform -import re -import shutil from typing import override import zipfile from dataclasses import dataclass, field -from datetime import datetime, timedelta from email.message import Message from email.parser import Parser from logging import Logger from pathlib import Path -from urllib import parse -import json - -import requests -import wheel.metadata from aexpy import getCacheDirectory, utils -from aexpy.models import Distribution - -from ..models import Distribution, Release -from ..utils import elapsedTimer, ensureDirectory, logWithFile from . import Preprocessor FILE_ORIGIN = "https://files.pythonhosted.org/"