Skip to content

Commit 00355b2

Browse files
authored
[None][feat] precompiled installation from local src dir with fnmatch only (NVIDIA#10430)
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
1 parent 77be1b7 commit 00355b2

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

setup.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ def extract_from_precompiled(precompiled_location: str, package_data: List[str],
173173
- Remote URL: Downloads and extracts from URL (wheel or tar.gz)
174174
"""
175175
import fnmatch
176-
import glob
177176
import shutil
178177
import tarfile
179178
import zipfile
@@ -183,6 +182,7 @@ def extract_from_precompiled(precompiled_location: str, package_data: List[str],
183182

184183
# Handle local directory (assuming repo structure)
185184
if os.path.isdir(precompiled_location):
185+
precompiled_location = os.path.abspath(precompiled_location)
186186
print(
187187
f"Using local directory as precompiled source: {precompiled_location}"
188188
)
@@ -192,14 +192,13 @@ def extract_from_precompiled(precompiled_location: str, package_data: List[str],
192192
f"Directory {precompiled_location} does not contain a tensorrt_llm folder."
193193
)
194194

195-
for pattern in package_data:
196-
full_pattern = os.path.join(source_tensorrt_llm, pattern)
197-
for src_file in glob.glob(full_pattern, recursive=True):
198-
if not os.path.isfile(src_file):
199-
continue
200-
195+
# Walk through all files and match using fnmatch (consistent with wheel extraction)
196+
for root, dirs, files in os.walk(source_tensorrt_llm):
197+
for filename in files:
198+
src_file = os.path.join(root, filename)
199+
# Get path relative to precompiled_location (e.g., "tensorrt_llm/libs/libtensorrt_llm.so")
201200
rel_path = os.path.relpath(src_file, precompiled_location)
202-
dst_file = rel_path # e.g., "tensorrt_llm/libs/libtensorrt_llm.so"
201+
dst_file = rel_path
203202

204203
# Skip yaml files
205204
if dst_file.endswith(".yaml"):
@@ -214,6 +213,14 @@ def extract_from_precompiled(precompiled_location: str, package_data: List[str],
214213
if not any(dst_file.startswith(d) for d in allowed_dirs):
215214
continue
216215

216+
# Check if file matches any pattern using fnmatch (same as wheel extraction)
217+
for filename_pattern in package_data:
218+
if fnmatch.fnmatchcase(rel_path,
219+
f"tensorrt_llm/{filename_pattern}"):
220+
break
221+
else:
222+
continue
223+
217224
dst_dir = os.path.dirname(dst_file)
218225
if dst_dir:
219226
os.makedirs(dst_dir, exist_ok=True)

0 commit comments

Comments
 (0)