aspect-build / aspect-build/rules_py
[Bug]: py_layer_tier ignores `root`
- Dominant language
- Starlark
- Stars
- 145
- Forks
- 97
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 71
Description
### What happened?
...or I don't understand what it's supposed to do.
Given a `py_layer_tier` like:
```
py_layer_tier(
name = "my_tier",
root = "/my_favorite_dir",
)
```
I expect it to put the files in `/my_favorite_dir/my_app.runfiles`, or perhaps `/my_favorite_dir.runfiles`. I'm not sure.
Instead, it puts the files in `/app.runfiles`.
I'm seeing this on a full image build. To save time, I've done the reproduction with `py_image_layer` + checking the output tars.
### Version
Development (host) and target OS/architectures:
Tested on:
Linux x86-64 host and target
MacOS arm host and target
Output of `bazel --version`: bazel 9.2.0
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: 2.0.0-alpha.6
Language(s) and/or frameworks involved: Python
### How to reproduce
```shell
First, set up a repository containing:
MODULE.bazel:
module(
name = "no-root",
version = "0.1.0",
)
bazel_dep(name = "aspect_rules_py", version = "2.0.0-alpha.6")
BUILD.bazel:
load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_image_layer", "py_layer_tier")
py_binary(
name = "main",
srcs = ["main.py"],
deps = [],
)
py_layer_tier(
name = "my_tier",
root = "/my_favorite_dir",
)
py_image_layer(
name = "image",
binary = ":main",
layer_tier = "//:my_tier",
)
main.py:
print("Hello, world!")
Build the image layers:
bazel build //:image
Check the contents of the output tar:
tar -ztf bazel-bin/image_default.tar.gz | head
Expectation:
Something like `/my_favorite_dir/my_app.runfiles/_main/._main.venv/bin/python`
Actual result:
A list of files like:
`./app.runfiles/_main/._main.venv/bin/python`
```
### Any other information?
_No response_
Contributor guide
Research direction
Start with the py_layer_tier and py_image_layer definitions, using the BUILD.bazel reproduction and its root attribute as the entry point. Run bazel build //:image, then inspect bazel-bin/image_default.tar.gz with tar to compare the generated paths with the requested /my_favorite_dir location. Done means root affects the runfiles paths in the output tar.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100