Bazel build ERROR on ubuntu
Opened this issue · 1 comments
I am using Linux Ubuntu 22.04.3 LTS (WSL 2) on a windows 11 machine and I have python 3.10, numpy 1.26.3 and bazel 7.0.0 installed.
I modified the WORKSPACE script according to my path to python and numpy, which are respectively:
/usr/include/python3.10
/usr/local/lib/python3.10/dist-packages/numpy/core/
However, when I go in qcc/src/lib and try to build using bazel build all
I got this error:
ERROR: /home/username/qcc/WORKSPACE:1:21: //external:third_party_python: invalid label '/home/username/qcc/python.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/python.BUILD': target names may not start with '/'
ERROR: /home/username/qcc/WORKSPACE:8:21: //external:third_party_numpy: invalid label '/home/username/qcc/numpy.BUILD' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/home/username/qcc/numpy.BUILD': target names may not start with '/'
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'toolchains/jdk_build_file.bzl': no such package '@@rules_java_builtin//toolchains': error loading package 'external': Could not load //external package
SOLUTION
My solution was the following:
- in the main folder
qcc
, create a folder calledexternal
: - move
python.BUILD
andnumpy.BUILD
fromqcc
toqcc/external
- then modify the
WORKSPACE
script as follows:
new_local_repository(
name = "third_party_python",
build_file = "//external:python.BUILD",
path = "/usr/include/python3.10",
)
new_local_repository(
name = "third_party_numpy",
build_file = "//external:numpy.BUILD",
path = "/usr/local/lib/python3.10/dist-packages/numpy/core/",
)
This solved the issue for me.
Hope this was helpful, have a greate day :)