diff --git a/rules_python/whl.py b/rules_python/whl.py index 3e9d4f88fa..9073aed8c1 100644 --- a/rules_python/whl.py +++ b/rules_python/whl.py @@ -42,6 +42,13 @@ def version(self): parts = self.basename().split('-') return parts[1] + def build_tag(self): + # See https://www.python.org/dev/peps/pep-0427/#file-name-convention + parts = self.basename().split('-') + if len(parts) == 5: + return None + return parts[2] + def repository_name(self): # Returns the canonical name of the Bazel repository for this package. canonical = 'pypi__{}_{}'.format(self.distribution(), self.version()) @@ -52,7 +59,11 @@ def _dist_info(self): # Return the name of the dist-info directory within the .whl file. # e.g. google_cloud-0.27.0-py2.py3-none-any.whl -> # google_cloud-0.27.0.dist-info - return '{}-{}.dist-info'.format(self.distribution(), self.version()) + build_tag = self.build_tag() + name = '{}-{}'.format(self.distribution(), self.version()) + if build_tag is not None: + name += '-' + build_tag + return '{}.dist-info'.format(name) def metadata(self): # Extract the structured data from metadata.json in the WHL's dist-info diff --git a/tools/piptool.par b/tools/piptool.par index b105fd48ef..f52e42a6bf 100755 Binary files a/tools/piptool.par and b/tools/piptool.par differ diff --git a/tools/whltool.par b/tools/whltool.par index cab1f7d6c9..a20ed5f0c8 100755 Binary files a/tools/whltool.par and b/tools/whltool.par differ