diff --git a/rules_python/BUILD b/rules_python/BUILD index 6c23e01ae7..734bd3a73b 100644 --- a/rules_python/BUILD +++ b/rules_python/BUILD @@ -21,6 +21,7 @@ load("@piptool_deps//:requirements.bzl", "requirement") py_library( name = "whl", srcs = ["whl.py"], + srcs_version = "PY3ONLY", deps = [ requirement("setuptools"), ], @@ -30,8 +31,8 @@ py_test( name = "whl_test", srcs = ["whl_test.py"], data = [ - "@futures_3_1_1_whl//file", "@futures_2_2_0_whl//file", + "@futures_3_1_1_whl//file", "@google_cloud_language_whl//file", "@grpc_whl//file", "@mock_whl//file", @@ -47,6 +48,7 @@ load("@subpar//:subpar.bzl", "par_binary") par_binary( name = "piptool", srcs = ["piptool.py"], + default_python_version = "PY3", deps = [ ":whl", requirement("pip"), @@ -57,6 +59,7 @@ par_binary( par_binary( name = "whltool", srcs = ["whl.py"], + default_python_version = "PY3", main = "whl.py", deps = [ ":whl", diff --git a/rules_python/whl.py b/rules_python/whl.py index e3544d80d0..10a28e3601 100644 --- a/rules_python/whl.py +++ b/rules_python/whl.py @@ -18,6 +18,7 @@ import os import pkg_resources import re +import sys import zipfile @@ -113,7 +114,7 @@ def _parse_metadata(self, content): parser = argparse.ArgumentParser( - description='Unpack a WHL file as a py_library.') + description='Unpack a WHL file as a py_library [Python {}]'.format(sys.version)) parser.add_argument('--whl', action='store', help=('The .whl file we are expanding.')) diff --git a/tools/piptool.par b/tools/piptool.par index b7a62c5563..1211d79a17 100755 Binary files a/tools/piptool.par and b/tools/piptool.par differ diff --git a/tools/whltool.par b/tools/whltool.par index 8e2f34250d..5d68b6913c 100755 Binary files a/tools/whltool.par and b/tools/whltool.par differ diff --git a/update_tools.sh b/update_tools.sh index 5f00e9c331..28fb48d7a7 100755 --- a/update_tools.sh +++ b/update_tools.sh @@ -16,6 +16,6 @@ set -euo pipefail -bazel build //rules_python:piptool.par //rules_python:whltool.par +bazel build //rules_python:piptool.par //rules_python:whltool.par --force_python=PY3 --python_path=/usr/bin/python3 cp bazel-bin/rules_python/piptool.par tools/piptool.par cp bazel-bin/rules_python/whltool.par tools/whltool.par