|
3 | 3 | import platform
|
4 | 4 |
|
5 | 5 | from pathlib import Path
|
6 |
| -from typing import Dict, List, Optional |
| 6 | +from typing import List, Optional |
7 | 7 |
|
8 |
| - |
9 |
| -def run_cmd( |
10 |
| - cmd: List[str], |
11 |
| - env: Optional[Dict[str, str]] = None, |
12 |
| - must_succeed: bool = True, |
13 |
| - capture_output: bool = True, |
14 |
| -) -> subprocess.CompletedProcess: |
15 |
| - """Run a command quietly, only printing stderr if the command fails.""" |
16 |
| - |
17 |
| - logging.info(f"Exec: {' '.join(cmd)}") |
18 |
| - result = subprocess.run( |
19 |
| - cmd, |
20 |
| - check=False, |
21 |
| - stdout=subprocess.PIPE if capture_output else None, |
22 |
| - stderr=subprocess.STDOUT if capture_output else None, |
23 |
| - universal_newlines=True, |
24 |
| - env=env, |
25 |
| - ) |
26 |
| - if result.returncode != 0: |
27 |
| - logging.error(f"Error running: {' '.join(cmd)}") |
28 |
| - if result.stdout is not None: |
29 |
| - logging.error(result.stdout) |
30 |
| - if must_succeed: |
31 |
| - raise ChildProcessError() |
32 |
| - return result |
| 8 | +from cloe_launch import procutils |
33 | 9 |
|
34 | 10 |
|
35 | 11 | def patch_rpath(file: Path, rpath: List[str]) -> Optional[subprocess.CompletedProcess]:
|
@@ -58,14 +34,14 @@ def patch_rpath(file: Path, rpath: List[str]) -> Optional[subprocess.CompletedPr
|
58 | 34 | file_arg = str(file)
|
59 | 35 | rpath_arg = ":".join(rpath)
|
60 | 36 | logging.debug(f"Setting RPATH: {file_arg} -> {rpath_arg}")
|
61 |
| - return run_cmd(["patchelf", "--set-rpath", rpath_arg, file_arg], must_succeed=False) |
| 37 | + return procutils.system(["patchelf", "--set-rpath", rpath_arg, file_arg], must_succeed=False) |
62 | 38 |
|
63 | 39 |
|
64 | 40 | def find_binary_files(cwd: Optional[Path] = None) -> List[Path]:
|
65 | 41 | """Return a list of all file paths that are of the binary type."""
|
66 | 42 | assert platform.system() != "Windows"
|
67 | 43 | result = subprocess.run(
|
68 |
| - """find -type f -exec sh -c "file -i '{}' | grep -q '; charset=binary'" \; -print""", |
| 44 | + """find -type f -exec sh -c "file -i '{}' | grep -q '; charset=binary'" \\; -print""", |
69 | 45 | shell=True,
|
70 | 46 | stdout=subprocess.PIPE,
|
71 | 47 | check=True,
|
|
0 commit comments