Skip to content

Commit 32c4e43

Browse files
authored
Don't call os.remove on Windows in intel/backend/compiler.py (#4640)
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent e5ad020 commit 32c4e43

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

third_party/intel/backend/compiler.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,17 @@ def make_spv(src, metadata, options, device_arch):
435435
ocloc_cmd[-1] = metadata["build_flags"] + shader_dump_opt
436436
subprocess.run(ocloc_cmd, check=True, close_fds=False, stdout=flog,
437437
stderr=subprocess.STDOUT)
438-
os.remove(flog.name)
439-
if os.path.exists(fsrc.name):
438+
if os.name != "nt":
439+
# Skip deleting on Windows to avoid
440+
# PermissionError: [WinError 32] The process cannot access the file because
441+
# it is being used by another process
442+
os.remove(flog.name)
443+
if os.path.exists(fsrc.name) and os.name != "nt":
440444
os.remove(fsrc.name)
441445
except subprocess.CalledProcessError as e:
442446
with open(flog.name) as log_file:
443447
log = log_file.read()
444-
if os.path.exists(flog.name):
448+
if os.path.exists(flog.name) and os.name != "nt":
445449
os.remove(flog.name)
446450

447451
if e.returncode == 255:
@@ -457,7 +461,7 @@ def make_spv(src, metadata, options, device_arch):
457461

458462
with open(fbin, 'rb') as f:
459463
zebin = f.read()
460-
if os.path.exists(fbin):
464+
if os.path.exists(fbin) and os.name != "nt":
461465
os.remove(fbin)
462466
return zebin
463467
return spirv

0 commit comments

Comments
 (0)