Skip to content
Open
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
8 changes: 6 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ common:ci --toolchain_resolution_debug='@@bazel_tools//tools/cpp:toolchain_type'
common:release --build_tag_filters=release
common:release --stamp
common:release --compilation_mode=opt
common:release --@rules_rust//rust/settings:lto=fat
common:release --@rules_rust//:extra_rustc_flags=-Cpanic=abort

# These are reproducibility settings, but we set them globally to avoid having
# to rebuild rust libraries and C-extensions in many configurations.
common --@rules_rust//rust/settings:lto=fat
common --@rules_rust//:extra_rustc_flags=-Cstrip=debuginfo
common --stripopt=--strip-all

# Speed up local development by using the non-hermetic CPP toolchain.
common:nollvm --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
Expand Down
17 changes: 9 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions bazel/rust/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,12 @@

load("@aspect_bazel_lib//lib:expand_template.bzl", _expand_template = "expand_template")
load("@rules_rust//rust:defs.bzl", _rust_binary = "rust_binary", _rust_library = "rust_library", _rust_proc_macro = "rust_proc_macro", _rust_test = "rust_test")
load("@with_cfg.bzl", "with_cfg")

_default_platform = select({
# Non-Linux binaries should just build with their default platforms
"//conditions:default": None,
})

rust_opt_binary, _rust_opt_binary_internal = with_cfg(_rust_binary).set(
"compilation_mode",
"opt",
).set(
Label("@rules_rust//:extra_rustc_flags"),
[
"-Cstrip=symbols",
"-Ccodegen-units=1",
"-Cpanic=abort",
],
# Avoid rules_rust trying to instrument this binary
).set("collect_code_coverage", "false").build()

def rust_binary(name, rustc_env_files = [], version_key = "", crate_features = [], platform = _default_platform, **kwargs):
"""
Macro for rust_binary defaults.
Expand Down Expand Up @@ -50,7 +36,7 @@ def rust_binary(name, rustc_env_files = [], version_key = "", crate_features = [
# Note that we use symbol stripping to
# try and make these artifacts reproducibly sized for the
# container_structure tests.
rust_opt_binary(
_rust_binary(
name = name,
rustc_env_files = rustc_env_files,
crate_features = crate_features + ["bazel"],
Expand Down
6 changes: 0 additions & 6 deletions e2e/cases/uv-deps-650/crossbuild/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ platform(
flags = [
"--@aspect_rules_py//uv/private/constraints/platform:platform_libc=glibc",
"--@aspect_rules_py//uv/private/constraints/platform:platform_version=2.39",
"--@rules_rust//:extra_rustc_flag=-Cstrip=debuginfo",
"--@rules_rust//rust/settings:lto=fat",
"--stripopt=--strip-all",
],
)

Expand All @@ -28,9 +25,6 @@ platform(
flags = [
"--@aspect_rules_py//uv/private/constraints/platform:platform_libc=glibc",
"--@aspect_rules_py//uv/private/constraints/platform:platform_version=2.39",
"--@rules_rust//:extra_rustc_flag=-Cstrip=debuginfo",
"--@rules_rust//rust/settings:lto=fat",
"--stripopt=--strip-all",
],
)

Expand Down
2 changes: 1 addition & 1 deletion py/private/py_venv/entrypoint.tmpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ set -o errexit -o nounset -o pipefail

source "$(rlocation "{{VENV}}")"/bin/activate

exec "$(rlocation "{{VENV}}")"/bin/python {{INTERPRETER_FLAGS}} "$@"
exec "$(rlocation "{{VENV}}")"/bin/python3 {{INTERPRETER_FLAGS}} "$@"
2 changes: 1 addition & 1 deletion py/tests/py-venv-standalone-interpreter/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ex

ROOT="$(dirname $0)"

"$ROOT"/.ex/bin/python --help >/dev/null 2>&1
"$ROOT"/.ex/bin/python --help

if [ "Hello, world!" != "$($ROOT/.ex/bin/python -c 'from ex import hello; print(hello())')" ]; then
exit 1
Expand Down
6 changes: 0 additions & 6 deletions py/tests/py_venv_image_layer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ platform(
flags = [
"--//uv/private/constraints/platform:platform_libc=glibc",
"--//uv/private/constraints/platform:platform_version=2.39",
"--@rules_rust//:extra_rustc_flag=-Cstrip=debuginfo",
"--@rules_rust//rust/settings:lto=fat",
"--stripopt=--strip-all",
],
)

Expand All @@ -29,9 +26,6 @@ platform(
flags = [
"--//uv/private/constraints/platform:platform_libc=glibc",
"--//uv/private/constraints/platform:platform_version=2.39",
"--@rules_rust//:extra_rustc_flag=-Cstrip=debuginfo",
"--@rules_rust//rust/settings:lto=fat",
"--stripopt=--strip-all",
],
)

Expand Down
10 changes: 5 additions & 5 deletions py/tests/py_venv_image_layer/my_app_amd64_layers_listing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ files:
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/
- -rwxr-xr-x 0 0 0 1245 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin
- -rwxr-xr-x 0 0 0 1246 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/+uv+whl_install__pypi__default__colorama/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/+uv+whl_install__pypi__default__colorama/install/
Expand All @@ -2521,14 +2521,14 @@ files:
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/
- -rwxr-xr-x 0 0 0 2503 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/activate
- -rwxr-xr-x 0 0 0 799896 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python
- -rwxr-xr-x 0 0 0 799896 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
- -rwxr-xr-x 0 0 0 799896 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9
- -rwxr-xr-x 0 0 0 4342824 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python
- -rwxr-xr-x 0 0 0 4342824 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
- -rwxr-xr-x 0 0 0 4342824 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/lib/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/lib/python3.9/
- -rwxr-xr-x 0 0 0 348 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/pyvenv.cfg
- -rwxr-xr-x 0 0 0 390 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/__main__.py
- -rwxr-xr-x 0 0 0 1245 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/my_app_bin
- -rwxr-xr-x 0 0 0 1246 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/my_app_bin
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/
Expand Down
10 changes: 5 additions & 5 deletions py/tests/py_venv_image_layer/my_app_arm64_layers_listing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,7 @@ files:
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/
- -rwxr-xr-x 0 0 0 1245 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin
- -rwxr-xr-x 0 0 0 1246 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/+uv+whl_install__pypi__default__colorama/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/+uv+whl_install__pypi__default__colorama/install/
Expand All @@ -2502,14 +2502,14 @@ files:
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/
- -rwxr-xr-x 0 0 0 2503 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/activate
- -rwxr-xr-x 0 0 0 871208 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python
- -rwxr-xr-x 0 0 0 871208 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
- -rwxr-xr-x 0 0 0 871208 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9
- -rwxr-xr-x 0 0 0 4531120 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python
- -rwxr-xr-x 0 0 0 4531120 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
- -rwxr-xr-x 0 0 0 4531120 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/lib/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/lib/python3.9/
- -rwxr-xr-x 0 0 0 349 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/pyvenv.cfg
- -rwxr-xr-x 0 0 0 390 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/__main__.py
- -rwxr-xr-x 0 0 0 1245 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/my_app_bin
- -rwxr-xr-x 0 0 0 1246 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/my_app_bin
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/
Expand Down
8 changes: 8 additions & 0 deletions py/tools/venv_shim/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_rust//rust:defs.bzl", "rust_test")
load("//bazel/release:release.bzl", "release")
load("//bazel/rust:defs.bzl", "rust_binary")
load("//bazel/rust:multi_platform_rust_binaries.bzl", "multi_platform_rust_binaries")
Expand All @@ -6,14 +7,21 @@ rust_binary(
name = "shim",
srcs = [
"src/main.rs",
"src/pyargs.rs",
],
deps = [
"//py/tools/runfiles",
"@crates//:clap",
"@crates//:miette",
"@crates//:which",
],
)

rust_test(
name = "shim_tests",
crate = ":shim",
)

multi_platform_rust_binaries(
name = "bins",
target = ":shim",
Expand Down
1 change: 1 addition & 0 deletions py/tools/venv_shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ path = "src/main.rs"

[dependencies]
miette = { workspace = true }
clap = { workspace = true }
runfiles = { path = "../runfiles" }
which = "8.0.0"
Loading