Use pkg_files for python source tarball.

The file structure was broken only when invoking from protobuf repo (`bazel build @upb//python/dist:source_tarball`) since filegroup files have a path like `protobuf/external/upb/python/dist/setup.py` rather than `protobuf/setup.py`

This was broken by 79af13abde

PiperOrigin-RevId: 553821217
pull/13675/head^2
Sandy Zhang 1 year ago committed by Copybara-Service
parent 1b0011dfef
commit 3d0119a2dd
  1. 34
      python/dist/BUILD.bazel

@ -27,7 +27,7 @@ load("//bazel:py_proto_library.bzl", "py_proto_library")
load(":dist.bzl", "py_dist", "py_dist_module")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@com_google_protobuf//:protobuf_version.bzl", "PROTOBUF_PYTHON_VERSION")
load("@rules_pkg//:mappings.bzl", "pkg_files")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_python//python:packaging.bzl", "py_wheel")
load("@system_python//:version.bzl", "SYSTEM_PYTHON_VERSION")
@ -237,16 +237,20 @@ pkg_files(
prefix = "utf8_range",
)
# NOTE: This package currently only works for macos and ubuntu, MSVC users
# should use a binary wheel.
pkg_tar(
name = "source_tarball",
pkg_files(
name = "dist_source_files",
srcs = [
"MANIFEST.in",
"setup.py",
":generated_wkt",
":generated_wkt_compiler",
":utf8_range_source_files",
],
)
# Passing filegroups to pkg_tar directly results in incorrect
# `protobuf/external/upb/` directory structure when built from the protobuf
# repo. This can be removed once repositories are merged.
pkg_files(
name = "filegroup_source_files",
srcs = [
"//:LICENSE",
"//:source_files",
"//python:message_srcs",
@ -255,6 +259,20 @@ pkg_tar(
"//upb/mini_descriptor:source_files",
"//upb/mini_table:source_files",
"//upb/util:source_files",
],
strip_prefix = strip_prefix.from_root(""),
)
# NOTE: This package currently only works for macos and ubuntu, MSVC users
# should use a binary wheel.
pkg_tar(
name = "source_tarball",
srcs = [
":dist_source_files",
":filegroup_source_files",
":generated_wkt",
":generated_wkt_compiler",
":utf8_range_source_files",
"@com_google_protobuf//python:python_source_files",
],
extension = "tar.gz",

Loading…
Cancel
Save