Skip to content

Commit

Permalink
Merge pull request #58 from calcmogul/replace-deprecated-usage-of-pkg…
Browse files Browse the repository at this point in the history
…-resources

Replace deprecated usage of pkg_resources with importlib.resources
  • Loading branch information
renefritze authored Mar 18, 2024
2 parents 757a007 + d3cb951 commit 9a4dcdf
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions clang_tidy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@
import sys
from pathlib import Path
import functools
import pkg_resources
import os

if sys.version_info.minor >= 9:
# Only available on 3.9 or later, and required on 3.12
from importlib.resources import files
else:
import pkg_resources


@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")]
if sys.version_info.minor >= 9:
# Only available in 3.9 or later, and required in 3.12
possibles = [
Path(files("clang_tidy") / f"data/bin/{name}{s}")
for s in ("", ".exe", ".bin", ".dmg")
]
else:
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():
if os.environ.get("CLANG_TIDY_WHEEL_VERBOSE", None):
Expand Down

0 comments on commit 9a4dcdf

Please sign in to comment.