Skip to content

Commit 8d34521

Browse files
committed
Revert layering changes for now
1 parent 2cf44b4 commit 8d34521

File tree

1 file changed

+9
-41
lines changed

1 file changed

+9
-41
lines changed

py/private/py_image_layer.bzl

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,18 @@ oci_image(
3030
```
3131
"""
3232

33-
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_mutate", "mtree_spec", "tar")
33+
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
3434
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
3535

3636
default_layer_groups = {
37+
# match *only* external pip like repositories that contain the string "site-packages"
38+
"packages": "\\\\.runfiles/.*/site-packages",
3739
# match *only* external repositories that begins with the string "python"
3840
# e.g. this will match
3941
# `/hello_world/hello_world_bin.runfiles/rules_python~0.21.0~python~python3_9_aarch64-unknown-linux-gnu/bin/python3`
4042
# but not match
4143
# `/hello_world/hello_world_bin.runfiles/_main/python_app`
42-
#
43-
# Note that due to dict key insertion order sensitivity, we want this group
44-
# to go first so that the entire interpreter including its bundled libraries
45-
# goes into the same layer.
4644
"interpreter": "\\\\.runfiles/.*python.*-.*/",
47-
# match *only* external pip like repositories that contain the string "site-packages"
48-
#
49-
# Note that this comes after the interpreter so that we won't bundle
50-
# interpreter embedded libraries (setuptools, pip, site) into the same
51-
# libraries layer.
52-
"packages": "\\\\.runfiles/.*/site-packages",
5345
}
5446

5547
def _split_mtree_into_layer_groups(name, root, groups, group_names, **kwargs):
@@ -98,17 +90,7 @@ awk < $< 'BEGIN {
9890
**kwargs
9991
)
10092

101-
def py_image_layer(
102-
name,
103-
binary,
104-
root = "/",
105-
layer_groups = {},
106-
compress = "gzip",
107-
tar_args = [],
108-
compute_unused_inputs = 1,
109-
platform = None,
110-
owner = None,
111-
**kwargs):
93+
def py_image_layer(name, binary, root = "/", layer_groups = {}, compress = "gzip", tar_args = [], compute_unused_inputs = 1, platform = None, **kwargs):
11294
"""Produce a separate tar output for each layer of a python app
11395
11496
> Requires `awk` to be installed on the host machine/rbe runner.
@@ -137,7 +119,6 @@ def py_image_layer(
137119
compress: Compression algorithm to use. Default is gzip. See: https://github.com/bazel-contrib/bazel-lib/blob/main/docs/tar.md#tar_rule-compress
138120
compute_unused_inputs: Whether to compute unused inputs. Default is 1. See: https://github.com/bazel-contrib/bazel-lib/blob/main/docs/tar.md#tar_rule-compute_unused_inputs
139121
platform: The platform to use for the transition. Default is None. See: https://github.com/bazel-contrib/bazel-lib/blob/main/docs/transitions.md#platform_transition_binary-target_platform
140-
owner: An owner uid for the uncompressed files. See mtree_mutate: https://github.com/bazel-contrib/bazel-lib/blob/main/docs/tar.md#mutating-the-tar-contents
141122
tar_args: Additional arguments to pass to the tar rule. Default is `[]`. See: https://github.com/bazel-contrib/bazel-lib/blob/main/docs/tar.md#tar_rule-args
142123
**kwargs: attribute that apply to all targets expanded by the macro
143124
@@ -149,24 +130,11 @@ def py_image_layer(
149130

150131
# Produce the manifest for a tar file of our py_binary, but don't tar it up yet, so we can split
151132
# into fine-grained layers for better pull, push and remote cache performance.
152-
manifest_name = name + ".manifest"
153-
if owner:
154-
mtree_spec(
155-
name = manifest_name + ".preprocessed",
156-
srcs = [binary],
157-
**kwargs
158-
)
159-
mtree_mutate(
160-
name = manifest_name,
161-
mtree = name + ".manifest.preprocessed",
162-
owner = owner,
163-
)
164-
else:
165-
mtree_spec(
166-
name = manifest_name,
167-
srcs = [binary],
168-
**kwargs
169-
)
133+
mtree_spec(
134+
name = name + ".manifest",
135+
srcs = [binary],
136+
**kwargs
137+
)
170138

171139
groups = dict(**layer_groups)
172140
groups = dict(groups, **default_layer_groups)

0 commit comments

Comments
 (0)