Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: _which_unchecked: don't watch PATH if binary exists. #2552

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ Unreleased changes template.
change. Fixes [#2468](https://github.com/bazelbuild/rules_python/issues/2468).
+ (gazelle) Gazelle no longer ignores `setup.py` files by default. To restore
this behavior, apply the `# gazelle:python_ignore_files setup.py` directive.
* Don't re-fetch whl_library, python_repository, etc. repository rules
rickeylev marked this conversation as resolved.
Show resolved Hide resolved
whenever `PATH` changes. Fixes
[#2551](https://github.com/bazelbuild/rules_python/issues/2551).

[pep-695]: https://peps.python.org/pep-0695/

Expand Down
4 changes: 2 additions & 2 deletions python/private/repo_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _which_checked(mrctx, binary_name):
def _which_unchecked(mrctx, binary_name):
"""Tests to see if a binary exists.
This is also watch the `PATH` environment variable.
Watches the `PATH` environment variable if the binary doesn't exist.
Args:
binary_name: name of the binary to find.
Expand All @@ -268,12 +268,12 @@ def _which_unchecked(mrctx, binary_name):
* `describe_failure`: `Callable | None`; takes no args. If the
binary couldn't be found, provides a detailed error description.
"""
path = _getenv(mrctx, "PATH", "")
binary = mrctx.which(binary_name)
if binary:
_watch(mrctx, binary)
describe_failure = None
else:
path = _getenv(mrctx, "PATH", "")
describe_failure = lambda: _which_describe_failure(binary_name, path)

return struct(
Expand Down