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