mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +00:00
Fix python module invocation (#2563)
This commit is contained in:
parent
dd0145624b
commit
5a9258327b
1 changed files with 18 additions and 1 deletions
|
@ -3,6 +3,23 @@ import sys
|
|||
import sysconfig
|
||||
from pathlib import Path
|
||||
|
||||
RUFF_PATHS = [
|
||||
Path(sysconfig.get_config_var("userbase")) / "bin" / "ruff",
|
||||
Path(sysconfig.get_path("scripts")) / "ruff",
|
||||
]
|
||||
|
||||
|
||||
def find_ruff_bin() -> Path:
|
||||
"""Return the ruff binary path."""
|
||||
for ruff_path in RUFF_PATHS:
|
||||
if ruff_path.is_file():
|
||||
return ruff_path
|
||||
raise FileNotFoundError(ruff_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ruff = Path(sysconfig.get_path("scripts")) / "ruff"
|
||||
try:
|
||||
ruff = find_ruff_bin()
|
||||
except FileNotFoundError as e:
|
||||
raise FileNotFoundError(e) from e
|
||||
sys.exit(os.spawnv(os.P_WAIT, ruff, [ruff, *sys.argv[1:]]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue