【问题标题】:Using Pybind with Bazel but setting Python Path?将 Pybind 与 Bazel 一起使用但设置 Python 路径?
【发布时间】:2021-09-25 04:19:17
【问题描述】:

我正在尝试将 Pybind 与 Bazel 一起使用,并且我一直遵循以下说明: https://github.com/pybind/pybind11_bazel

一切正常,我可以通过工作区中的以下命令强制它使用 Python3:

python_configure(name = "local_config_python", python_version = "3")

但是,关于如何在虚拟环境中使用特定 python 的说明完全不清楚

这个文件在这里https://github.com/pybind/pybind11_bazel/blob/master/python_configure.bzl 说我们必须设置两个变量:

"""Repository rule for Python autoconfiguration.
`python_configure` depends on the following environment variables:
  * `PYTHON_BIN_PATH`: location of python binary.
  * `PYTHON_LIB_PATH`: Location of python libraries.
"""

我设置了它们,但它实际上并不尊重这些值。我如何才能真正传递这些变量,也许是在我的cc_library 命令中。是否有 API 可以在我的工作区中设置 Python 路径?

【问题讨论】:

    标签: python bazel pybind11


    【解决方案1】:

    您可以尝试将这两个作为 action_env 添加到 .bazelrc 中:

    build --action_env=PYTHON_BIN_PATH=xxx
    build --action_env=PYTHON_LIB_PATH=xxx
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-07
      • 1970-01-01
      • 2017-09-30
      • 2011-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多