diff --git a/.bazelrc b/.bazelrc index 753c38f70f..22f7028251 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/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/proto,tests/compile_pip_requirements,tests/compile_pip_requirements_test_from_external_workspace,tests/ignore_root_user_error,tests/pip_repository_entry_points -query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/proto,tests/compile_pip_requirements,tests/compile_pip_requirements_test_from_external_workspace,tests/ignore_root_user_error,tests/pip_repository_entry_points +build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/proto,tests/compile_pip_requirements,tests/compile_pip_requirements_test_from_external_workspace,tests/ignore_root_user_error,tests/pip_repository_entry_points +query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/proto,tests/compile_pip_requirements,tests/compile_pip_requirements_test_from_external_workspace,tests/ignore_root_user_error,tests/pip_repository_entry_points test --test_output=errors diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e01615107..5540bae1a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,16 @@ A brief description of the categories of changes: * Make `//python/pip_install:pip_repository_bzl` `bzl_library` target internal as all of the publicly available symbols (etc. `package_annotation`) are re-exported via `//python:pip_bzl` `bzl_library`. -* Gazelle Python extension no longer has runtime dependencies. Using `GAZELLE_PYTHON_RUNTIME_DEPS` from `@rules_python_gazelle_plugin//:def.bzl` is no longer necessary. + +* Gazelle Python extension no longer has runtime dependencies. Using + `GAZELLE_PYTHON_RUNTIME_DEPS` from `@rules_python_gazelle_plugin//:def.bzl` is + no longer necessary. + +Breaking changes: + +* (pip) `pip_install` repository rule in this release has been disabled and + will fail by default. The API symbol is going to be removed in the next + version, please migrate to `pip_parse` as a replacement. ### Fixed diff --git a/docs/pip.md b/docs/pip.md index f84262a464..f6b7af7824 100644 --- a/docs/pip.md +++ b/docs/pip.md @@ -145,24 +145,10 @@ str: A json encoded string of the provided content. ## pip_install
-pip_install(requirements, name, kwargs)
+pip_install(requirements, name, allow_pip_install, kwargs)
 
-Accepts a locked/compiled requirements file and installs the dependencies listed within. - -```python -load("@rules_python//python:pip.bzl", "pip_install") - -pip_install( - name = "pip_deps", - requirements = ":requirements.txt", -) - -load("@pip_deps//:requirements.bzl", "install_deps") - -install_deps() -``` - +Will be removed in 0.28.0 **PARAMETERS** @@ -171,6 +157,7 @@ install_deps() | :------------- | :------------- | :------------- | | requirements | A 'requirements.txt' pip requirements file. | `None` | | name | A unique name for the created external repository (default 'pip'). | `"pip"` | +| allow_pip_install | change this to keep this rule working (default False). | `False` | | kwargs | Additional arguments to the [`pip_repository`](./pip_repository.md) repository rule. | none | diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index f8d0ebe77e..35c88cc3fd 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -27,11 +27,6 @@ bazel_integration_test( timeout = "long", ) -bazel_integration_test( - name = "pip_install_example", - timeout = "long", -) - bazel_integration_test( name = "pip_parse_example", timeout = "long", diff --git a/examples/pip_install/.bazelrc b/examples/pip_install/.bazelrc deleted file mode 100644 index 9e7ef37327..0000000000 --- a/examples/pip_install/.bazelrc +++ /dev/null @@ -1,2 +0,0 @@ -# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file -try-import %workspace%/user.bazelrc diff --git a/examples/pip_install/.gitignore b/examples/pip_install/.gitignore deleted file mode 100644 index e5ae073b3c..0000000000 --- a/examples/pip_install/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# git ignore patterns - -/bazel-* -user.bazelrc diff --git a/examples/pip_install/BUILD.bazel b/examples/pip_install/BUILD.bazel deleted file mode 100644 index 87c5aa7f8c..0000000000 --- a/examples/pip_install/BUILD.bazel +++ /dev/null @@ -1,110 +0,0 @@ -load("@bazel_skylib//rules:diff_test.bzl", "diff_test") -load("@bazel_skylib//rules:write_file.bzl", "write_file") -load( - "@pip//:requirements.bzl", - "data_requirement", - "dist_info_requirement", - "entry_point", - "requirement", -) -load("@rules_python//python:defs.bzl", "py_binary", "py_test") -load("@rules_python//python:pip.bzl", "compile_pip_requirements") - -# Toolchain setup, this is optional. -# Demonstrate that we can use the same python interpreter for the toolchain and executing pip in pip install (see WORKSPACE). -# -#load("@rules_python//python:defs.bzl", "py_runtime_pair") -# -#py_runtime( -# name = "python3_runtime", -# files = ["@python_interpreter//:files"], -# interpreter = "@python_interpreter//:python_bin", -# python_version = "PY3", -# visibility = ["//visibility:public"], -#) -# -#py_runtime_pair( -# name = "my_py_runtime_pair", -# py2_runtime = None, -# py3_runtime = ":python3_runtime", -#) -# -#toolchain( -# name = "my_py_toolchain", -# toolchain = ":my_py_runtime_pair", -# toolchain_type = "@bazel_tools//tools/python:toolchain_type", -#) -# End of toolchain setup. - -py_binary( - name = "main", - srcs = ["main.py"], - deps = [ - requirement("boto3"), - ], -) - -py_test( - name = "test", - srcs = ["test.py"], - deps = [":main"], -) - -# For pip dependencies which have entry points, the `entry_point` macro can be -# used from the generated `pip_install` repository to access a runnable binary. - -alias( - name = "yamllint", - actual = entry_point("yamllint"), -) - -# Check that our compiled requirements are up-to-date -compile_pip_requirements( - name = "requirements", - requirements_windows = ":requirements_windows.txt", -) - -# Test the use of all pip_install utilities in a single py_test -py_test( - name = "pip_install_test", - srcs = ["pip_install_test.py"], - data = [ - ":yamllint", - data_requirement("s3cmd"), - dist_info_requirement("boto3"), - ], - env = { - "WHEEL_DATA_CONTENTS": "$(rootpaths {})".format(data_requirement("s3cmd")), - "WHEEL_DIST_INFO_CONTENTS": "$(rootpaths {})".format(dist_info_requirement("boto3")), - "YAMLLINT_ENTRY_POINT": "$(rootpath :yamllint)", - }, - deps = ["@rules_python//python/runfiles"], -) - -# Assert that tags are present on resulting py_library, -# which is useful for tooling that needs to reflect on the dep graph -# to determine the packages it was built from. -genquery( - name = "yamllint_lib_by_version", - expression = """ - attr("tags", "\\bpypi_version=1.28.0\\b", "@pip_yamllint//:pkg") - intersect - attr("tags", "\\bpypi_name=yamllint\\b", "@pip_yamllint//:pkg") - """, - scope = [requirement("yamllint")], -) - -write_file( - name = "write_expected", - out = "expected", - content = [ - "@pip_yamllint//:pkg", - "", - ], -) - -diff_test( - name = "test_query_result", - file1 = "expected", - file2 = "yamllint_lib_by_version", -) diff --git a/examples/pip_install/README.md b/examples/pip_install/README.md deleted file mode 100644 index 76577870f8..0000000000 --- a/examples/pip_install/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# pip_install example - -This example shows how to use pip to fetch external dependencies from a requirements.txt file, -then use them in BUILD files as dependencies of Bazel targets. diff --git a/examples/pip_install/WORKSPACE b/examples/pip_install/WORKSPACE deleted file mode 100644 index b1744bfa7d..0000000000 --- a/examples/pip_install/WORKSPACE +++ /dev/null @@ -1,96 +0,0 @@ -workspace(name = "rules_python_pip_install_example") - -local_repository( - name = "rules_python", - path = "../..", -) - -load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") - -py_repositories() - -python_register_toolchains( - name = "python39", - python_version = "3.9", -) - -load("@python39//:defs.bzl", "interpreter") -load("@rules_python//python:pip.bzl", "pip_install") - -pip_install( - # (Optional) You can provide extra parameters to pip. - # Here, make pip output verbose (this is usable with `quiet = False`). - #extra_pip_args = ["-v"], - - # (Optional) You can exclude custom elements in the data section of the generated BUILD files for pip packages. - # Exclude directories with spaces in their names in this example (avoids build errors if there are such directories). - #pip_data_exclude = ["**/* */**"], - - # (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that - # acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.: - # 1. Python interpreter that you compile in the build file (as above in @python_interpreter). - # 2. Pre-compiled python interpreter included with http_archive - # 3. Wrapper script, like in the autodetecting python toolchain. - # - # Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain. - python_interpreter_target = interpreter, - - # (Optional) You can set quiet to False if you want to see pip output. - #quiet = False, - - # (Optional) You can set an environment in the pip process to control its - # behavior. Note that pip is run in "isolated" mode so no PIP__ - # style env vars are read, but env vars that control requests and urllib3 - # can be passed. - #environment = {"HTTP_PROXY": "http://my.proxy.fun/"}, - - # Uses the default repository name "pip" - requirements = "//:requirements.txt", -) - -load("@pip//:requirements.bzl", "install_deps") - -# Initialize repositories for all packages in requirements.txt. -install_deps() - -# You could optionally use an in-build, compiled python interpreter as a toolchain, -# and also use it to execute pip. -# -# Special logic for building python interpreter with OpenSSL from homebrew. -# See https://devguide.python.org/setup/#macos-and-os-x -#_py_configure = """ -#if [[ "$OSTYPE" == "darwin"* ]]; then -# ./configure --prefix=$(pwd)/bazel_install --with-openssl=$(brew --prefix openssl) -#else -# ./configure --prefix=$(pwd)/bazel_install -#fi -#""" -# -# NOTE: you need to have the SSL headers installed to build with openssl support (and use HTTPS). -# E.g. on Ubuntu: `sudo apt install libssl-dev` -#http_archive( -# name = "python_interpreter", -# build_file_content = """ -#exports_files(["python_bin"]) -#filegroup( -# name = "files", -# srcs = glob(["bazel_install/**"], exclude = ["**/* *"]), -# visibility = ["//visibility:public"], -#) -#""", -# patch_cmds = [ -# "mkdir $(pwd)/bazel_install", -# _py_configure, -# "make", -# "make install", -# "ln -s bazel_install/bin/python3 python_bin", -# ], -# sha256 = "dfab5ec723c218082fe3d5d7ae17ecbdebffa9a1aea4d64aa3a2ecdd2e795864", -# strip_prefix = "Python-3.8.3", -# urls = ["https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz"], -#) - -# Optional: -# Register the toolchain with the same python interpreter we used for pip in pip_install(). -#register_toolchains("//:my_py_toolchain") -# End of in-build Python interpreter setup. diff --git a/examples/pip_install/main.py b/examples/pip_install/main.py deleted file mode 100644 index 1fb7249f76..0000000000 --- a/examples/pip_install/main.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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. - -import boto3 - - -def the_dir(): - return dir(boto3) - - -if __name__ == "__main__": - print(the_dir()) diff --git a/examples/pip_install/pip_install_test.py b/examples/pip_install/pip_install_test.py deleted file mode 100644 index f49422bb83..0000000000 --- a/examples/pip_install/pip_install_test.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python3 -# 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. - - -import os -import subprocess -import unittest -from pathlib import Path - -from rules_python.python.runfiles import runfiles - - -class PipInstallTest(unittest.TestCase): - maxDiff = None - - def test_entry_point(self): - env = os.environ.get("YAMLLINT_ENTRY_POINT") - self.assertIsNotNone(env) - - r = runfiles.Create() - - # To find an external target, this must use `{workspace_name}/$(rootpath @external_repo//:target)` - entry_point = Path( - r.Rlocation("rules_python_pip_install_example/{}".format(env)) - ) - self.assertTrue(entry_point.exists()) - - proc = subprocess.run( - [str(entry_point), "--version"], - check=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.28.0") - - def test_data(self): - env = os.environ.get("WHEEL_DATA_CONTENTS") - self.assertIsNotNone(env) - self.assertListEqual( - env.split(" "), - [ - "external/pip_s3cmd/data/share/doc/packages/s3cmd/INSTALL.md", - "external/pip_s3cmd/data/share/doc/packages/s3cmd/LICENSE", - "external/pip_s3cmd/data/share/doc/packages/s3cmd/NEWS", - "external/pip_s3cmd/data/share/doc/packages/s3cmd/README.md", - "external/pip_s3cmd/data/share/man/man1/s3cmd.1", - ], - ) - - def test_dist_info(self): - env = os.environ.get("WHEEL_DIST_INFO_CONTENTS") - self.assertIsNotNone(env) - self.assertListEqual( - env.split(" "), - [ - "external/pip_boto3/site-packages/boto3-1.14.63.dist-info/DESCRIPTION.rst", - "external/pip_boto3/site-packages/boto3-1.14.63.dist-info/INSTALLER", - "external/pip_boto3/site-packages/boto3-1.14.63.dist-info/METADATA", - "external/pip_boto3/site-packages/boto3-1.14.63.dist-info/RECORD", - "external/pip_boto3/site-packages/boto3-1.14.63.dist-info/WHEEL", - "external/pip_boto3/site-packages/boto3-1.14.63.dist-info/metadata.json", - "external/pip_boto3/site-packages/boto3-1.14.63.dist-info/top_level.txt", - ], - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/examples/pip_install/requirements.in b/examples/pip_install/requirements.in deleted file mode 100644 index 3480175020..0000000000 --- a/examples/pip_install/requirements.in +++ /dev/null @@ -1,4 +0,0 @@ -boto3~=1.14.51 -s3cmd~=2.1.0 -yamllint~=1.28.0 -tree-sitter==0.20.0 ; sys_platform != "win32" diff --git a/examples/pip_install/requirements.txt b/examples/pip_install/requirements.txt deleted file mode 100644 index 00fe860169..0000000000 --- a/examples/pip_install/requirements.txt +++ /dev/null @@ -1,113 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.9 -# by the following command: -# -# bazel run //:requirements.update -# -boto3==1.14.63 \ - --hash=sha256:25c716b7c01d4664027afc6a6418a06459e311a610c7fd39a030a1ced1b72ce4 \ - --hash=sha256:37158c37a151eab5b9080968305621a40168171fda9584d50a309ceb4e5e6964 - # via -r requirements.in -botocore==1.17.63 \ - --hash=sha256:40f13f6c9c29c307a9dc5982739e537ddce55b29787b90c3447b507e3283bcd6 \ - --hash=sha256:aa88eafc6295132f4bc606f1df32b3248e0fa611724c0a216aceda767948ac75 - # via - # boto3 - # s3transfer -docutils==0.15.2 \ - --hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 \ - --hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 \ - --hash=sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99 - # via botocore -jmespath==0.10.0 \ - --hash=sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9 \ - --hash=sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f - # via - # boto3 - # botocore -pathspec==0.10.3 \ - --hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \ - --hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6 - # via yamllint -python-dateutil==2.8.2 \ - --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \ - --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9 - # via - # botocore - # s3cmd -python-magic==0.4.27 \ - --hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \ - --hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3 - # via s3cmd -pyyaml==6.0 \ - --hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \ - --hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \ - --hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \ - --hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \ - --hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \ - --hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \ - --hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \ - --hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \ - --hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \ - --hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \ - --hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \ - --hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \ - --hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \ - --hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \ - --hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \ - --hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \ - --hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \ - --hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \ - --hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \ - --hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \ - --hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \ - --hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \ - --hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \ - --hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \ - --hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \ - --hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \ - --hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \ - --hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \ - --hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \ - --hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \ - --hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \ - --hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \ - --hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \ - --hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \ - --hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \ - --hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \ - --hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \ - --hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \ - --hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \ - --hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5 - # via yamllint -s3cmd==2.1.0 \ - --hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \ - --hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03 - # via -r requirements.in -s3transfer==0.3.7 \ - --hash=sha256:35627b86af8ff97e7ac27975fe0a98a312814b46c6333d8a6b889627bcd80994 \ - --hash=sha256:efa5bd92a897b6a8d5c1383828dca3d52d0790e0756d49740563a3fb6ed03246 - # via boto3 -six==1.16.0 \ - --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ - --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 - # via python-dateutil -tree-sitter==0.20.0 ; sys_platform != "win32" \ - --hash=sha256:1940f64be1e8c9c3c0e34a2258f1e4c324207534d5b1eefc5ab2960a9d98f668 \ - --hash=sha256:51a609a7c1bd9d9e75d92ee128c12c7852ae70a482900fbbccf3d13a79e0378c - # via -r requirements.in -urllib3==1.25.11 \ - --hash=sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2 \ - --hash=sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e - # via botocore -yamllint==1.28.0 \ - --hash=sha256:89bb5b5ac33b1ade059743cf227de73daa34d5e5a474b06a5e17fc16583b0cf2 \ - --hash=sha256:9e3d8ddd16d0583214c5fdffe806c9344086721f107435f68bad990e5a88826b - # via -r requirements.in - -# The following packages are considered to be unsafe in a requirements file: -setuptools==65.6.3 \ - --hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \ - --hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75 - # via yamllint diff --git a/examples/pip_install/requirements_windows.txt b/examples/pip_install/requirements_windows.txt deleted file mode 100644 index c74eeacb06..0000000000 --- a/examples/pip_install/requirements_windows.txt +++ /dev/null @@ -1,109 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.9 -# by the following command: -# -# bazel run //:requirements.update -# -boto3==1.14.63 \ - --hash=sha256:25c716b7c01d4664027afc6a6418a06459e311a610c7fd39a030a1ced1b72ce4 \ - --hash=sha256:37158c37a151eab5b9080968305621a40168171fda9584d50a309ceb4e5e6964 - # via -r requirements.in -botocore==1.17.63 \ - --hash=sha256:40f13f6c9c29c307a9dc5982739e537ddce55b29787b90c3447b507e3283bcd6 \ - --hash=sha256:aa88eafc6295132f4bc606f1df32b3248e0fa611724c0a216aceda767948ac75 - # via - # boto3 - # s3transfer -docutils==0.15.2 \ - --hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 \ - --hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 \ - --hash=sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99 - # via botocore -jmespath==0.10.0 \ - --hash=sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9 \ - --hash=sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f - # via - # boto3 - # botocore -pathspec==0.10.3 \ - --hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \ - --hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6 - # via yamllint -python-dateutil==2.8.2 \ - --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \ - --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9 - # via - # botocore - # s3cmd -python-magic==0.4.27 \ - --hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \ - --hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3 - # via s3cmd -pyyaml==6.0 \ - --hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \ - --hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \ - --hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \ - --hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \ - --hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \ - --hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \ - --hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \ - --hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \ - --hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \ - --hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \ - --hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \ - --hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \ - --hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \ - --hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \ - --hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \ - --hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \ - --hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \ - --hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \ - --hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \ - --hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \ - --hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \ - --hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \ - --hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \ - --hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \ - --hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \ - --hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \ - --hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \ - --hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \ - --hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \ - --hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \ - --hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \ - --hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \ - --hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \ - --hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \ - --hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \ - --hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \ - --hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \ - --hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \ - --hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \ - --hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5 - # via yamllint -s3cmd==2.1.0 \ - --hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \ - --hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03 - # via -r requirements.in -s3transfer==0.3.7 \ - --hash=sha256:35627b86af8ff97e7ac27975fe0a98a312814b46c6333d8a6b889627bcd80994 \ - --hash=sha256:efa5bd92a897b6a8d5c1383828dca3d52d0790e0756d49740563a3fb6ed03246 - # via boto3 -six==1.16.0 \ - --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ - --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 - # via python-dateutil -urllib3==1.26.17 \ - --hash=sha256:24d6a242c28d29af46c3fae832c36db3bbebcc533dd1bb549172cd739c82df21 \ - --hash=sha256:94a757d178c9be92ef5539b8840d48dc9cf1b2709c9d6b588232a055c524458b - # via botocore -yamllint==1.28.0 \ - --hash=sha256:89bb5b5ac33b1ade059743cf227de73daa34d5e5a474b06a5e17fc16583b0cf2 \ - --hash=sha256:9e3d8ddd16d0583214c5fdffe806c9344086721f107435f68bad990e5a88826b - # via -r requirements.in - -# The following packages are considered to be unsafe in a requirements file: -setuptools==65.6.3 \ - --hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \ - --hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75 - # via yamllint diff --git a/examples/pip_install/test.py b/examples/pip_install/test.py deleted file mode 100644 index 0f5b7c905e..0000000000 --- a/examples/pip_install/test.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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. - -import unittest - -import main - - -class ExampleTest(unittest.TestCase): - def test_main(self): - self.assertIn("set_stream_logger", main.the_dir()) - - -if __name__ == "__main__": - unittest.main() diff --git a/examples/pip_repository_annotations/BUILD.bazel b/examples/pip_repository_annotations/BUILD.bazel index 77b5ab0698..5b924e1cb0 100644 --- a/examples/pip_repository_annotations/BUILD.bazel +++ b/examples/pip_repository_annotations/BUILD.bazel @@ -1,4 +1,3 @@ -load("@pip_installed//:requirements.bzl", "requirement") load("@rules_python//python:defs.bzl", "py_test") load("@rules_python//python:pip.bzl", "compile_pip_requirements") @@ -16,28 +15,13 @@ py_test( name = "pip_parse_annotations_test", srcs = ["pip_repository_annotations_test.py"], env = { - "REQUESTS_PKG_DIR": "pip_parsed_requests", - "WHEEL_PKG_DIR": "pip_parsed_wheel", + "REQUESTS_PKG_DIR": "pip_requests", + "WHEEL_PKG_DIR": "pip_wheel", }, main = "pip_repository_annotations_test.py", deps = [ - "@pip_parsed_requests//:pkg", - "@pip_parsed_wheel//:pkg", - "@rules_python//python/runfiles", - ], -) - -py_test( - name = "pip_install_annotations_test", - srcs = ["pip_repository_annotations_test.py"], - env = { - "REQUESTS_PKG_DIR": "pip_installed_requests", - "WHEEL_PKG_DIR": "pip_installed_wheel", - }, - main = "pip_repository_annotations_test.py", - deps = [ - requirement("wheel"), - requirement("requests"), + "@pip_requests//:pkg", + "@pip_wheel//:pkg", "@rules_python//python/runfiles", ], ) diff --git a/examples/pip_repository_annotations/WORKSPACE b/examples/pip_repository_annotations/WORKSPACE index 3deea0329c..35350550ef 100644 --- a/examples/pip_repository_annotations/WORKSPACE +++ b/examples/pip_repository_annotations/WORKSPACE @@ -15,7 +15,7 @@ python_register_toolchains( ) load("@python39//:defs.bzl", "interpreter") -load("@rules_python//python:pip.bzl", "package_annotation", "pip_install", "pip_parse") +load("@rules_python//python:pip.bzl", "package_annotation", "pip_parse") # Here we can see an example of annotations being applied to an arbitrary # package. For details on `package_annotation` and it's uses, see the @@ -52,24 +52,12 @@ write_file( # For a more thorough example of `pip_parse`. See `@rules_python//examples/pip_parse` pip_parse( - name = "pip_parsed", + name = "pip", annotations = ANNOTATIONS, python_interpreter_target = interpreter, requirements_lock = "//:requirements.txt", ) -load("@pip_parsed//:requirements.bzl", install_pip_parse_deps = "install_deps") +load("@pip//:requirements.bzl", "install_deps") -install_pip_parse_deps() - -# For a more thorough example of `pip_install`. See `@rules_python//examples/pip_install` -pip_install( - name = "pip_installed", - annotations = ANNOTATIONS, - python_interpreter_target = interpreter, - requirements = "//:requirements.txt", -) - -load("@pip_installed//:requirements.bzl", install_pip_install_deps = "install_deps") - -install_pip_install_deps() +install_deps() diff --git a/python/pip.bzl b/python/pip.bzl index fb842cc4ce..67a06f4b20 100644 --- a/python/pip.bzl +++ b/python/pip.bzl @@ -23,31 +23,20 @@ load("//python/private:render_pkg_aliases.bzl", "NO_MATCH_ERROR_MESSAGE_TEMPLATE compile_pip_requirements = _compile_pip_requirements package_annotation = _package_annotation -def pip_install(requirements = None, name = "pip", **kwargs): - """Accepts a locked/compiled requirements file and installs the dependencies listed within. - - ```python - load("@rules_python//python:pip.bzl", "pip_install") - - pip_install( - name = "pip_deps", - requirements = ":requirements.txt", - ) - - load("@pip_deps//:requirements.bzl", "install_deps") - - install_deps() - ``` +def pip_install(requirements = None, name = "pip", allow_pip_install = False, **kwargs): + """Will be removed in 0.28.0 Args: requirements (Label): A 'requirements.txt' pip requirements file. name (str, optional): A unique name for the created external repository (default 'pip'). + allow_pip_install (bool, optional): change this to keep this rule working (default False). **kwargs (dict): Additional arguments to the [`pip_repository`](./pip_repository.md) repository rule. """ - # buildifier: disable=print - print("pip_install is deprecated. Please switch to pip_parse. pip_install will be removed in a future release.") - pip_parse(requirements = requirements, name = name, **kwargs) + if allow_pip_install: + pip_parse(requirements = requirements, name = name, **kwargs) + else: + fail("pip_install support has been disabled, please use pip_parse as a replacement.") def pip_parse(requirements = None, requirements_lock = None, name = "pip_parsed_deps", **kwargs): """Accepts a locked/compiled requirements file and installs the dependencies listed within. diff --git a/tests/pip_repository_entry_points/BUILD.bazel b/tests/pip_repository_entry_points/BUILD.bazel index 2e2e2dcf99..f0204ca8b9 100644 --- a/tests/pip_repository_entry_points/BUILD.bazel +++ b/tests/pip_repository_entry_points/BUILD.bazel @@ -1,5 +1,4 @@ -load("@pip_installed//:requirements.bzl", installed_entry_point = "entry_point") -load("@pip_parsed//:requirements.bzl", parsed_entry_point = "entry_point") +load("@pip//:requirements.bzl", "entry_point") load("@rules_python//python:defs.bzl", "py_test") load("@rules_python//python:pip.bzl", "compile_pip_requirements") @@ -9,45 +8,23 @@ compile_pip_requirements( requirements_windows = ":requirements_windows.txt", ) -pip_parsed_sphinx = parsed_entry_point( +pip_sphinx = entry_point( pkg = "sphinx", script = "sphinx-build", ) -pip_parsed_yamllint = parsed_entry_point("yamllint") +pip_yamllint = entry_point("yamllint") py_test( name = "pip_parse_entry_points_test", srcs = ["pip_repository_entry_points_test.py"], data = [ - pip_parsed_sphinx, - pip_parsed_yamllint, + pip_sphinx, + pip_yamllint, ], env = { - "SPHINX_BUILD_ENTRY_POINT": "$(rootpath {})".format(pip_parsed_sphinx), - "YAMLLINT_ENTRY_POINT": "$(rootpath {})".format(pip_parsed_yamllint), - }, - main = "pip_repository_entry_points_test.py", - deps = ["@rules_python//python/runfiles"], -) - -pip_installed_sphinx = installed_entry_point( - pkg = "sphinx", - script = "sphinx-build", -) - -pip_installed_yamllint = installed_entry_point("yamllint") - -py_test( - name = "pip_install_annotations_test", - srcs = ["pip_repository_entry_points_test.py"], - data = [ - pip_installed_sphinx, - pip_installed_yamllint, - ], - env = { - "SPHINX_BUILD_ENTRY_POINT": "$(rootpath {})".format(pip_installed_sphinx), - "YAMLLINT_ENTRY_POINT": "$(rootpath {})".format(pip_installed_yamllint), + "SPHINX_BUILD_ENTRY_POINT": "$(rootpath {})".format(pip_sphinx), + "YAMLLINT_ENTRY_POINT": "$(rootpath {})".format(pip_yamllint), }, main = "pip_repository_entry_points_test.py", deps = ["@rules_python//python/runfiles"], diff --git a/tests/pip_repository_entry_points/WORKSPACE b/tests/pip_repository_entry_points/WORKSPACE index 1afd68c215..3ad8f2f8b7 100644 --- a/tests/pip_repository_entry_points/WORKSPACE +++ b/tests/pip_repository_entry_points/WORKSPACE @@ -1,4 +1,4 @@ -workspace(name = "pip_repository_annotations_example") +workspace(name = "pip_entry_points_example") local_repository( name = "rules_python", @@ -17,28 +17,16 @@ python_register_toolchains( ) load("@python310//:defs.bzl", "interpreter") -load("@rules_python//python:pip.bzl", "pip_install", "pip_parse") +load("@rules_python//python:pip.bzl", "pip_parse") # For a more thorough example of `pip_parse`. See `@rules_python//examples/pip_parse` pip_parse( - name = "pip_parsed", + name = "pip", python_interpreter_target = interpreter, requirements_lock = "//:requirements.txt", requirements_windows = "//:requirements_windows.txt", ) -load("@pip_parsed//:requirements.bzl", install_pip_parse_deps = "install_deps") +load("@pip//:requirements.bzl", "install_deps") -install_pip_parse_deps() - -# For a more thorough example of `pip_install`. See `@rules_python//examples/pip_install` -pip_install( - name = "pip_installed", - python_interpreter_target = interpreter, - requirements = "//:requirements.txt", - requirements_windows = "//:requirements_windows.txt", -) - -load("@pip_installed//:requirements.bzl", install_pip_install_deps = "install_deps") - -install_pip_install_deps() +install_deps()