| # Copyright 2023 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("@bazel_skylib//lib:versions.bzl", "versions") |
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") |
| |
| _RULE_DEPS = [ |
| ( |
| "pypi__build", |
| "https://files.pythonhosted.org/packages/03/97/f58c723ff036a8d8b4d3115377c0a37ed05c1f68dd9a0d66dab5e82c5c1c/build-0.9.0-py3-none-any.whl", |
| "38a7a2b7a0bdc61a42a0a67509d88c71ecfc37b393baba770fae34e20929ff69", |
| ), |
| ( |
| "pypi__click", |
| "https://files.pythonhosted.org/packages/76/0a/b6c5f311e32aeb3b406e03c079ade51e905ea630fc19d1262a46249c1c86/click-8.0.1-py3-none-any.whl", |
| "fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6", |
| ), |
| ( |
| "pypi__colorama", |
| "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", |
| "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", |
| ), |
| ( |
| "pypi__installer", |
| "https://files.pythonhosted.org/packages/bf/42/fe5f10fd0d58d5d8231a0bc39e664de09992f960597e9fbd3753f84423a3/installer-0.6.0-py3-none-any.whl", |
| "ae7c62d1d6158b5c096419102ad0d01fdccebf857e784cee57f94165635fe038", |
| ), |
| ( |
| "pypi__packaging", |
| "https://files.pythonhosted.org/packages/8f/7b/42582927d281d7cb035609cd3a543ffac89b74f3f4ee8e1c50914bcb57eb/packaging-22.0-py3-none-any.whl", |
| "957e2148ba0e1a3b282772e791ef1d8083648bc131c8ab0c1feba110ce1146c3", |
| ), |
| ( |
| "pypi__pep517", |
| "https://files.pythonhosted.org/packages/ee/2f/ef63e64e9429111e73d3d6cbee80591672d16f2725e648ebc52096f3d323/pep517-0.13.0-py3-none-any.whl", |
| "4ba4446d80aed5b5eac6509ade100bff3e7943a8489de249654a5ae9b33ee35b", |
| ), |
| ( |
| "pypi__pip", |
| "https://files.pythonhosted.org/packages/09/bd/2410905c76ee14c62baf69e3f4aa780226c1bbfc9485731ad018e35b0cb5/pip-22.3.1-py3-none-any.whl", |
| "908c78e6bc29b676ede1c4d57981d490cb892eb45cd8c214ab6298125119e077", |
| ), |
| ( |
| "pypi__pip_tools", |
| "https://files.pythonhosted.org/packages/5e/e8/f6d7d1847c7351048da870417724ace5c4506e816b38db02f4d7c675c189/pip_tools-6.12.1-py3-none-any.whl", |
| "f0c0c0ec57b58250afce458e2e6058b1f30a4263db895b7d72fd6311bf1dc6f7", |
| ), |
| ( |
| "pypi__setuptools", |
| "https://files.pythonhosted.org/packages/7c/5b/3d92b9f0f7ca1645cba48c080b54fe7d8b1033a4e5720091d1631c4266db/setuptools-60.10.0-py3-none-any.whl", |
| "782ef48d58982ddb49920c11a0c5c9c0b02e7d7d1c2ad0aa44e1a1e133051c96", |
| ), |
| ( |
| "pypi__tomli", |
| "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", |
| "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", |
| ), |
| ( |
| "pypi__wheel", |
| "https://files.pythonhosted.org/packages/bd/7c/d38a0b30ce22fc26ed7dbc087c6d00851fb3395e9d0dac40bec1f905030c/wheel-0.38.4-py3-none-any.whl", |
| "b60533f3f5d530e971d6737ca6d58681ee434818fab630c83a734bb10c083ce8", |
| ), |
| ( |
| "pypi__importlib_metadata", |
| "https://files.pythonhosted.org/packages/d7/31/74dcb59a601b95fce3b0334e8fc9db758f78e43075f22aeb3677dfb19f4c/importlib_metadata-1.4.0-py2.py3-none-any.whl", |
| "bdd9b7c397c273bcc9a11d6629a38487cd07154fa255a467bf704cd2c258e359", |
| ), |
| ( |
| "pypi__zipp", |
| "https://files.pythonhosted.org/packages/f4/50/cc72c5bcd48f6e98219fc4a88a5227e9e28b81637a99c49feba1d51f4d50/zipp-1.0.0-py2.py3-none-any.whl", |
| "8dda78f06bd1674bd8720df8a50bb47b6e1233c503a4eed8e7810686bde37656", |
| ), |
| ( |
| "pypi__more_itertools", |
| "https://files.pythonhosted.org/packages/bd/3f/c4b3dbd315e248f84c388bd4a72b131a29f123ecacc37ffb2b3834546e42/more_itertools-8.13.0-py3-none-any.whl", |
| "c5122bffc5f104d37c1626b8615b511f3427aa5389b94d61e5ef8236bfbc3ddb", |
| ), |
| ] |
| |
| _GENERIC_WHEEL = """\ |
| package(default_visibility = ["//visibility:public"]) |
| |
| load("@rules_python//python:defs.bzl", "py_library") |
| |
| py_library( |
| name = "lib", |
| srcs = glob(["**/*.py"]), |
| data = glob(["**/*"], exclude=[ |
| # These entries include those put into user-installed dependencies by |
| # data_exclude in /python/pip_install/tools/bazel.py |
| # to avoid non-determinism following pip install's behavior. |
| "**/*.py", |
| "**/*.pyc", |
| "**/* *", |
| "**/*.dist-info/RECORD", |
| "BUILD", |
| "WORKSPACE", |
| ]), |
| # This makes this directory a top-level in the python import |
| # search path for anything that depends on this. |
| imports = ["."], |
| ) |
| """ |
| |
| # Collate all the repository names so they can be easily consumed |
| all_requirements = [name for (name, _, _) in _RULE_DEPS] |
| |
| def requirement(pkg): |
| return Label("@pypi__" + pkg + "//:lib") |
| |
| def pip_install_dependencies(): |
| """ |
| Fetch dependencies these rules depend on. Workspaces that use the pip_install rule can call this. |
| |
| (However we call it from pip_install, making it optional for users to do so.) |
| """ |
| |
| # We only support Bazel LTS and rolling releases. |
| # Give the user an obvious error to upgrade rather than some obscure missing symbol later. |
| # It's not guaranteed that users call this function, but it's used by all the pip fetch |
| # repository rules so it's likely that most users get the right error. |
| versions.check("4.0.0") |
| |
| for (name, url, sha256) in _RULE_DEPS: |
| maybe( |
| http_archive, |
| name, |
| url = url, |
| sha256 = sha256, |
| type = "zip", |
| build_file_content = _GENERIC_WHEEL, |
| ) |