Skip to content

Nix + build --@rules_python//python/config_settings:bootstrap_impl=script issues. #192

@pcj

Description

@pcj

We have a setup that uses both nix (rules_nixpkgs) and rules_python+rules_pycross. Recently flipped to using this new "multiphase bootstrap strategy" using build --@rules_python//python/config_settings:bootstrap_impl=script in the .bazelrc, and now can no longer build grpclib:

I'm not sure if nix is part of the issue here, but mentioning it for context

ERROR: /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/external/pypi/_lock/BUILD.bazel:5:8: Building grpclib-0.4.7.tar.gz failed: (Exit 1): wheel_builder failed: error executing WheelBuild command (from target @@pypi//_lock:_build_grpclib@0.4.7) bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder --sdist external/pypi_sdist_grpclib_0.4.7/file/grpclib-0.4.7.tar.gz --wheel-file ... (remaining 23 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
===== CROSSENV FAILED =====
/private/tmp/nix-shell-32134-344847943/wheelbuilddj7nmzop/sdist/../bazel-execroot/unity/external/python_aarch64-apple-darwin/bin/python3: Error while finding module specification for 'pycross.private.tools.crossenv' (ModuleNotFoundError: No module named 'pycross')

Traceback (most recent call last):
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/_wheel_builder_stage2_bootstrap.py", line 407, in <module>
    main()
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/_wheel_builder_stage2_bootstrap.py", line 403, in main
    _run_py(main_filename, args=sys.argv[1:])
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/_wheel_builder_stage2_bootstrap.py", line 266, in _run_py
    runpy.run_path(main_filename, run_name="__main__")
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/wheel_builder.py", line 1038, in <module>
    main_wrapper(parse_flags())
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/wheel_builder.py", line 1031, in main_wrapper
    main(args, _temp_dir, _is_debug)
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/wheel_builder.py", line 825, in main
    build_venv(
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/wheel_builder.py", line 599, in build_venv
    build_cross_venv(env_dir, exec_python_exe, target_python_exe, sysconfig_vars, target_env)
  File "/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/sandbox/processwrapper-sandbox/105/execroot/unity/bazel-out/darwin_arm64-opt-exec-ST-b70c0c6d18a4/bin/external/rules_pycross/pycross/private/tools/wheel_builder.runfiles/unity/../rules_pycross/pycross/private/tools/wheel_builder.py", line 556, in build_cross_venv
    subprocess.check_output(args=crossenv_args, env=os.environ, stderr=subprocess.STDOUT)

Currently still using WORKSPACE with rules_pycross at head:

    # Commit: d2d8419398fa0d1e2fbe946a0778935d9db4de3e
    # Date: 2025-09-25 00:11:10 +0000 UTC
    # URL: https://github.com/jvolkman/rules_pycross/commit/d2d8419398fa0d1e2fbe946a0778935d9db4de3e
    #
    # Use project dependencies from uv.lock (#186)
    #
    # * Add test for generating lock file in BUILD.bazel
    #
    # * Load project dependencies from uv.lock
    # Size: 309192 (309 kB)
    http_archive(
        name = "rules_pycross",
        sha256 = "71070138fd728e5cb132f3b7d67329f100b4a87d12272c4898c6a53be4c041f0",
        strip_prefix = "rules_pycross-d2d8419398fa0d1e2fbe946a0778935d9db4de3e",
        urls = ["https://github.com/jvolkman/rules_pycross/archive/d2d8419398fa0d1e2fbe946a0778935d9db4de3e.tar.gz"],
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions