• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = "python39",
14    python_version = "3.9",
15)
16
17load("@python39//:defs.bzl", "interpreter")
18load("@rules_python//python:pip.bzl", "pip_parse")
19
20pip_parse(
21    # (Optional) You can set an environment in the pip process to control its
22    # behavior. Note that pip is run in "isolated" mode so no PIP_<VAR>_<NAME>
23    # style env vars are read, but env vars that control requests and urllib3
24    # can be passed
25    # environment = {"HTTPS_PROXY": "http://my.proxy.fun/"},
26    name = "pypi",
27    # (Optional) You can provide extra parameters to pip.
28    # Here, make pip output verbose (this is usable with `quiet = False`).
29    # extra_pip_args = ["-v"],
30
31    # (Optional) You can exclude custom elements in the data section of the generated BUILD files for pip packages.
32    # Exclude directories with spaces in their names in this example (avoids build errors if there are such directories).
33    #pip_data_exclude = ["**/* */**"],
34
35    # (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
36    # acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
37    # 1. Python interpreter that you compile in the build file (as above in @python_interpreter).
38    # 2. Pre-compiled python interpreter included with http_archive
39    # 3. Wrapper script, like in the autodetecting python toolchain.
40    #
41    # Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain.
42    python_interpreter_target = interpreter,
43
44    # (Optional) You can set quiet to False if you want to see pip output.
45    #quiet = False,
46    requirements_lock = "//:requirements_lock.txt",
47)
48
49load("@pypi//:requirements.bzl", "install_deps")
50
51# Initialize repositories for all packages in requirements_lock.txt.
52install_deps()
53