[BUG] Forcing Bazel to use Python3 in my Virtual Env?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
I have followed the instructions in Python Bazel, and added the following to my workspace:
http_archive(
name = "pybind11_bazel",
strip_prefix = "pybind11_bazel-master",
urls = ["https://github.com/pybind/pybind11_bazel/archive/refs/heads/master.zip"],
)
# We still require the pybind library.
http_archive(
name = "pybind11",
build_file = "@pybind11_bazel//:pybind11.BUILD",
strip_prefix = "pybind11-2.6.2",
urls = ["https://github.com/pybind/pybind11/archive/v2.6.2.tar.gz"],
)
load("@pybind11_bazel//:python_configure.bzl", "python_configure")
python_configure(name = "local_config_python")
My project now uses Pybind as follows:
cc_library(
name = "PerceptionPybind",
srcs = ["pybind/PerceptionPybind.cpp"],
deps = [
"@pybind11",
#"//src:common",
],
)
It generates the appropirate .so file, but I can only import it in Python2 and not Python3! Why is it set to Python2, how can i set it in bazel to a different version of Python? Perhaps one in my virtual env?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the workspace configuration using python_configure and the PerceptionPybind cc_library shown in the issue, with the virtual-environment Python 3 interpreter. Check which interpreter the generated .so targets and compare imports under Python 2 and Python 3; done means the binding imports successfully in the requested Python 3 environment and the configuration path is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100