Skip to content

feat: stop using chmod on Bazel 8.6+#3855

Open
aignas wants to merge 2 commits into
bazel-contrib:mainfrom
aignas:aignas.chore.stop-chmod
Open

feat: stop using chmod on Bazel 8.6+#3855
aignas wants to merge 2 commits into
bazel-contrib:mainfrom
aignas:aignas.chore.stop-chmod

Conversation

@aignas

@aignas aignas commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add an extract_needs_chmod config flag that controls whether chmod
is run after extracting wheel files. The flag is False for Bazel

= 8.6 (where the fix for file permissions is built into Bazel) and
True for older versions.

Move _maybe_fix_permissions from whl_extract.bzl into
repo_utils.bzl and have _extract call it conditionally based
on the config flag. This ensures both whl_extract and patch_whl
benefit from the chmod fix when needed.

Fixes #3585

aignas added a commit to aignas/rules_python that referenced this pull request Jun 27, 2026
aignas added a commit to aignas/rules_python that referenced this pull request Jun 27, 2026
@aignas aignas force-pushed the aignas.chore.stop-chmod branch from 0575a4e to 3a0d510 Compare June 27, 2026 04:40

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces basic support for generating and importing uv.lock files via the lock rule, allowing uv.lock to be used as a primary source for package metadata. It also refactors wheel extraction permission fixes to be conditional on the Bazel version. The review feedback highlights several critical issues: missing Starlark loads for evaluate and select_whl in parse_requirements.bzl, a missing logger argument in repo_utils.bzl that could cause a failure during extraction, a recommendation to forward the logger in whl_extract.bzl, and a potential runtime crash in uv_lock_to_requirements.bzl if the source field in the lockfile is explicitly null.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

I am having trouble creating individual review comments. Click here to see my feedback.

python/private/pypi/parse_requirements.bzl (31-34)

high

The newly added _parse_uv_lock_json function references evaluate and select_whl, but these functions are not loaded in this file. This will cause a runtime Starlark evaluation error when parsing uv.lock files. Please load them from :markers.bzl and :select_whl.bzl respectively.

load("//python/uv/private:uv_lock_to_requirements.bzl", "uv_lock_extras_map")  # buildifier: disable=bzl-visibility
load(":argparse.bzl", "argparse")
load(":index_sources.bzl", "index_sources")
load(":markers.bzl", "evaluate")
load(":parse_requirements_txt.bzl", "parse_requirements_txt")
load(":select_whl.bzl", "select_whl")

python/private/repo_utils.bzl (536-537)

high

The _maybe_fix_permissions function expects a logger when mrctx is a module_ctx (which is what mrctx is designed to support). However, _extract calls it without passing logger, which will result in a guaranteed fail error if extract_needs_chmod is True and mrctx is a module_ctx. Please forward the logger from kwargs if available.

    if extract_needs_chmod:
        _maybe_fix_permissions(mrctx, whl_path = archive, logger = kwargs.get("logger"))

python/private/pypi/whl_extract.bzl (18-22)

medium

It is highly recommended to pass the logger parameter to repo_utils.extract to ensure that the same logger is reused and to prevent potential failures if extract is ever called in a context where a logger is required.

        archive = whl_path,
        output = install_dir_path,
        supports_whl_extraction = rp_config.supports_whl_extraction,
        extract_needs_chmod = rp_config.extract_needs_chmod,
        logger = logger,
    )

python/uv/private/uv_lock_to_requirements.bzl (70)

medium

In Starlark/Python, if the "source" key is explicitly set to null in the JSON, pkg.get("source", {}) will return None instead of the default {}. This can cause a runtime crash when calling source.get("registry"). Using pkg.get("source") or {} is a safer and more robust defensive programming pattern.

        source = pkg.get("source") or {}

Add an extract_needs_chmod config flag that controls whether chmod
is run after extracting wheel files. The flag is False for Bazel
>= 8.6 (where the fix for file permissions is built into Bazel) and
True for older versions.

Move _maybe_fix_permissions from whl_extract.bzl into repo_utils.bzl
and have _extract call it conditionally based on the config flag.
This ensures both whl_extract and patch_whl benefit from the chmod
fix when needed.

Fixes bazel-contrib#3585
@aignas aignas force-pushed the aignas.chore.stop-chmod branch from 3a0d510 to ce34fef Compare June 27, 2026 04:41
@aignas aignas marked this pull request as ready for review June 27, 2026 05:46
@aignas aignas requested a review from rickeylev as a code owner June 27, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop using chmod on bazel 8.6 or 9.0.1 and above

1 participant