Skip to content

Commit

Permalink
Tweak comments
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Oct 3, 2024
1 parent 3d86535 commit f2dc241
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/ruff/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def find_ruff_bin() -> str:
if os.path.isfile(target_path):
return target_path

# Might be a pip build environment
# Search for pip-specific build environments.
#
# See: https://github.com/pypa/pip/blob/102d8187a1f5a4cd5de7a549fd8a9af34e89a54f/src/pip/_internal/build_env.py#L87
paths = os.environ.get("PATH", "").split(os.pathsep)
if len(paths) >= 2:
# https://github.com/pypa/pip/blob/main/src/pip/_internal/build_env.py#L87
first, second = os.path.split(paths[0]), os.path.split(paths[1])
# we need an overlay and normal folder within pip-build-env-{random} folders
# Search for both an `overlay` and `normal` folder within a `pip-build-env-{random}` folder.
if (
len(first) >= 3
and len(second) >= 3
Expand All @@ -47,7 +48,8 @@ def find_ruff_bin() -> str:
and second[-3].startswith("pip-build-env-")
and second[-2] == "normal"
):
candidate = os.path.join(first, ruff_exe) # the overlay contains ruff
# The overlay must contain the ruff binary.
candidate = os.path.join(first, ruff_exe)
if os.path.isfile(candidate):
return candidate

Expand Down

0 comments on commit f2dc241

Please # to comment.