1515""" initializes the bazel_rules_hdl workspace """
1616
1717load ("@bazel_skylib//:workspace.bzl" , "bazel_skylib_workspace" )
18- load ("@rules_python//python:pip.bzl" , "pip_install" )
18+ load ("@rules_python//python:pip.bzl" , "pip_parse" )
19+ load ("//dependency_support:requirements.bzl" , install_pip_deps = "install_deps" )
1920load ("//dependency_support/boost:init_boost.bzl" , "init_boost" )
2021load ("//dependency_support/pybind11:init_pybind11.bzl" , "init_pybind11" )
2122
@@ -26,26 +27,37 @@ def init(python_interpreter = None, python_interpreter_target = None):
2627 must call `init` to allow @bazel_rules_hdl to set itself up.
2728
2829 `python_interpreter` and `python_interpreter_target` are passed to
29- @bazel_rules_hdl's instance of `pip_install `. They can normally be set to
30+ @bazel_rules_hdl's instance of `pip_parse `. They can normally be set to
3031 the default None value, but if the outside workspace has a custom Python
3132 toolchain configured, these must be set, otherwise @bazel_rules_hdl will
3233 not use the right Python toolchain when installing pip dependencies.
3334
35+ If either is set, the outside workspace must also include:
36+
37+ load(
38+ "@rules_hdl_pip_deps//:requirements.bzl",
39+ rules_hdl_install_pip_deps = "install_deps",
40+ )
41+ rules_hdl_install_pip_deps()
42+
3443 Args:
3544 python_interpreter: Path to external Python interpreter to use with
36- `pip_install `. This can be an absolute path or relative to the host's
45+ `pip_parse `. This can be an absolute path or relative to the host's
3746 `PATH` environment variable.
3847 python_interpreter_target: Bazel target of a Python interpreter to build
39- to use with `pip_install `. Using `python_interpreter_target` makes it
48+ to use with `pip_parse `. Using `python_interpreter_target` makes it
4049 possible to have a hermetic Python toolchain. `python_interpreter_target`
4150 takes precedence over `python_interpreter` if both are set.
4251 """
43- pip_install (
52+ # Used only by the rules that vendor requirements.bzl
53+ pip_parse (
4454 name = "rules_hdl_pip_deps" ,
45- requirements = "@rules_hdl//dependency_support:pip_requirements.txt" ,
55+ requirements_lock = "@rules_hdl//dependency_support:pip_requirements.txt" ,
4656 python_interpreter = python_interpreter ,
4757 python_interpreter_target = python_interpreter_target ,
4858 )
59+ if (not python_interpreter ) or (python_interpreter_target != "@rules_hdl_cpython//:install/bin/python3" ):
60+ install_pip_deps ()
4961
5062 init_boost ()
5163 init_pybind11 ()
0 commit comments