From 84c52f245cf271683100ac76dadd96a991ec85fb Mon Sep 17 00:00:00 2001 From: AutomatedTester Date: Tue, 27 Oct 2020 13:52:29 +0000 Subject: [PATCH] [Build] Update directory check in rules_python This checks if an item is a directory and ignores it when files are being created in the python package. --- WORKSPACE | 1 + py/rules_python_any_version_wheel.patch | 69 --------------------- py/rules_python_wheel_directory_check.patch | 14 ++--- 3 files changed, 8 insertions(+), 76 deletions(-) delete mode 100644 py/rules_python_any_version_wheel.patch diff --git a/WORKSPACE b/WORKSPACE index 76868477f3628..2b98d8bf9a7aa 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -119,6 +119,7 @@ npm_install( http_archive( name = "rules_python", + patches = ["//py:rules_python_wheel_directory_check.patch"], sha256 = "4d8ed66d5f57a0b6b90e495ca8e29e5c5fa353b93f093e7c31c595a4631ff293", strip_prefix = "rules_python-5c948dcfd4ca79c2ed3a87636c46abba9f5836e9", url = "https://github.com/bazelbuild/rules_python/archive/5c948dcfd4ca79c2ed3a87636c46abba9f5836e9.zip", diff --git a/py/rules_python_any_version_wheel.patch b/py/rules_python_any_version_wheel.patch deleted file mode 100644 index 9d640cb6d7782..0000000000000 --- a/py/rules_python_any_version_wheel.patch +++ /dev/null @@ -1,69 +0,0 @@ -diff --git experimental/python/wheel.bzl experimental/python/wheel.bzl -index 9cd6534..7802d42 100644 ---- experimental/python/wheel.bzl -+++ experimental/python/wheel.bzl -@@ -85,7 +85,7 @@ def _py_wheel_impl(ctx): - outfile = ctx.actions.declare_file("-".join([ - ctx.attr.distribution, - ctx.attr.version, -- ctx.attr.python_tag, -+ ".".join(ctx.attr.python_tag), - ctx.attr.abi, - ctx.attr.platform, - ]) + ".whl") -@@ -101,7 +101,7 @@ def _py_wheel_impl(ctx): - args = ctx.actions.args() - args.add("--name", ctx.attr.distribution) - args.add("--version", ctx.attr.version) -- args.add("--python_tag", ctx.attr.python_tag) -+ args.add_all(ctx.attr.python_tag, format_each = "--python_tag=%s") - args.add("--abi", ctx.attr.abi) - args.add("--platform", ctx.attr.platform) - args.add("--out", outfile.path) -@@ -177,10 +177,9 @@ refer to the package in other packages' dependencies. - default = "any", - doc = "Supported platforms. 'any' for pure-Python wheel.", - ), -- "python_tag": attr.string( -- default = "py3", -- doc = "Supported Python major version. 'py2' or 'py3'", -- values = ["py2", "py3"], -+ "python_tag": attr.string_list( -+ default = ["py3"], -+ doc = "Supported Python major version. 'py2' and/or 'py3'", - ), - "version": attr.string( - mandatory = True, -diff --git experimental/rules_python/wheelmaker.py experimental/rules_python/wheelmaker.py -index 6be5d38..34b5cb0 100644 ---- experimental/rules_python/wheelmaker.py -+++ experimental/rules_python/wheelmaker.py -@@ -61,14 +61,14 @@ class WheelMaker(object): - components = [self._name, self._version] - if self._build_tag: - components.append(self._build_tag) -- components += [self._python_tag, self._abi, self._platform] -+ components += [".".join(self._python_tag), self._abi, self._platform] - return '-'.join(components) + '.whl' - - def distname(self): - return self._name + '-' + self._version - - def disttags(self): -- return ['-'.join([self._python_tag, self._abi, self._platform])] -+ return ['-'.join([tag, self._abi, self._platform]) for tag in self._python_tag] - - def distinfo_path(self, basename): - return self.distname() + '.dist-info/' + basename -@@ -206,7 +206,10 @@ def main(): - help="Version of the distribution") - metadata_group.add_argument('--build_tag', type=str, default='', - help="Optional build tag for the distribution") -- metadata_group.add_argument('--python_tag', type=str, default='py3', -+ metadata_group.add_argument('--python_tag', -+ type=str, -+ default=[], -+ action="append", - help="Python version, e.g. 'py2' or 'py3'") - metadata_group.add_argument('--abi', type=str, default='none') - metadata_group.add_argument('--platform', type=str, default='any', diff --git a/py/rules_python_wheel_directory_check.patch b/py/rules_python_wheel_directory_check.patch index df34227c0a8d2..603e039b46dec 100644 --- a/py/rules_python_wheel_directory_check.patch +++ b/py/rules_python_wheel_directory_check.patch @@ -1,5 +1,5 @@ diff --git experimental/examples/wheel/BUILD experimental/examples/wheel/BUILD -index 8916423..8a4aeb4 100644 +index 06371fe..eaf0709 100644 --- experimental/examples/wheel/BUILD +++ experimental/examples/wheel/BUILD @@ -31,6 +31,20 @@ py_library( @@ -36,7 +36,7 @@ index 8916423..8a4aeb4 100644 py_wheel( name = "minimal_with_py_package", # Package data. We're building "example_minimal_package-0.0.1-py3-none-any.whl" -@@ -131,6 +151,16 @@ py_wheel( +@@ -135,6 +155,16 @@ py_wheel( ], ) @@ -53,11 +53,11 @@ index 8916423..8a4aeb4 100644 py_test( name = "wheel_test", srcs = ["wheel_test.py"], -diff --git experimental/rules_python/wheelmaker.py experimental/rules_python/wheelmaker.py -index 1b3261d..1a28df2 100644 ---- experimental/rules_python/wheelmaker.py -+++ experimental/rules_python/wheelmaker.py -@@ -101,6 +101,11 @@ class WheelMaker(object): +diff --git experimental/tools/wheelmaker.py experimental/tools/wheelmaker.py +index 38fb122..4c7be30 100644 +--- experimental/tools/wheelmaker.py ++++ experimental/tools/wheelmaker.py +@@ -102,6 +102,11 @@ class WheelMaker(object): return normalized_arcname