Skip to content

Commit 9c238ae

Browse files
committed
Using python lib for download to make it platform agnostic
1 parent 3469736 commit 9c238ae

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

py/torch_tensorrt/dynamo/utils.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
import shutil
88
import subprocess
99
import sys
10+
import urllib.request
1011
import warnings
1112
from dataclasses import fields, replace
1213
from enum import Enum
1314
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
15+
from urllib.error import URLError
1416

1517
import numpy as np
1618
import sympy
@@ -827,18 +829,21 @@ def download_plugin_lib_path(py_version: str, platform: str) -> str:
827829
base_url = "https://pypi.nvidia.com/tensorrt-llm/"
828830
file_name = f"tensorrt_llm-0.18.0-{py_version}-{py_version}-{platform}.whl"
829831
download_url = base_url + file_name
830-
cmd = ["wget", download_url]
831832
if not (os.path.exists(file_name)):
832833
try:
833-
subprocess.run(cmd, check=True)
834+
logger.debug(f"Downloading {download_url} ...")
835+
urllib.request.urlretrieve(download_url, file_name)
834836
logger.debug("Download succeeded and TRT-LLM wheel is now present")
835-
except subprocess.CalledProcessError as e:
837+
except urllib.error.HTTPError as e:
836838
logger.error(
837-
"Download failed (file not found or connection issue). Error code:",
838-
e.returncode,
839+
f"HTTP error {e.code} when trying to download {download_url}: {e.reason}"
839840
)
840-
except FileNotFoundError:
841-
logger.error("wget is required but not found. Please install wget.")
841+
except urllib.error.URLError as e:
842+
logger.error(
843+
f"URL error when trying to download {download_url}: {e.reason}"
844+
)
845+
except OSError as e:
846+
logger.error(f"Local file write error: {e}")
842847

843848
# Proceeding with the unzip of the wheel file
844849
# This will exist if the filename was already downloaded

0 commit comments

Comments
 (0)