Add python_interpreter attr to pip rules (#252)

This adds a `python_interpreter` attribute to `pip_import` and `whl_library` that can be used to select the system command used to run Python's packaging tools. This provides the basis for invoking pip under Python 3 to install PY3 dependencies.

Example usage:
```
pip_import(
    name = 'pip_deps',
    requirements = '//:requirements.txt',
    python_interpreter = 'python3.7',
)
```

The par files have been regenerated. (This required a little bootstrapping since piptool.py needs to be modified to accept the flag before pip.bzl is modified to pass it.)
diff --git a/docs/pip.md b/docs/pip.md
index 70fcd91..54aa476 100755
--- a/docs/pip.md
+++ b/docs/pip.md
@@ -5,7 +5,7 @@
 ## pip_import
 
 <pre>
-pip_import(<a href="#pip_import-name">name</a>, <a href="#pip_import-requirements">requirements</a>)
+pip_import(<a href="#pip_import-name">name</a>, <a href="#pip_import-python_interpreter">python_interpreter</a>, <a href="#pip_import-requirements">requirements</a>)
 </pre>
 
 A rule for importing `requirements.txt` dependencies into Bazel.
@@ -67,6 +67,16 @@
         </p>
       </td>
     </tr>
+    <tr id="pip_import-python_interpreter">
+      <td><code>python_interpreter</code></td>
+      <td>
+        String; optional
+        <p>
+          The command to run the Python interpreter used to invoke pip and unpack the
+wheels.
+        </p>
+      </td>
+    </tr>
     <tr id="pip_import-requirements">
       <td><code>requirements</code></td>
       <td>
diff --git a/docs/whl.md b/docs/whl.md
index e7c35c1..8aaa3c5 100755
--- a/docs/whl.md
+++ b/docs/whl.md
@@ -5,7 +5,7 @@
 ## whl_library
 
 <pre>
-whl_library(<a href="#whl_library-name">name</a>, <a href="#whl_library-extras">extras</a>, <a href="#whl_library-requirements">requirements</a>, <a href="#whl_library-whl">whl</a>)
+whl_library(<a href="#whl_library-name">name</a>, <a href="#whl_library-extras">extras</a>, <a href="#whl_library-python_interpreter">python_interpreter</a>, <a href="#whl_library-requirements">requirements</a>, <a href="#whl_library-whl">whl</a>)
 </pre>
 
 A rule for importing `.whl` dependencies into Bazel.
@@ -53,6 +53,15 @@
         </p>
       </td>
     </tr>
+    <tr id="whl_library-python_interpreter">
+      <td><code>python_interpreter</code></td>
+      <td>
+        String; optional
+        <p>
+          The command to run the Python interpreter used when unpacking the wheel.
+        </p>
+      </td>
+    </tr>
     <tr id="whl_library-requirements">
       <td><code>requirements</code></td>
       <td>
diff --git a/packaging/piptool.py b/packaging/piptool.py
index 2544032..ac78bac 100644
--- a/packaging/piptool.py
+++ b/packaging/piptool.py
@@ -86,6 +86,10 @@
 parser = argparse.ArgumentParser(
     description='Import Python dependencies into Bazel.')
 
+parser.add_argument('--python_interpreter', action='store',
+                    help=('The Python interpreter to use when extracting '
+                          'wheels.'))
+
 parser.add_argument('--name', action='store',
                     help=('The namespace of the import.'))
 
@@ -177,10 +181,12 @@
   if "{repo_name}" not in native.existing_rules():
     whl_library(
         name = "{repo_name}",
+        python_interpreter = "{python_interpreter}",
         whl = "@{name}//:{path}",
         requirements = "@{name}//:requirements.bzl",
         extras = [{extras}]
     )""".format(name=args.name, repo_name=wheel.repository_name(),
+                python_interpreter=args.python_interpreter,
                 path=wheel.basename(),
                 extras=','.join([
                   '"%s"' % extra
diff --git a/python/pip.bzl b/python/pip.bzl
index b926de3..231c723 100644
--- a/python/pip.bzl
+++ b/python/pip.bzl
@@ -24,8 +24,10 @@
 
     # To see the output, pass: quiet=False
     result = repository_ctx.execute([
-        "python",
+        repository_ctx.attr.python_interpreter,
         repository_ctx.path(repository_ctx.attr._script),
+        "--python_interpreter",
+        repository_ctx.attr.python_interpreter,
         "--name",
         repository_ctx.attr.name,
         "--input",
@@ -41,6 +43,10 @@
 
 pip_import = repository_rule(
     attrs = {
+        "python_interpreter": attr.string(default = "python", doc = """
+The command to run the Python interpreter used to invoke pip and unpack the
+wheels.
+"""),
         "requirements": attr.label(
             mandatory = True,
             allow_single_file = True,
diff --git a/python/whl.bzl b/python/whl.bzl
index 1dfa9be..d3a9f90 100644
--- a/python/whl.bzl
+++ b/python/whl.bzl
@@ -17,7 +17,7 @@
     """Core implementation of whl_library."""
 
     args = [
-        "python",
+        repository_ctx.attr.python_interpreter,
         repository_ctx.path(repository_ctx.attr._script),
         "--whl",
         repository_ctx.path(repository_ctx.attr.whl),
@@ -41,6 +41,9 @@
 A subset of the "extras" available from this <code>.whl</code> for which
 <code>requirements</code> has the dependencies.
 """),
+        "python_interpreter": attr.string(default = "python", doc = """
+The command to run the Python interpreter used when unpacking the wheel.
+"""),
         "requirements": attr.string(doc = """
 The name of the <code>pip_import</code> repository rule from which to load this
 <code>.whl</code>'s dependencies.
diff --git a/tools/piptool.par b/tools/piptool.par
index f0e0f22..d5dce0c 100755
--- a/tools/piptool.par
+++ b/tools/piptool.par
Binary files differ