generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Description
Description
Starting with version 2.9.0, mtree_spec creates items containing .. when used with rules_python on a py_binary with dependencies.
Given that it involves __init__.py files, it might have something to do with bazel-contrib/bazel-lib#939.
Steps to Reproduce
-
Set up a minimal project:
MODULE.bazelmodule(name = "test-module") bazel_dep(name = "aspect_bazel_lib", version = "2.9.0") # https://github.com/aspect-build/bazel-lib bazel_dep(name = "rules_python", version = "1.1.0") # https://github.com/bazelbuild/rules_python python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( python_version = "3.13.1", ) pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.parse( hub_name = "pypi", python_version = "3.13.1", requirements_lock = "//:requirements_lock.txt", ) use_repo(pip, "pypi")
BUILD.bazelload("@rules_python//python:pip.bzl", "compile_pip_requirements") compile_pip_requirements( name = "requirements", src = "requirements.in", requirements_txt = "requirements_lock.txt", )
requirements.inpsutiltest/BUILD.bazelload("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar") load("@rules_python//python:defs.bzl", "py_binary") py_binary( name = "test_bin", srcs = ["test_bin.py"], deps = ["@pypi//psutil:pkg"], ) mtree_spec( name = "test_bin_mtree", srcs = [":test_bin"], ) tar( name = "tar", srcs = [":test_bin"], mtree = ":test_bin_mtree", )
test/test_bin.py#!/usr/bin/env python import psutil print(psutil.Process().exe())
-
Build:
bazel --version # bazel 8.1.1 : > requirements_lock.txt && bazel run //:requirements.update bazel build //test:tar
Expectation
Paths with .. are never generated in the mtree and tar can unpack the //test:tar target.
Actual Outcome
$ cat bazel-bin/test/test_bin_mtree.spec | grep '\.\.' | grep psutil
test/test_bin.runfiles/_main/../rules_python++pip+pypi_313_psutil/__init__.py uid=0 gid=0 time=1672560000 mode=0755 type=file
$ cd bazel-bin/test
$ tar xvf tar.tar
test/
test/test_bin
test/test_bin.py
test/test_bin.runfiles/
tar: Removing leading `test/test_bin.runfiles/_main/../' from member names
tar: test/test_bin.runfiles/_main/../rules_python++pip+pypi_313_psutil/__init__.py: Member name contains '..'
tar: test/test_bin.runfiles/_main/../__init__.py: Member name contains '..'
...
tar: Exiting with failure status due to previous errors
$ echo $?
2Reactions are currently unavailable