Skip to content

[feat] Support bin-on-bin deps by transitioning binaries into libraries#762

Closed
ParaLock wants to merge 8 commits intoaspect-build:mainfrom
ParaLock:nmercaldo/bin-to-lib-transition
Closed

[feat] Support bin-on-bin deps by transitioning binaries into libraries#762
ParaLock wants to merge 8 commits intoaspect-build:mainfrom
ParaLock:nmercaldo/bin-to-lib-transition

Conversation

@ParaLock
Copy link
Copy Markdown

@ParaLock ParaLock commented Dec 29, 2025

Our use case of rules_py would benefit from an ability for binary targets to depend on other binary targets in a manner amenable to composition of virtual environments. This PR attempts to achieve said functionality by transitioning a binary into a library if it is depended upon by another binary.


Changes are visible to end-users: no

Test plan

  • Covered by existing test cases
  • New test cases added

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 29, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ ParaLock
❌ nmercaldo-bdai
You have signed the CLA already but the status is still pending? Let us recheck it.

@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Dec 29, 2025

test-os:linux-bzl:8 (Test)

⚠️ Buildkite build #1799 failed.

//py/unstable:defs.doc_extract failed to build

in deps attribute of starlark_doc_extract rule //py/unstable:defs.doc_extract: missing bzl_library targets
for Starlark module(s) //py/private:bin_to_lib.bzl. Since this rule was created by the macro 'bzl_library',
the error might have been caused by the macro implementation

//py:defs.doc_extract failed to build

in deps attribute of starlark_doc_extract rule //py:defs.doc_extract: missing bzl_library targets for
Starlark module(s) //py/private:bin_to_lib.bzl. Since this rule was created by the macro 'bzl_library', the
error might have been caused by the macro implementation

@@+uv+whl_install__pypi__default__bravado_core//:actual_install failed to build

unpack failed: error executing Action command (from target @@+uv+whl_install__pypi__default__bravado_core//:actual_install) bazel-out/k8-opt-exec-ST-a2b2cf5b3f92/bin/py/tools/unpack_bin/unpack --into bazel-out/k8-fastbuild/bin/external/+uv+whl_install__pypi__default__bravado_core/install --wheel ... (remaining 5 arguments skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
Error:   × Unable to run command:
  ├─▶ Didn't find exactly one wheel file to install!
  ╰─▶ got zero elements when exactly one was expected

//py/tests/py-binary:run_py_test_help failed to build

bash failed: error executing Genrule command (from target //py/tests/py-binary:run_py_test_help) /bin/bash -c ... (remaining 1 argument skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
Traceback (most recent call last):
  File "/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/5707/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/+uv+venv__pypi__default/pytest/entrypoints/pytest.runfiles/+uv+venv__pypi__default/pytest/entrypoints/_pytest_entrypoint.py", line 2, in <module>
    from pytest import console_main
ImportError: cannot import name 'console_main' from 'pytest' (unknown location)
Failed tests (5)
//py/tests/py_venv_image_layer:my_app_amd64_layers_test [k8-fastbuild]                    🔗
//py/tests/py_venv_image_layer:my_app_arm64_layers_test [k8-fastbuild]                    🔗
//py/tests/py_venv_image_layer:py_amd64_image_command_test [k8-fastbuild]                 🔗
//py/tests/py_venv_image_layer:py_amd64_image_content_test [k8-fastbuild]                 🔗
//py/tests/py_venv_image_layer:py_arm64_image_content_test [k8-fastbuild]                 🔗

💡 To reproduce the build failures, run

bazel build //py/unstable:defs.doc_extract //py:defs.doc_extract @@+uv+whl_install__pypi__default__bravado_core//:actual_install //py/tests/py-binary:run_py_test_help

💡 To reproduce the test failures, run

bazel test //py/tests/py_venv_image_layer:py_amd64_image_command_test //py/tests/py_venv_image_layer:py_arm64_image_content_test //py/tests/py_venv_image_layer:my_app_arm64_layers_test //py/tests/py_venv_image_layer:py_amd64_image_content_test //py/tests/py_venv_image_layer:my_app_amd64_layers_test

test-os:linux-bzl:latest (Test)

⚠️ Buildkite build #1799 failed.

//py/unstable:defs.doc_extract failed to build

in deps attribute of starlark_doc_extract rule //py/unstable:defs.doc_extract: missing bzl_library targets
for Starlark module(s) //py/private:bin_to_lib.bzl. Since this rule was created by the macro 'bzl_library',
the error might have been caused by the macro implementation

//py:defs.doc_extract failed to build

in deps attribute of starlark_doc_extract rule //py:defs.doc_extract: missing bzl_library targets for
Starlark module(s) //py/private:bin_to_lib.bzl. Since this rule was created by the macro 'bzl_library', the
error might have been caused by the macro implementation

//py/tests/py-binary:run_py_test_help failed to build

bash failed: error executing Genrule command (from target //py/tests/py-binary:run_py_test_help) /bin/bash -c ... (remaining 1 argument skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
Traceback (most recent call last):
  File "/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/5297/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/+uv+venv__pypi__default/pytest/entrypoints/pytest.runfiles/+uv+venv__pypi__default/pytest/entrypoints/_pytest_entrypoint.py", line 2, in <module>
    from pytest import console_main
ImportError: cannot import name 'console_main' from 'pytest' (unknown location)

@@+uv+whl_install__pypi__default__bravado_core//:actual_install failed to build

unpack failed: error executing Action command (from target @@+uv+whl_install__pypi__default__bravado_core//:actual_install) bazel-out/k8-opt-exec-ST-a2b2cf5b3f92/bin/py/tools/unpack_bin/unpack --into bazel-out/k8-fastbuild/bin/external/+uv+whl_install__pypi__default__bravado_core/install --wheel ... (remaining 5 arguments skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
Error:   × Unable to run command:
  ├─▶ Didn't find exactly one wheel file to install!
  ╰─▶ got zero elements when exactly one was expected
Failed tests (5)
//py/tests/py_venv_image_layer:my_app_amd64_layers_test [k8-fastbuild]                    🔗
//py/tests/py_venv_image_layer:my_app_arm64_layers_test [k8-fastbuild]                    🔗
//py/tests/py_venv_image_layer:py_amd64_image_command_test [k8-fastbuild]                 🔗
//py/tests/py_venv_image_layer:py_amd64_image_content_test [k8-fastbuild]                 🔗
//py/tests/py_venv_image_layer:py_arm64_image_content_test [k8-fastbuild]                 🔗

💡 To reproduce the build failures, run

bazel build //py/unstable:defs.doc_extract //py:defs.doc_extract //py/tests/py-binary:run_py_test_help @@+uv+whl_install__pypi__default__bravado_core//:actual_install

💡 To reproduce the test failures, run

bazel test //py/tests/py_venv_image_layer:my_app_amd64_layers_test //py/tests/py_venv_image_layer:my_app_arm64_layers_test //py/tests/py_venv_image_layer:py_arm64_image_content_test //py/tests/py_venv_image_layer:py_amd64_image_content_test //py/tests/py_venv_image_layer:py_amd64_image_command_test

test-os:linux-bzl:8 (Test)

e2e

⚠️ Buildkite build #1799 failed.

Failed tests (2)
//cases/uv-deps-650/crossbuild:app_amd64_layers_test [k8-fastbuild]                       🔗
//cases/uv-deps-650/crossbuild:app_arm64_layers_test [k8-fastbuild]                       🔗

💡 To reproduce the test failures, run

bazel test //cases/uv-deps-650/crossbuild:app_arm64_layers_test //cases/uv-deps-650/crossbuild:app_amd64_layers_test

test-os:linux-bzl:latest (Test)

e2e

⚠️ Buildkite build #1799 failed.

Failed tests (2)
//cases/uv-deps-650/crossbuild:app_amd64_layers_test [k8-fastbuild]                       🔗
//cases/uv-deps-650/crossbuild:app_arm64_layers_test [k8-fastbuild]                       🔗

💡 To reproduce the test failures, run

bazel test //cases/uv-deps-650/crossbuild:app_amd64_layers_test //cases/uv-deps-650/crossbuild:app_arm64_layers_test

test-os:linux-bzl:8 (Test)

examples/uv_pip_compile

All tests were cache hits

1 test (100.0%) was fully cached saving 335ms.


test-os:linux-bzl:latest (Test)

examples/uv_pip_compile

All tests were cache hits

1 test (100.0%) was fully cached saving 335ms.

@arrdem arrdem closed this Mar 4, 2026
@arrdem
Copy link
Copy Markdown
Contributor

arrdem commented Mar 4, 2026

Closing -- I love this idea but as discussed at some length I think it has to be handled with a macro that's inappropriate for the core ruleset itself since we can't actually have a "binary" target that doesn't generate the declared/expected binary in some configurations.

I may circle back to this and try to take a crack at it since we've had a variety of bin-on-bin issues.

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.

4 participants