Skip to content

Commit b5ae0b9

Browse files
authored
Fix execute permissions for flatc binary extracted from PAR files (#18738)
Differential Revision: D99780508 Pull Request resolved: #18738
1 parent ac68932 commit b5ae0b9

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

exir/_serialize/_flatbuffer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
import re
1313
import shutil
14+
import stat
1415
import subprocess
1516

1617
import tempfile
@@ -252,6 +253,15 @@ def _run_flatc(args: Sequence[str]) -> None:
252253
if flatc_resource.is_file():
253254
# Use the provided flatc binary.
254255
with importlib.resources.as_file(flatc_resource) as flatc_path:
256+
# Ensure the binary has execute permissions (needed for PAR files)
257+
try:
258+
current_mode = flatc_path.stat().st_mode
259+
if not (current_mode & stat.S_IXUSR):
260+
flatc_path.chmod(
261+
current_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
262+
)
263+
except OSError:
264+
pass
255265
subprocess.run([flatc_path] + list(args), check=True)
256266
else:
257267
# Expect the `flatc` tool to be on the system path or set as an env var.

0 commit comments

Comments
 (0)