Deleted legacy pip_import rule (#582)
diff --git a/.bazelrc b/.bazelrc
index 8c931b7..f06d343 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -3,8 +3,8 @@
# This lets us glob() up all the files inside the examples to make them inputs to tests
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
# To update these lines, run tools/bazel_integration_test/update_deleted_packages.sh
-build --deleted_packages=examples/build_file_generation,examples/legacy_pip_import/boto,examples/legacy_pip_import/extras,examples/legacy_pip_import/helloworld,examples/pip_install,examples/pip_parse,examples/py_import,examples/relative_requirements
-query --deleted_packages=examples/build_file_generation,examples/legacy_pip_import/boto,examples/legacy_pip_import/extras,examples/legacy_pip_import/helloworld,examples/pip_install,examples/pip_parse,examples/py_import,examples/relative_requirements
+build --deleted_packages=examples/build_file_generation,examples/pip_install,examples/pip_parse,examples/py_import,examples/relative_requirements
+query --deleted_packages=examples/build_file_generation,examples/pip_install,examples/pip_parse,examples/py_import,examples/relative_requirements
test --test_output=errors
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index f165903..38e0658 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -2,7 +2,6 @@
Please check if your PR fulfills the following requirements:
-- [ ] Does not include precompiled binaries, eg. `.par` files. See [CONTRIBUTING.md](https://github.com/bazelbuild/rules_python/blob/master/CONTRIBUTING.md) for info
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
diff --git a/.gitignore b/.gitignore
index 3099b78..9df0fb8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,7 @@
/bazel-genfiles
/bazel-out
/bazel-testlogs
+user.bazelrc
# vim swap files
*.swp
@@ -45,4 +46,4 @@
# Go/Gazelle files
# These otherwise match patterns above
!go.mod
-!BUILD.out
\ No newline at end of file
+!BUILD.out
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 676b60f..da4b625 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -52,28 +52,6 @@
This needs to be done whenever the docstrings in the corresponding .bzl files
are changed; a test failure will remind you to run this command when needed.
-### Precompiled tools
-
-The packaging rules depend on two precompiled binaries, `tools/piptool.par` and
-`tools/whltool.par`. We need these to be precompiled because they are invoked
-during `WORKSPACE` evaluation, before Bazel itself is able to build anything
-from source. The .par files can be regenerated by running this script in the
-repository root:
-
-```shell
-# You can pass --nodocker if Docker is not available on your system.
-./update_tools.sh
-```
-
-This needs to be done whenever the corresponding sources in the `packaging/`
-directory are updated.
-
-Since these are binary files and therefore unreviewable, for security
-reasons<sup>1</sup> we will regenerate the .par files for you when merging your
-pull request.
-
-<sup>1</sup> See "[Reflections on Trusting Trust](https://en.wikipedia.org/wiki/Backdoor_(computing)#Compiler_backdoors)".
-
## Core rules
The bulk of this repo is owned and maintained by the Bazel Python community.
diff --git a/README.md b/README.md
index a35ef7a..0557e85 100644
--- a/README.md
+++ b/README.md
@@ -154,27 +154,6 @@
install_deps()
```
-### Importing `pip` dependencies with `pip_import` (legacy)
-
-The deprecated `pip_import` can still be used if needed. It is the only packaging rule that supports Python 2,
-which has been [sunsetted since January 1st, 2020](https://www.python.org/doc/sunset-python-2/).
-
-```
-load("@rules_python//python/legacy_pip_import:pip.bzl", "pip_import", "pip_repositories")
-
-# Create a central repo that knows about the dependencies needed for requirements.txt.
-pip_import(
- name = "my_deps",
- requirements = "//path/to:requirements.txt",
-)
-
-# Load the central repo's install function from its `//:requirements.bzl` file, and call it.
-load("@my_deps//:requirements.bzl", "pip_install")
-pip_install()
-```
-
-An example can be found in [`examples/legacy_pip_import`](examples/legacy_pip_import).
-
### Consuming `pip` dependencies
Each extracted wheel repo contains a `py_library` target representing the
diff --git a/docs/pip.md b/docs/pip.md
index de8d1db..ce865a6 100644
--- a/docs/pip.md
+++ b/docs/pip.md
@@ -35,24 +35,6 @@
| kwargs | other bazel attributes passed to the "_test" rule | none |
-<a name="#pip_import"></a>
-
-## pip_import
-
-<pre>
-pip_import(<a href="#pip_import-kwargs">kwargs</a>)
-</pre>
-
- Rule for installing packages listed in a requirements file.
-
-**PARAMETERS**
-
-
-| Name | Description | Default Value |
-| :-------------: | :-------------: | :-------------: |
-| kwargs | <p align="center"> - </p> | none |
-
-
<a name="#pip_install"></a>
## pip_install
diff --git a/examples/BUILD b/examples/BUILD
index 826f87c..8188ca7 100644
--- a/examples/BUILD
+++ b/examples/BUILD
@@ -18,11 +18,6 @@
licenses(["notice"]) # Apache 2.0
bazel_integration_test(
- name = "legacy_pip_import_example",
- timeout = "long",
-)
-
-bazel_integration_test(
name = "pip_install_example",
timeout = "long",
)
diff --git a/examples/legacy_pip_import/.bazelrc b/examples/legacy_pip_import/.bazelrc
deleted file mode 100644
index 0dca511..0000000
--- a/examples/legacy_pip_import/.bazelrc
+++ /dev/null
@@ -1,2 +0,0 @@
-# Watch Bazel run, and only run one at a time
-test --test_output=streamed
diff --git a/examples/legacy_pip_import/README.md b/examples/legacy_pip_import/README.md
deleted file mode 100644
index a474a01..0000000
--- a/examples/legacy_pip_import/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# LEGACY pip example
-
-This feature has been replaced by the pip_install rule, please see the rules_python 0.1 release notes to migrate.
-
-This shows how you can point Bazel at your requirements.txt file to get dependencies automatically installed.
-
-It also shows how a monorepo might have multiple python packages which each have a separate requirements.txt file.
diff --git a/examples/legacy_pip_import/WORKSPACE b/examples/legacy_pip_import/WORKSPACE
deleted file mode 100644
index 784fbdb..0000000
--- a/examples/legacy_pip_import/WORKSPACE
+++ /dev/null
@@ -1,31 +0,0 @@
-workspace(name = "pip_example")
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-http_archive(
- name = "rules_python",
- sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
- url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
-)
-
-load("@rules_python//python/legacy_pip_import:pip.bzl", "pip_import", "pip_repositories")
-
-pip_repositories()
-
-pip_import(
- name = "boto_deps",
- requirements = "//boto:requirements.txt",
-)
-
-load("@boto_deps//:requirements.bzl", _boto_install = "pip_install")
-
-_boto_install()
-
-pip_import(
- name = "extras_deps",
- requirements = "//extras:requirements.txt",
-)
-
-load("@extras_deps//:requirements.bzl", _extras_install = "pip_install")
-
-_extras_install()
diff --git a/examples/legacy_pip_import/boto/BUILD b/examples/legacy_pip_import/boto/BUILD
deleted file mode 100644
index 7bd91d9..0000000
--- a/examples/legacy_pip_import/boto/BUILD
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-load("@boto_deps//:requirements.bzl", "requirement")
-load("@rules_python//python:defs.bzl", "py_test")
-
-package(default_visibility = ["//visibility:public"])
-
-licenses(["notice"]) # Apache 2.0
-
-py_test(
- name = "boto_test",
- srcs = ["boto_test.py"],
- python_version = "PY2",
- deps = [
- requirement("boto3"),
- requirement("pip"),
- # six is a transitive dependency via python-dateutil. Explicitly depend
- # on it to work around issue #70; see issue #98.
- requirement("six"),
- ],
-)
diff --git a/examples/legacy_pip_import/boto/boto_test.py b/examples/legacy_pip_import/boto/boto_test.py
deleted file mode 100644
index 9ee16f4..0000000
--- a/examples/legacy_pip_import/boto/boto_test.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import boto3
-import pip
-import unittest
-
-
-class BotoTest(unittest.TestCase):
-
- def test_version(self):
- # Just the minimal assertion that the boto3 import worked
- self.assertEqual(boto3.__version__, '1.4.7')
- # Regression test that the pip version is the one requested
- # see https://github.com/bazelbuild/rules_python/pull/1#discussion_r138349892
- self.assertEqual(pip.__version__, '9.0.3')
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/examples/legacy_pip_import/boto/requirements.txt b/examples/legacy_pip_import/boto/requirements.txt
deleted file mode 100644
index 8cdea9c..0000000
--- a/examples/legacy_pip_import/boto/requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-boto3==1.4.7
-# Release 0.15 appears to have a broken wheel.
-# See https://github.com/bazelbuild/rules_python/issues/205.
-docutils!=0.15.post1
-pip==9.0.3
diff --git a/examples/legacy_pip_import/extras/BUILD b/examples/legacy_pip_import/extras/BUILD
deleted file mode 100644
index a961b4d..0000000
--- a/examples/legacy_pip_import/extras/BUILD
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-load("@extras_deps//:requirements.bzl", "requirement")
-load("@rules_python//python:defs.bzl", "py_test")
-
-package(default_visibility = ["//visibility:public"])
-
-licenses(["notice"]) # Apache 2.0
-
-py_test(
- name = "extras_test",
- srcs = ["extras_test.py"],
- python_version = "PY2",
- deps = [
- requirement("google-cloud-language"),
- # Make sure that we can resolve the "extra" dependency
- requirement("googleapis-common-protos[grpc]"),
- ],
-)
diff --git a/examples/legacy_pip_import/extras/extras_test.py b/examples/legacy_pip_import/extras/extras_test.py
deleted file mode 100644
index 3ad249d..0000000
--- a/examples/legacy_pip_import/extras/extras_test.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import unittest
-
-
-# The test is the build itself, which should not work if extras are missing.
-class ExtrasTest(unittest.TestCase):
- def test_nothing(self):
- pass
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/examples/legacy_pip_import/extras/requirements.txt b/examples/legacy_pip_import/extras/requirements.txt
deleted file mode 100644
index 49b86eb..0000000
--- a/examples/legacy_pip_import/extras/requirements.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-google-cloud-language==0.27.0
-googleapis-common-protos==1.51.0
diff --git a/examples/legacy_pip_import/extras/version_test.py b/examples/legacy_pip_import/extras/version_test.py
deleted file mode 100644
index 084a595..0000000
--- a/examples/legacy_pip_import/extras/version_test.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import pip
-import unittest
-
-
-class VersionTest(unittest.TestCase):
-
- def test_version(self):
- self.assertEqual(pip.__version__, '9.0.3')
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/examples/pip_install/.bazelrc b/examples/pip_install/.bazelrc
index b98fc09..9e7ef37 100644
--- a/examples/pip_install/.bazelrc
+++ b/examples/pip_install/.bazelrc
@@ -1 +1,2 @@
-test --test_output=errors
+# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
+try-import %workspace%/user.bazelrc
diff --git a/examples/pip_parse/.bazelrc b/examples/pip_parse/.bazelrc
new file mode 100644
index 0000000..9e7ef37
--- /dev/null
+++ b/examples/pip_parse/.bazelrc
@@ -0,0 +1,2 @@
+# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
+try-import %workspace%/user.bazelrc
diff --git a/internal_deps.bzl b/internal_deps.bzl
index e3910a9..a44e0de 100644
--- a/internal_deps.bzl
+++ b/internal_deps.bzl
@@ -1,9 +1,7 @@
"""Dependencies that are needed for rules_python tests and tools."""
-load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
-load("@rules_python//python/legacy_pip_import:pip.bzl", "pip_import")
def rules_python_internal_deps():
"""Fetches all required dependencies for rules_python tests and tools."""
@@ -121,21 +119,6 @@
)
maybe(
- git_repository,
- name = "subpar",
- remote = "https://github.com/google/subpar",
- # tag = "2.0.0",
- commit = "35bb9f0092f71ea56b742a520602da9b3638a24f",
- shallow_since = "1557863961 -0400",
- )
-
- maybe(
- pip_import,
- name = "piptool_deps",
- requirements = "@rules_python//python:requirements.txt",
- )
-
- maybe(
http_archive,
name = "build_bazel_integration_testing",
urls = [
diff --git a/internal_setup.bzl b/internal_setup.bzl
index 9523f75..63385c9 100644
--- a/internal_setup.bzl
+++ b/internal_setup.bzl
@@ -3,12 +3,6 @@
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@build_bazel_integration_testing//tools:repositories.bzl", "bazel_binaries")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
-
-# Requirements for building our piptool.
-load(
- "@piptool_deps//:requirements.bzl",
- _piptool_install = "pip_install",
-)
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//gazelle:deps.bzl", _go_repositories = "gazelle_deps")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
@@ -16,9 +10,6 @@
def rules_python_internal_setup():
"""Setup for rules_python tests and tools."""
- # Requirements for building our piptool.
- _piptool_install()
-
# Because we don't use the pip_install rule, we have to call this to fetch its deps
pip_install_dependencies()
diff --git a/packaging/BUILD b/packaging/BUILD
deleted file mode 100644
index 237e0ba..0000000
--- a/packaging/BUILD
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-load("@piptool_deps//:requirements.bzl", "requirement")
-load("@subpar//:subpar.bzl", "par_binary")
-load("//python:defs.bzl", "py_library", "py_test")
-
-licenses(["notice"]) # Apache 2.0
-
-py_library(
- name = "whl",
- srcs = ["whl.py"],
- deps = [
- requirement("setuptools"),
- ],
-)
-
-py_test(
- name = "whl_test",
- srcs = ["whl_test.py"],
- data = [
- "@futures_2_2_0_whl//file",
- "@futures_3_1_1_whl//file",
- "@google_cloud_language_whl//file",
- "@grpc_whl//file",
- "@mock_whl//file",
- ],
- deps = [
- ":whl",
- requirement("mock"),
- ],
-)
-
-par_binary(
- name = "piptool",
- srcs = ["piptool.py"],
- deps = [
- ":whl",
- requirement("pip"),
- requirement("wheel"),
- ],
-)
-
-par_binary(
- name = "whltool",
- srcs = ["whl.py"],
- main = "whl.py",
- deps = [
- ":whl",
- ],
-)
diff --git a/packaging/piptool.py b/packaging/piptool.py
deleted file mode 100644
index 9eab1cd..0000000
--- a/packaging/piptool.py
+++ /dev/null
@@ -1,248 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""The piptool module imports pip requirements into Bazel rules."""
-
-import argparse
-import atexit
-import json
-import os
-import pkgutil
-import pkg_resources
-import re
-import shutil
-import sys
-import tempfile
-import zipfile
-
-# Note: We carefully import the following modules in a particular
-# order, since these modules modify the import path and machinery.
-import pkg_resources
-
-
-def extract_packages(package_names):
- """Extract zipfile contents to disk and add to import path"""
-
- # Set a safe extraction dir
- extraction_tmpdir = tempfile.mkdtemp()
- atexit.register(lambda: shutil.rmtree(
- extraction_tmpdir, ignore_errors=True))
- pkg_resources.set_extraction_path(extraction_tmpdir)
-
- # Extract each package to disk
- dirs_to_add = []
- for package_name in package_names:
- req = pkg_resources.Requirement.parse(package_name)
- extraction_dir = pkg_resources.resource_filename(req, '')
- dirs_to_add.append(extraction_dir)
-
- # Add extracted directories to import path ahead of their zip file
- # counterparts.
- sys.path[0:0] = dirs_to_add
- existing_pythonpath = os.environ.get('PYTHONPATH')
- if existing_pythonpath:
- dirs_to_add.extend(existing_pythonpath.split(':'))
- os.environ['PYTHONPATH'] = ':'.join(dirs_to_add)
-
-
-# Wheel, pip, and setuptools are much happier running from actual
-# files on disk, rather than entries in a zipfile. Extract zipfile
-# contents, add those contents to the path, then import them.
-extract_packages(['pip', 'setuptools', 'wheel'])
-
-# Defeat pip's attempt to mangle sys.path
-saved_sys_path = sys.path
-sys.path = sys.path[:]
-import pip
-sys.path = saved_sys_path
-
-import setuptools
-import wheel
-
-
-def pip_main(argv):
- # Extract the certificates from the PAR following the example of get-pip.py
- # https://github.com/pypa/get-pip/blob/430ba37776ae2ad89/template.py#L164-L168
- cert_tmpdir = tempfile.mkdtemp()
- cert_path = os.path.join(cert_tmpdir, "cacert.pem")
- atexit.register(lambda: shutil.rmtree(cert_tmpdir, ignore_errors=True))
- with open(cert_path, "wb") as cert:
- cert.write(pkgutil.get_data("pip._vendor.requests", "cacert.pem"))
- argv = ["--isolated", "--disable-pip-version-check", "--cert", cert_path] + argv
- return pip.main(argv)
-
-from packaging.whl import Wheel
-
-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.'))
-
-parser.add_argument('--input', action='store',
- help=('The requirements.txt file to import.'))
-
-parser.add_argument('--output', action='store',
- help=('The requirements.bzl file to export.'))
-
-parser.add_argument('--directory', action='store',
- help=('The directory into which to put .whl files.'))
-
-parser.add_argument('--extra_pip_args', action='store',
- help=('Extra arguments to pass down to pip.'))
-
-def sort_wheels(whls):
- """Sorts a list of wheels deterministically."""
- return sorted(whls, key=lambda w: w.distribution() + '_' + w.version())
-
-def determine_possible_extras(whls):
- """Determines the list of possible "extras" for each .whl
-
- The possibility of an extra is determined by looking at its
- additional requirements, and determinine whether they are
- satisfied by the complete list of available wheels.
-
- Args:
- whls: a list of Wheel objects
-
- Returns:
- a dict that is keyed by the Wheel objects in whls, and whose
- values are lists of possible extras.
- """
- whl_map = {
- whl.distribution(): whl
- for whl in whls
- }
-
- # TODO(mattmoor): Consider memoizing if this recursion ever becomes
- # expensive enough to warrant it.
- def is_possible(distro, extra):
- distro = distro.replace("-", "_")
- # If we don't have the .whl at all, then this isn't possible.
- if distro not in whl_map:
- return False
- whl = whl_map[distro]
- # If we have the .whl, and we don't need anything extra then
- # we can satisfy this dependency.
- if not extra:
- return True
- # If we do need something extra, then check the extra's
- # dependencies to make sure they are fully satisfied.
- for extra_dep in whl.dependencies(extra=extra):
- req = pkg_resources.Requirement.parse(extra_dep)
- # Check that the dep and any extras are all possible.
- if not is_possible(req.project_name, None):
- return False
- for e in req.extras:
- if not is_possible(req.project_name, e):
- return False
- # If all of the dependencies of the extra are satisfiable then
- # it is possible to construct this dependency.
- return True
-
- return {
- whl: [
- extra
- for extra in sorted(whl.extras())
- if is_possible(whl.distribution(), extra)
- ]
- for whl in whls
- }
-
-def main():
- args = parser.parse_args()
-
- # https://github.com/pypa/pip/blob/9.0.1/pip/__init__.py#L209
- pip_args = ["wheel", "-w", args.directory, "-r", args.input]
- if args.extra_pip_args:
- pip_args += args.extra_pip_args.strip("\"").split()
- if pip_main(pip_args):
- sys.exit(1)
-
- # Enumerate the .whl files we downloaded.
- def list_whls():
- dir = args.directory + '/'
- for root, unused_dirnames, filenames in os.walk(dir):
- for fname in filenames:
- if fname.endswith('.whl'):
- yield os.path.join(root, fname)
-
- whls = sort_wheels(Wheel(path) for path in list_whls())
- possible_extras = determine_possible_extras(whls)
-
- def repository_name(wheel):
- return args.name + "_" + wheel.repository_suffix()
-
- def whl_library(wheel):
- # Indentation here matters. whl_library must be within the scope
- # of the function below. We also avoid reimporting an existing WHL.
- return """
- 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=repository_name(wheel),
- python_interpreter=args.python_interpreter,
- path=wheel.basename(),
- extras=','.join([
- '"%s"' % extra
- for extra in possible_extras.get(wheel, [])
- ]))
-
- whl_targets = ','.join([
- ','.join([
- '"%s": "@%s//:pkg"' % (whl.distribution().lower(), repository_name(whl))
- ] + [
- # For every extra that is possible from this requirements.txt
- '"%s[%s]": "@%s//:%s"' % (whl.distribution().lower(), extra.lower(),
- repository_name(whl), extra)
- for extra in possible_extras.get(whl, [])
- ])
- for whl in whls
- ])
-
- with open(args.output, 'w') as f:
- f.write("""\
-# Install pip requirements.
-#
-# Generated from {input}
-
-load("@rules_python//python:whl.bzl", "whl_library")
-
-def pip_install():
- {whl_libraries}
-
-_requirements = {{
- {mappings}
-}}
-
-all_requirements = _requirements.values()
-
-def requirement(name):
- name_key = name.replace("-", "_").lower()
- if name_key not in _requirements:
- fail("Could not find pip-provided dependency: '%s'" % name)
- return _requirements[name_key]
-""".format(input=args.input,
- whl_libraries='\n'.join(map(whl_library, whls)) if whls else "pass",
- mappings=whl_targets))
-
-if __name__ == '__main__':
- main()
diff --git a/packaging/whl.py b/packaging/whl.py
deleted file mode 100644
index f30575a..0000000
--- a/packaging/whl.py
+++ /dev/null
@@ -1,215 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""The whl modules defines classes for interacting with Python packages."""
-
-import argparse
-import json
-import os
-import pkg_resources
-import re
-import stat
-import zipfile
-
-
-def current_umask():
- """Get the current umask which involves having to set it temporarily."""
- mask = os.umask(0)
- os.umask(mask)
- return mask
-
-
-def set_extracted_file_to_default_mode_plus_executable(path):
- """
- Make file present at path have execute for user/group/world
- (chmod +x) is no-op on windows per python docs
- """
- os.chmod(path, (0o777 & ~current_umask() | 0o111))
-
-
-class Wheel(object):
-
- def __init__(self, path):
- self._path = path
-
- def path(self):
- return self._path
-
- def basename(self):
- return os.path.basename(self.path())
-
- def distribution(self):
- # See https://www.python.org/dev/peps/pep-0427/#file-name-convention
- parts = self.basename().split('-')
- return parts[0]
-
- def version(self):
- # See https://www.python.org/dev/peps/pep-0427/#file-name-convention
- parts = self.basename().split('-')
- return parts[1]
-
- def repository_suffix(self):
- # Returns a canonical suffix that will form part of the name of the Bazel
- # repository for this package.
- canonical = 'pypi__{}_{}'.format(self.distribution(), self.version())
- # Escape any illegal characters with underscore.
- return re.sub('[-.+]', '_', canonical)
-
- 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())
-
- def metadata(self):
- # Extract the structured data from metadata.json in the WHL's dist-info
- # directory.
- with zipfile.ZipFile(self.path(), 'r') as whl:
- # first check for metadata.json
- try:
- with whl.open(self._dist_info() + '/metadata.json') as f:
- return json.loads(f.read().decode("utf-8"))
- except KeyError:
- pass
- # fall back to METADATA file (https://www.python.org/dev/peps/pep-0427/)
- with whl.open(self._dist_info() + '/METADATA') as f:
- return self._parse_metadata(f.read().decode("utf-8"))
-
- def name(self):
- return self.metadata().get('name')
-
- def dependencies(self, extra=None):
- """Access the dependencies of this Wheel.
-
- Args:
- extra: if specified, include the additional dependencies
- of the named "extra".
-
- Yields:
- the names of requirements from the metadata.json, in lexical order.
- """
- # TODO(mattmoor): Is there a schema to follow for this?
- dependency_set = set()
-
- run_requires = self.metadata().get('run_requires', [])
- for requirement in run_requires:
- if requirement.get('extra') != extra:
- # Match the requirements for the extra we're looking for.
- continue
- marker = requirement.get('environment')
- if marker and not pkg_resources.evaluate_marker(marker):
- # The current environment does not match the provided PEP 508 marker,
- # so ignore this requirement.
- continue
- requires = requirement.get('requires', [])
- for entry in requires:
- # Strip off any trailing versioning data.
- parts = re.split('[ ><=()]', entry)
- dependency_set.add(parts[0])
-
- return sorted(dependency_set)
-
- def extras(self):
- return self.metadata().get('extras', [])
-
- def expand(self, directory):
- with zipfile.ZipFile(self.path(), "r", allowZip64=True) as whl:
- whl.extractall(directory)
- # The following logic is borrowed from Pip:
- # https://github.com/pypa/pip/blob/cc48c07b64f338ac5e347d90f6cb4efc22ed0d0b/src/pip/_internal/utils/unpacking.py#L240
- for info in whl.infolist():
- name = info.filename
- # Do not attempt to modify directories.
- if name.endswith("/") or name.endswith("\\"):
- continue
- mode = info.external_attr >> 16
- # if mode and regular file and any execute permissions for
- # user/group/world?
- if mode and stat.S_ISREG(mode) and mode & 0o111:
- name = os.path.join(directory, name)
- set_extracted_file_to_default_mode_plus_executable(name)
-
- # _parse_metadata parses METADATA files according to https://www.python.org/dev/peps/pep-0314/
- def _parse_metadata(self, content):
- # TODO: handle fields other than just name
- name_pattern = re.compile('Name: (.*)')
- return { 'name': name_pattern.search(content).group(1) }
-
-
-parser = argparse.ArgumentParser(
- description='Unpack a WHL file as a py_library.')
-
-parser.add_argument('--whl', action='store',
- help=('The .whl file we are expanding.'))
-
-parser.add_argument('--requirements', action='store',
- help='The pip_import from which to draw dependencies.')
-
-parser.add_argument('--directory', action='store', default='.',
- help='The directory into which to expand things.')
-
-parser.add_argument('--extras', action='append',
- help='The set of extras for which to generate library targets.')
-
-def main():
- """
- Generate a BUILD file for an unzipped Wheel
-
- We allow for empty Python sources as for Wheels containing only compiled C code
- there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`).
- """
-
- args = parser.parse_args()
- whl = Wheel(args.whl)
-
- # Extract the files into the current directory
- whl.expand(args.directory)
-
- with open(os.path.join(args.directory, 'BUILD'), 'w') as f:
- f.write("""
-package(default_visibility = ["//visibility:public"])
-
-load("@rules_python//python:defs.bzl", "py_library")
-load("{requirements}", "requirement")
-
-py_library(
- name = "pkg",
- srcs = glob(["**/*.py"], allow_empty = True),
- data = glob(["**/*"], exclude=["**/*.py", "**/* *", "BUILD", "WORKSPACE"]),
- # This makes this directory a top-level in the python import
- # search path for anything that depends on this.
- imports = ["."],
- deps = [{dependencies}],
-)
-{extras}""".format(
- requirements=args.requirements,
- dependencies=','.join([
- 'requirement("%s")' % d
- for d in whl.dependencies()
- ]),
- extras='\n\n'.join([
- """py_library(
- name = "{extra}",
- deps = [
- ":pkg",{deps}
- ],
-)""".format(extra=extra,
- deps=','.join([
- 'requirement("%s")' % dep
- for dep in whl.dependencies(extra)
- ]))
- for extra in args.extras or []
- ])))
-
-if __name__ == '__main__':
- main()
diff --git a/packaging/whl_test.py b/packaging/whl_test.py
deleted file mode 100644
index 1a29f5b..0000000
--- a/packaging/whl_test.py
+++ /dev/null
@@ -1,120 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import unittest
-
-from mock import patch
-
-from packaging import whl
-
-
-def TestData(name):
- return os.path.join(os.environ['TEST_SRCDIR'], name)
-
-
-class WheelTest(unittest.TestCase):
-
- def test_grpc_whl(self):
- td = TestData('grpc_whl/file/grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(wheel.name(), 'grpcio')
- self.assertEqual(wheel.distribution(), 'grpcio')
- self.assertEqual(wheel.version(), '1.6.0')
- self.assertEqual(set(wheel.dependencies()),
- set(['enum34', 'futures', 'protobuf', 'six']))
- self.assertEqual('pypi__grpcio_1_6_0', wheel.repository_suffix())
- self.assertEqual([], wheel.extras())
-
- def test_futures_whl(self):
- td = TestData('futures_3_1_1_whl/file/futures-3.1.1-py2-none-any.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(wheel.name(), 'futures')
- self.assertEqual(wheel.distribution(), 'futures')
- self.assertEqual(wheel.version(), '3.1.1')
- self.assertEqual(set(wheel.dependencies()), set())
- self.assertEqual('pypi__futures_3_1_1', wheel.repository_suffix())
- self.assertEqual([], wheel.extras())
-
- def test_whl_with_METADATA_file(self):
- td = TestData('futures_2_2_0_whl/file/futures-2.2.0-py2.py3-none-any.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(wheel.name(), 'futures')
- self.assertEqual(wheel.distribution(), 'futures')
- self.assertEqual(wheel.version(), '2.2.0')
- self.assertEqual(set(wheel.dependencies()), set())
- self.assertEqual('pypi__futures_2_2_0', wheel.repository_suffix())
-
- @patch('platform.python_version', return_value='2.7.13')
- def test_mock_whl(self, *args):
- td = TestData('mock_whl/file/mock-2.0.0-py2.py3-none-any.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(wheel.name(), 'mock')
- self.assertEqual(wheel.distribution(), 'mock')
- self.assertEqual(wheel.version(), '2.0.0')
- self.assertEqual(set(wheel.dependencies()),
- set(['funcsigs', 'pbr', 'six']))
- self.assertEqual('pypi__mock_2_0_0', wheel.repository_suffix())
-
- @patch('platform.python_version', return_value='3.3.0')
- def test_mock_whl_3_3(self, *args):
- td = TestData('mock_whl/file/mock-2.0.0-py2.py3-none-any.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(set(wheel.dependencies()),
- set(['pbr', 'six']))
-
- @patch('platform.python_version', return_value='2.7.13')
- def test_mock_whl_extras(self, *args):
- td = TestData('mock_whl/file/mock-2.0.0-py2.py3-none-any.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(['docs', 'test'], wheel.extras())
- self.assertEqual(set(wheel.dependencies(extra='docs')), set(['sphinx']))
- self.assertEqual(set(wheel.dependencies(extra='test')), set(['unittest2']))
-
- @patch('platform.python_version', return_value='3.0.0')
- def test_mock_whl_extras_3_0(self, *args):
- td = TestData('mock_whl/file/mock-2.0.0-py2.py3-none-any.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(['docs', 'test'], wheel.extras())
- self.assertEqual(set(wheel.dependencies(extra='docs')), set(['sphinx', 'Pygments', 'jinja2']))
- self.assertEqual(set(wheel.dependencies(extra='test')), set(['unittest2']))
-
- @patch('platform.python_version', return_value='2.7.13')
- def test_google_cloud_language_whl(self, *args):
- td = TestData('google_cloud_language_whl/file/' +
- 'google_cloud_language-0.29.0-py2.py3-none-any.whl')
- wheel = whl.Wheel(td)
- self.assertEqual(wheel.name(), 'google-cloud-language')
- self.assertEqual(wheel.distribution(), 'google_cloud_language')
- self.assertEqual(wheel.version(), '0.29.0')
- expected_deps = ['google-gax', 'google-cloud-core',
- 'googleapis-common-protos[grpc]', 'enum34']
- self.assertEqual(set(wheel.dependencies()),
- set(expected_deps))
- self.assertEqual('pypi__google_cloud_language_0_29_0',
- wheel.repository_suffix())
- self.assertEqual([], wheel.extras())
-
- @patch('platform.python_version', return_value='3.4.0')
- def test_google_cloud_language_whl_3_4(self, *args):
- td = TestData('google_cloud_language_whl/file/' +
- 'google_cloud_language-0.29.0-py2.py3-none-any.whl')
- wheel = whl.Wheel(td)
- expected_deps = ['google-gax', 'google-cloud-core',
- 'googleapis-common-protos[grpc]']
- self.assertEqual(set(wheel.dependencies()),
- set(expected_deps))
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/python/BUILD b/python/BUILD
index 972bf9e..9470ad6 100644
--- a/python/BUILD
+++ b/python/BUILD
@@ -24,8 +24,6 @@
that @rules_python//python is only concerned with the core rules.
"""
-load("//python/pip_install:requirements.bzl", "compile_pip_requirements")
-
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
@@ -34,7 +32,6 @@
name = "distribution",
srcs = glob(["**"]) + [
"//python/constraints:distribution",
- "//python/legacy_pip_import:distribution",
"//python/runfiles:distribution",
"//python/private:distribution",
],
@@ -140,8 +137,3 @@
"pip.bzl",
"whl.bzl",
])
-
-compile_pip_requirements(
- name = "requirements",
- extra_args = ["--allow-unsafe"],
-)
diff --git a/python/legacy_pip_import/BUILD b/python/legacy_pip_import/BUILD
deleted file mode 100644
index d76747a..0000000
--- a/python/legacy_pip_import/BUILD
+++ /dev/null
@@ -1,8 +0,0 @@
-filegroup(
- name = "distribution",
- srcs = [
- "BUILD",
- "pip.bzl",
- ],
- visibility = ["//python:__pkg__"],
-)
diff --git a/python/legacy_pip_import/pip.bzl b/python/legacy_pip_import/pip.bzl
deleted file mode 100644
index e2b1b87..0000000
--- a/python/legacy_pip_import/pip.bzl
+++ /dev/null
@@ -1,143 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Import pip requirements into Bazel."""
-
-def _pip_import_impl(repository_ctx):
- """Core implementation of pip_import."""
-
- # Add an empty top-level BUILD file.
- # This is because Bazel requires BUILD files along all paths accessed
- # via //this/sort/of:path and we wouldn't be able to load our generated
- # requirements.bzl without it.
- repository_ctx.file("BUILD", "")
-
- interpreter_path = repository_ctx.attr.python_interpreter
- if repository_ctx.attr.python_interpreter_target != None:
- target = repository_ctx.attr.python_interpreter_target
- interpreter_path = repository_ctx.path(target)
-
- args = [
- interpreter_path,
- repository_ctx.path(repository_ctx.attr._script),
- "--python_interpreter",
- interpreter_path,
- "--name",
- repository_ctx.attr.name,
- "--input",
- repository_ctx.path(repository_ctx.attr.requirements),
- "--output",
- repository_ctx.path("requirements.bzl"),
- "--directory",
- repository_ctx.path(""),
- ]
- if repository_ctx.attr.extra_pip_args:
- args += [
- "--extra_pip_args",
- "\"" + " ".join(repository_ctx.attr.extra_pip_args) + "\"",
- ]
-
- # To see the output, pass: quiet=False
- result = repository_ctx.execute(args, timeout = repository_ctx.attr.timeout)
-
- if result.return_code:
- fail("pip_import failed: %s (%s)" % (result.stdout, result.stderr))
-
-pip_import = repository_rule(
- attrs = {
- "extra_pip_args": attr.string_list(
- doc = "Extra arguments to pass on to pip. Must not contain spaces.",
- ),
- "python_interpreter": attr.string(default = "python", doc = """
-The command to run the Python interpreter used to invoke pip and unpack the
-wheels.
-"""),
- "python_interpreter_target": attr.label(allow_single_file = True, doc = """
-If you are using a custom python interpreter built by another repository rule,
-use this attribute to specify its BUILD target. This allows pip_import to invoke
-pip using the same interpreter as your toolchain. If set, takes precedence over
-python_interpreter.
-"""),
- "requirements": attr.label(
- mandatory = True,
- allow_single_file = True,
- doc = "The label of the requirements.txt file.",
- ),
- "timeout": attr.int(
- default = 600,
- doc = "Timeout (in seconds) for repository fetch.",
- ),
- "_script": attr.label(
- executable = True,
- default = Label("//tools:piptool.par"),
- cfg = "host",
- ),
- },
- implementation = _pip_import_impl,
- doc = """A rule for importing `requirements.txt` dependencies into Bazel.
-
-This rule imports a `requirements.txt` file and generates a new
-`requirements.bzl` file. This is used via the `WORKSPACE` pattern:
-
-```python
-pip_import(
- name = "foo",
- requirements = ":requirements.txt",
-)
-load("@foo//:requirements.bzl", "pip_install")
-pip_install()
-```
-
-You can then reference imported dependencies from your `BUILD` file with:
-
-```python
-load("@foo//:requirements.bzl", "requirement")
-py_library(
- name = "bar",
- ...
- deps = [
- "//my/other:dep",
- requirement("futures"),
- requirement("mock"),
- ],
-)
-```
-
-Or alternatively:
-```python
-load("@foo//:requirements.bzl", "all_requirements")
-py_binary(
- name = "baz",
- ...
- deps = [
- ":foo",
- ] + all_requirements,
-)
-```
-""",
-)
-
-# We don't provide a `pip2_import` that would use the `python2` system command
-# because this command does not exist on all platforms. On most (but not all)
-# systems, `python` means Python 2 anyway. See also #258.
-
-def pip3_import(**kwargs):
- """A wrapper around pip_import that uses the `python3` system command.
-
- Use this for requirements of PY3 programs.
- """
- pip_import(python_interpreter = "python3", **kwargs)
-
-def pip_repositories():
- # buildifier: disable=print
- print("DEPRECATED: the pip_import rule has been replaced with pip_install, please see rules_python 0.1 release notes")
diff --git a/python/pip.bzl b/python/pip.bzl
index cac11c2..7776efe 100644
--- a/python/pip.bzl
+++ b/python/pip.bzl
@@ -199,15 +199,3 @@
# buildifier: disable=print
print("DEPRECATED: the pip_repositories rule has been replaced with pip_install, please see rules_python 0.1 release notes")
-
-def pip_import(**kwargs):
- """
- Rule for installing packages listed in a requirements file.
-
- Deprecated:
- the pip_import rule has been replaced with pip_install.
- """
- fail("=" * 79 + """\n
- pip_import has been replaced with pip_install, please see the rules_python 0.1 release notes.
- To continue using it, you can load from "@rules_python//python/legacy_pip_import:pip.bzl"
- """)
diff --git a/python/requirements.in b/python/requirements.in
deleted file mode 100644
index cae7f29..0000000
--- a/python/requirements.in
+++ /dev/null
@@ -1,10 +0,0 @@
-pip==9.0.3
-setuptools==44.0.0
-wheel==0.30.0a0
-
-# For tests
-mock==2.0.0
-# This is a transitive dependency of mock, which only appears on some python versions
-# Right now our repo doesn't pin our Python interpreter, so our locked requirements
-# may differ between local dev and CI, for example.
-funcsigs==1.0.2
diff --git a/python/requirements.txt b/python/requirements.txt
deleted file mode 100644
index 9bba20d..0000000
--- a/python/requirements.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# This file is autogenerated by pip-compile
-# To update, run:
-#
-# bazel run //python:requirements.update
-#
-funcsigs==1.0.2 \
- --hash=sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca \
- --hash=sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50
- # via -r python/requirements.in
-mock==2.0.0 \
- --hash=sha256:5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1 \
- --hash=sha256:b158b6df76edd239b8208d481dc46b6afd45a846b7812ff0ce58971cf5bc8bba
- # via -r python/requirements.in
-pbr==5.5.1 \
- --hash=sha256:5fad80b613c402d5b7df7bd84812548b2a61e9977387a80a5fc5c396492b13c9 \
- --hash=sha256:b236cde0ac9a6aedd5e3c34517b423cd4fd97ef723849da6b0d2231142d89c00
- # via mock
-six==1.15.0 \
- --hash=sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259 \
- --hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced
- # via mock
-wheel==0.30.0a0 \
- --hash=sha256:98f3e09b4ad7f5649a7e3d00e0e005ec1824ddcd6ec16c5086c05b1d91ada6da \
- --hash=sha256:cd19aa9325d3af1c641b0a23502b12696159171d2a2f4b84308df9a075c2a4a0
- # via -r python/requirements.in
-
-# The following packages are considered to be unsafe in a requirements file:
-pip==9.0.3 \
- --hash=sha256:7bf48f9a693be1d58f49f7af7e0ae9fe29fd671cde8a55e6edca3581c4ef5796 \
- --hash=sha256:c3ede34530e0e0b2381e7363aded78e0c33291654937e7373032fda04e8803e5
- # via -r python/requirements.in
-setuptools==44.0.0 \
- --hash=sha256:180081a244d0888b0065e18206950d603f6550721bd6f8c0a10221ed467dd78e \
- --hash=sha256:e5baf7723e5bb8382fc146e33032b241efc63314211a3a120aaa55d62d2bb008
- # via -r python/requirements.in
diff --git a/tools/BUILD b/tools/BUILD
index 0e3cf70..789bc2b 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -23,19 +23,11 @@
srcs = ["wheelmaker.py"],
)
-# These files are generated and updated by ./update_tools.sh
-exports_files([
- "piptool.par",
- "whltool.par",
-])
-
filegroup(
name = "distribution",
srcs = [
"BUILD",
"wheelmaker.py",
- ] + glob([
- "*.par",
- ]),
+ ],
visibility = ["//:__pkg__"],
)
diff --git a/tools/piptool.par b/tools/piptool.par
deleted file mode 100755
index a94cd4d..0000000
--- a/tools/piptool.par
+++ /dev/null
Binary files differ
diff --git a/tools/update_tools/Dockerfile b/tools/update_tools/Dockerfile
deleted file mode 100644
index 1864fd1..0000000
--- a/tools/update_tools/Dockerfile
+++ /dev/null
@@ -1,35 +0,0 @@
-FROM gcr.io/gcp-runtimes/ubuntu_16_0_4:latest
-
-# Install Bazel (https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu).
-RUN apt-get update -y && apt-get install -y \
- # The JDK requirement is from the instructions for the bazel apt package,
- # which we're not using here, but let's be safe.
- openjdk-8-jdk \
- # These requirements are from the link above.
- pkg-config zip g++ zlib1g-dev unzip python3 \
- # And why should python3 have all the fun?
- python \
- # We also need git for git_repository to work. Maybe these other ones too.
- git unzip build-essential \
- # And wget for the below command.
- wget
-
-RUN wget https://github.com/bazelbuild/bazel/releases/download/0.28.0/bazel-0.28.0-installer-linux-x86_64.sh -O /tmp/bazel-installer.sh
-RUN chmod +x /tmp/bazel-installer.sh && /tmp/bazel-installer.sh
-
-# Sanity check the install.
-RUN bazel help info >/dev/null 2>&1
-
-# Build par files. We have a source and work directory to avoid stomping on
-# other files as root.
-CMD cp -r /opt/rules_python_source /opt/rules_python && \
- cd /opt/rules_python && \
- bazel clean && \
- bazel build //packaging:piptool.par //packaging:whltool.par \
- # This works around a bug in git_repository to give us better debugging
- # if there's an error.
- # TODO(brandjon): Remove this once we're using Bazel 0.29, which
- # contains the fix.
- --incompatible_string_join_requires_strings=false && \
- cp bazel-bin/packaging/piptool.par bazel-bin/packaging/whltool.par /opt/rules_python_source/tools/ && \
- chown --reference=/opt/rules_python_source/update_tools.sh /opt/rules_python_source/tools/piptool.par /opt/rules_python_source/tools/whltool.par
diff --git a/tools/whltool.par b/tools/whltool.par
deleted file mode 100755
index 36074db..0000000
--- a/tools/whltool.par
+++ /dev/null
Binary files differ
diff --git a/update_tools.sh b/update_tools.sh
deleted file mode 100755
index 41ca047..0000000
--- a/update_tools.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -euo pipefail
-
-usage() {
- echo "Usage: $0 [--nodocker]" 1>&2
- exit 1
-}
-
-if [ "$#" -eq 0 ] ; then
- docker build --no-cache -f tools/update_tools/Dockerfile --tag rules_python:update_tools .
- docker run -v"$PWD":/opt/rules_python_source rules_python:update_tools
-elif [ "$#" -eq 1 -a "$1" == "--nodocker" ] ; then
- bazel build //packaging:piptool.par //packaging:whltool.par
- cp bazel-bin/packaging/piptool.par tools/piptool.par
- cp bazel-bin/packaging/whltool.par tools/whltool.par
-else
- usage
-fi