Skip to content

Conversation

@arrdem
Copy link
Collaborator

@arrdem arrdem commented Nov 7, 2025

Python has an -E flag, which causes it to ignore PYTHONHOME and PYTHONEXECUTABLE both of which are key to how we're making the shim work.

Add a flag parser to the shim so we process the argv and strip out -E if it's set, and if -I is set we translate it to its equivalent -E and -s, and drop the -E.

Add Rust tests covering some basic cases for the parser so we aren't integration testing that.

Update Clap.

Go back to unwind rather than abort as our error handling strategy as it's required for writing tests and clap.

Fixes #703.

Changes are visible to end-users: no

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

py_venv will now unset the -E interpreter flag with which it's incompatible. -I is translated to -s.

Test plan

  • Covered by existing test cases
  • New test cases added

arrdem and others added 2 commits November 7, 2025 12:44
Python has an `-E` flag, which causes it to ignore PYTHONHOME and
PYTHONEXECUTABLE both of which are key to how we're making the shim
work.

Add a flag parser to the shim so we process the argv and strip out -E if
it's set, and if -I is set we translate it to its equivalent -E and -s,
and drop the -E.

Add Rust tests covering some basic cases for the parser so we aren't
integration testing that.

Update Clap.

Go back to unwind rather than abort as our error handling strategy as
it's required for writing tests and clap.
@aspect-workflows
Copy link

aspect-workflows bot commented Nov 7, 2025

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

⚠️ Buildkite build #981 failed.

//:gazelle_python_manifest failed to build

generator failed: error executing Action command (from target //:gazelle_python_manifest) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/uv/private/manifest/generator --whl_paths_file bazel-out/k8-fastbuild/bin/gazelle_python_manifest.args --output ... (remaining 1 argument skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/10151/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/uv/private/manifest/generator.runfiles/_main/uv/private/manifest/.generator/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/10151/execroot/_main/python': [Errno 2] No such file or directory

@@+uv+sbuild__pypi__default__bravado_core//:whl failed to build

python3 failed: error executing Action command (from target @@+uv+sbuild__pypi__default__bravado_core//:whl) bazel-out/k8-fastbuild-ST-fd81cbb45820/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3 uv/private/sdist_build/build_helper.py ... (remaining 2 arguments skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
/mnt/ephemeral/output/rules_py/__main__/execroot/_main/bazel-out/k8-fastbuild-ST-fd81cbb45820/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/10113/execroot/_main/python': [Errno 2] No such file or directory
python3 failed: error executing Action command (from target @@+uv+sbuild__pypi__default__bravado_core//:whl) bazel-out/k8-fastbuild/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3 uv/private/sdist_build/build_helper.py ... (remaining 2 arguments skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
/mnt/ephemeral/output/rules_py/__main__/execroot/_main/bazel-out/k8-fastbuild/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/10117/execroot/_main/python': [Errno 2] No such file or directory

//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
 
/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/10126/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/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/10126/execroot/_main/python': [Errno 2] No such file or directory
Failed tests (8)
//py/private/py_venv:test_link [k8-fastbuild]                                             🔗
//py/tests/py-internal-venv:test [k8-fastbuild]                                           🔗
//py/tests/py-venv-disable-systemsite:test [k8-fastbuild]                                 🔗
//py/tests/py-venv-disable-usersite:test [k8-fastbuild]                                   🔗
//py/tests/py-venv-enable-site:test [k8-fastbuild]                                        🔗
//py/tests/py-venv-standalone-interpreter:test [k8-fastbuild]                             🔗
//py/tests/py_venv_conflict:validate_import_roots [k8-fastbuild]                          🔗
//py/tests/py_venv_image_layer:py_amd64_image_command_test [k8-fastbuild]                 🔗

💡 To reproduce the build failures, run

bazel build //:gazelle_python_manifest @@+uv+sbuild__pypi__default__bravado_core//:whl @@+uv+sbuild__pypi__default__bravado_core//:whl //py/tests/py-binary:run_py_test_help

💡 To reproduce the test failures, run

bazel test //py/tests/py-venv-enable-site:test //py/tests/py-venv-disable-systemsite:test //py/tests/py-venv-standalone-interpreter:test //py/tests/py_venv_conflict:validate_import_roots //py/tests/py-internal-venv:test //py/private/py_venv:test_link //py/tests/py-venv-disable-usersite:test //py/tests/py_venv_image_layer:py_amd64_image_command_test

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

⚠️ Buildkite build #981 failed.

//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
 
/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/4194/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/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/4194/execroot/_main/python': [Errno 2] No such file or directory

@@+uv+sbuild__pypi__default__bravado_core//:whl failed to build

python3 failed: error executing Action command (from target @@+uv+sbuild__pypi__default__bravado_core//:whl) bazel-out/k8-fastbuild-ST-fd81cbb45820/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3 uv/private/sdist_build/build_helper.py ... (remaining 2 arguments skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
/mnt/ephemeral/output/rules_py/__main__/execroot/_main/bazel-out/k8-fastbuild-ST-fd81cbb45820/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/3843/execroot/_main/python': [Errno 2] No such file or directory
python3 failed: error executing Action command (from target @@+uv+sbuild__pypi__default__bravado_core//:whl) bazel-out/k8-fastbuild/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3 uv/private/sdist_build/build_helper.py ... (remaining 2 arguments skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
/mnt/ephemeral/output/rules_py/__main__/execroot/_main/bazel-out/k8-fastbuild/bin/external/+uv+sbuild__pypi__default__bravado_core/.build_venv/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/4076/execroot/_main/python': [Errno 2] No such file or directory

//:gazelle_python_manifest failed to build

generator failed: error executing Action command (from target //:gazelle_python_manifest) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/uv/private/manifest/generator --whl_paths_file bazel-out/k8-fastbuild/bin/gazelle_python_manifest.args --output ... (remaining 1 argument skipped)
 
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
 
/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/4068/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/uv/private/manifest/generator.runfiles/_main/uv/private/manifest/.generator/bin/python3: can't open file '/mnt/ephemeral/output/rules_py/__main__/sandbox/linux-sandbox/4068/execroot/_main/python': [Errno 2] No such file or directory
Failed tests (8)
//py/private/py_venv:test_link [k8-fastbuild]                                             🔗
//py/tests/py-internal-venv:test [k8-fastbuild]                                           🔗
//py/tests/py-venv-disable-systemsite:test [k8-fastbuild]                                 🔗
//py/tests/py-venv-disable-usersite:test [k8-fastbuild]                                   🔗
//py/tests/py-venv-enable-site:test [k8-fastbuild]                                        🔗
//py/tests/py-venv-standalone-interpreter:test [k8-fastbuild]                             🔗
//py/tests/py_venv_conflict:validate_import_roots [k8-fastbuild]                          🔗
//py/tests/py_venv_image_layer:py_amd64_image_command_test [k8-fastbuild]                 🔗

💡 To reproduce the build failures, run

bazel build //py/tests/py-binary:run_py_test_help @@+uv+sbuild__pypi__default__bravado_core//:whl //:gazelle_python_manifest @@+uv+sbuild__pypi__default__bravado_core//:whl

💡 To reproduce the test failures, run

bazel test //py/tests/py_venv_image_layer:py_amd64_image_command_test //py/tests/py-venv-disable-usersite:test //py/tests/py-venv-enable-site:test //py/tests/py-venv-standalone-interpreter:test //py/tests/py-internal-venv:test //py/tests/py-venv-disable-systemsite:test //py/private/py_venv:test_link //py/tests/py_venv_conflict:validate_import_roots

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

e2e

⚠️ Buildkite build #981 failed.

Failed tests (8)
//cases/cross-repo-610:test [k8-fastbuild]                                                🔗
//cases/interpreter-version-541:test_3_10_venv [k8-fastbuild-ST-0d3860f234bd]             🔗
//cases/interpreter-version-541:test_3_11_venv [k8-fastbuild]                             🔗
//cases/interpreter-version-541:test_3_9_venv [k8-fastbuild-ST-1311592336af]              🔗
//cases/uv-deps-650/airflow:airflow [k8-fastbuild-ST-ba1312b31f78]                        🔗
//cases/uv-deps-650/crossbuild:app_amd64_layers_test [k8-fastbuild]                       🔗
//cases/uv-deps-650/crossbuild:app_arm64_layers_test [k8-fastbuild]                       🔗
//cases/uv-deps-650/say:say [k8-fastbuild-ST-934aa07688c9]                                🔗

💡 To reproduce the test failures, run

bazel test //cases/interpreter-version-541:test_3_11_venv //cases/uv-deps-650/say:say //cases/interpreter-version-541:test_3_9_venv //cases/cross-repo-610:test //cases/uv-deps-650/crossbuild:app_amd64_layers_test //cases/uv-deps-650/crossbuild:app_arm64_layers_test //cases/uv-deps-650/airflow:airflow //cases/interpreter-version-541:test_3_10_venv

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

e2e

⚠️ Buildkite build #981 failed.

Failed tests (8)
//cases/cross-repo-610:test [k8-fastbuild]                                                🔗
//cases/interpreter-version-541:test_3_10_venv [k8-fastbuild-ST-0d3860f234bd]             🔗
//cases/interpreter-version-541:test_3_11_venv [k8-fastbuild]                             🔗
//cases/interpreter-version-541:test_3_9_venv [k8-fastbuild-ST-1311592336af]              🔗
//cases/uv-deps-650/airflow:airflow [k8-fastbuild-ST-ba1312b31f78]                        🔗
//cases/uv-deps-650/crossbuild:app_amd64_layers_test [k8-fastbuild]                       🔗
//cases/uv-deps-650/crossbuild:app_arm64_layers_test [k8-fastbuild]                       🔗
//cases/uv-deps-650/say:say [k8-fastbuild-ST-934aa07688c9]                                🔗

💡 To reproduce the test failures, run

bazel test //cases/uv-deps-650/crossbuild:app_amd64_layers_test //cases/cross-repo-610:test //cases/interpreter-version-541:test_3_11_venv //cases/interpreter-version-541:test_3_10_venv //cases/uv-deps-650/airflow:airflow //cases/interpreter-version-541:test_3_9_venv //cases/uv-deps-650/say:say //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.

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.

[Bug]: ModuleNotFoundError: No module named 'encodings'

3 participants