bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
216 stars 174 forks source link

pkg_tar for Python puts runfiles in wrong location #715

Closed SvenKratzEasel closed 11 months ago

SvenKratzEasel commented 1 year ago

When I construct a pkg_tar rule to pull in a py_binary, e.g.

  pkg_tar (
      name = "pkg_name",
      srcs = [
          "//my/python/foo:bar",
      ],
       include_runfiles = True,
  )

Include_runfiles just dumps all files into the root directory, and doesn't create .runfiles directory for the foo:bar target, so that running bar fails because no runfiles are found.

AndrewGuenther commented 1 year ago

So from what I've found, pkg_tar will always produce a flat directory structure. I have no clue why that would be the behavior, but it is.

If you use pkg_files and then pass that to pkg_tar you get the correct directory structure...but no runfiles. However, it looks like support for an include_runfiles parameter for pkg_files was recently merged, but isn't in the latest release. So hopefully this will be fixed when that change gets a release?

But it definitely feels odd that it's just not possible to create a package out of a py_binary using rules_pkg. Feels like I might be missing something?

AndrewGuenther commented 1 year ago

I pulled in the latest release, it still mangles the runfiles structure. :disappointed:

aiuto commented 11 months ago

Duplicate of #579.