Skip to content

Commit dc048b4

Browse files
(fix) resolve the compiling error under the offline mode
1 parent 980e533 commit dc048b4

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

python/setup.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,15 @@ def download_and_copy(name, src_func, dst_path, variable, version, url_func):
361361
print(f'{YELLOW}downloading and extracting {url} ... {NC}', file=sys.stderr, flush=True)
362362
file = tarfile.open(fileobj=open_url(url), mode="r|*")
363363
file.extractall(path=tmp_path)
364-
os.makedirs(os.path.split(dst_path)[0], exist_ok=True)
365-
print(f'copy {src_path} to {dst_path} ...', file=sys.stderr, flush=True)
366-
if os.path.isdir(src_path):
367-
shutil.copytree(src_path, dst_path, dirs_exist_ok=True)
368-
else:
369-
shutil.copy(src_path, dst_path)
364+
# In offline build mode the cache may be absent (e.g. backend doesn't need the
365+
# NVIDIA toolkits), skip the copy in that case instead of failing.
366+
if os.path.exists(src_path):
367+
os.makedirs(os.path.split(dst_path)[0], exist_ok=True)
368+
print(f'copy {src_path} to {dst_path} ...', file=sys.stderr, flush=True)
369+
if os.path.isdir(src_path):
370+
shutil.copytree(src_path, dst_path, dirs_exist_ok=True)
371+
else:
372+
shutil.copy(src_path, dst_path)
370373

371374

372375
# ---- cmake extension ----

python/setup_tools/utils/tools.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __init__(self):
132132
NetConfig.headers = {'User-Agent': NetConfig.user_agent}
133133

134134
def download(self, url=None, path=None, file_name=None, mode=None, module=None, required=False):
135-
if self.module_offline_handler.is_offline_build():
135+
if self.module_offline_handler.is_offline_build() and self.module_offline_handler.offline_build_dir is not None:
136136
self.offline_copy(module, required)
137137
return
138138

@@ -285,6 +285,9 @@ def handle_flagtree_hook(self, kargs):
285285

286286
def handle_triton_origin_toolkits(self):
287287

288+
if self.offline_build_dir is None:
289+
return
290+
288291
# detect system/arch/version, the same with setup.py
289292
system = platform.system()
290293
arch = platform.machine()

0 commit comments

Comments
 (0)