Skip to content

Commit

Permalink
make executable finding more cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
renefritze committed Sep 28, 2022
1 parent a338bea commit cabd864
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions clang_tidy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import subprocess
import sys

from pathlib import Path
import functools
import pkg_resources


def _get_executable(name):
return pkg_resources.resource_filename('clang_tidy', f"data/bin/{name}")
@functools.lru_cache(maxsize=None)
def _get_executable(name:str) -> Path:
possibles = [Path(pkg_resources.resource_filename('clang_tidy', f"data/bin/{name}{s}"))
for s in ("", ".exe", ".bin", ".dmg")]
for exe in possibles:
if exe.exists():
print(f'Resource filename: {exe} ')
return exe

raise FileNotFoundError(f"No executable found for {name} at\n{possibles}")

def _run(name, *args):
command = [_get_executable(name)]
Expand Down

0 comments on commit cabd864

Please sign in to comment.