1workspace(name = "rules_python_pip_parse_example") 2 3local_repository( 4 name = "rules_python", 5 path = "../..", 6) 7 8load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") 9 10py_repositories() 11 12python_register_toolchains( 13 name = "python_3_9", 14 python_version = "3.9.13", 15) 16 17load("@rules_python//python:pip.bzl", "pip_parse") 18 19pip_parse( 20 # (Optional) You can set an environment in the pip process to control its 21 # behavior. Note that pip is run in "isolated" mode so no PIP_<VAR>_<NAME> 22 # style env vars are read, but env vars that control requests and urllib3 23 # can be passed 24 # environment = {"HTTPS_PROXY": "http://my.proxy.fun/"}, 25 name = "pypi", 26 27 # Requirement groups allow Bazel to tolerate PyPi cycles by putting dependencies 28 # which are known to form cycles into groups together. 29 experimental_requirement_cycles = { 30 "sphinx": [ 31 "sphinx", 32 "sphinxcontrib-qthelp", 33 "sphinxcontrib-htmlhelp", 34 "sphinxcontrib-devhelp", 35 "sphinxcontrib-applehelp", 36 "sphinxcontrib-serializinghtml", 37 ], 38 }, 39 # (Optional) You can provide extra parameters to pip. 40 # Here, make pip output verbose (this is usable with `quiet = False`). 41 # extra_pip_args = ["-v"], 42 43 # (Optional) You can exclude custom elements in the data section of the generated BUILD files for pip packages. 44 # Exclude directories with spaces in their names in this example (avoids build errors if there are such directories). 45 #pip_data_exclude = ["**/* */**"], 46 47 # (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that 48 # acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.: 49 # 1. Python interpreter that you compile in the build file (as above in @python_interpreter). 50 # 2. Pre-compiled python interpreter included with http_archive 51 # 3. Wrapper script, like in the autodetecting python toolchain. 52 # 53 # Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain. 54 python_interpreter_target = "@python_3_9_host//:python", 55 56 # (Optional) You can set quiet to False if you want to see pip output. 57 #quiet = False, 58 requirements_lock = "//:requirements_lock.txt", 59 requirements_windows = "//:requirements_windows.txt", 60) 61 62load("@pypi//:requirements.bzl", "install_deps") 63 64# Initialize repositories for all packages in requirements_lock.txt. 65install_deps() 66