Fix the TF wheel build on Windows.

PiperOrigin-RevId: 355400706
Change-Id: I28de129edc73a1ede72c1276d8e11c9737f1c220
This commit is contained in:
Meghna Natraj 2021-02-03 08:18:48 -08:00 committed by TensorFlower Gardener
parent e7ff5a82de
commit bcc6c99c90

View File

@ -379,13 +379,18 @@ def flatbuffer_py_strip_prefix_srcs(name, srcs = [], strip_prefix = ""):
)
def _concat_flatbuffer_py_srcs_impl(ctx):
# Merge all generated python files.
command = "find '%s' -name '*.py' -exec cat {} + | sed '/import flatbuffers/d'"
command += " | sed '1s/^/import flatbuffers\\'$'\\n/' > %s"
# Merge all generated python files. The files are concatenated and import
# statements are removed. Finally we import the flatbuffer runtime library.
# IMPORTANT: Our Windows shell does not support "find ... -exec" properly.
# If you're changing the commandline below, please build wheels and run smoke
# tests on all the three operating systems.
command = "echo 'import flatbuffers\n' > %s; "
command += "for f in $(find %s -name '*.py'); do cat $f | sed '/import flatbuffers/d' >> %s; done "
ctx.actions.run_shell(
inputs = ctx.attr.deps[0].files,
outputs = [ctx.outputs.out],
command = command % (
ctx.outputs.out.path,
ctx.attr.deps[0].files.to_list()[0].path,
ctx.outputs.out.path,
),