Questions tagged [bazel-python]
24 questions
4
votes
3 answers
How do I select the runtime in bazel for Python and pip?
I'm trying to build an app on Ubuntu 20.04, where python3 points to Python3.8, and I'm building aganist Python3.6
I have the following runtime in the same directory of WORKSPACE.
$ cat BUILD.bazel
py_runtime(
name = "python3.6",
…

Ahmed
- 2,825
- 1
- 25
- 39
4
votes
1 answer
How do you generate Python coverage in bazel?
I'm trying to generate Python coverage in bazel. I tried to run this command and an empty file was generated
$ bazelisk coverage //company/libs:foo_test
INFO: Using default value for --instrumentation_filter: "^//company/libs[/:]".
INFO: Override…

Ahmed
- 2,825
- 1
- 25
- 39
3
votes
2 answers
Creating Python zip for AWS Lambda using Bazel
I've a monorepo that contains a set of Python AWS lambdas and I'm using Bazel for building and packaging the lambdas. I'm now trying to use Bazel to create a zip file that follows the expected AWS Lambdas packaging and that I can upload to Lambda.…

Ricardo Fonseca
- 51
- 5
3
votes
1 answer
Add required dependencies to py_wheel
I am trying to create a wheel package from bazel using py_wheel. py_wheel has an option to provide the required python dependencies using the requires param. However, I don't want to provide the list of dependencies manually. Is there a way that I…

randomperson
- 31
- 1
2
votes
0 answers
Installing python packages with extras using Bazel pip_parse
I use Python Rules for Bazel to build my python projects. I use pip_parse to install pip packages, as described in the guide, but that doesn't seem to be working for packages with extras.
For example, I have the following dependency in my…

andrii
- 1,248
- 1
- 11
- 25
1
vote
2 answers
How to materialize Bazel Outputs
I am relatively new to bazel, so this is probably a relatively simple question.
I have a bunch of libraries defined in my build structure. Something like this:
/libraries
- /lib1
- BUILD
- files.py
- /lib2
- BUILD
- sub_dir
-…

felixnext
- 13
- 3
1
vote
1 answer
One entry point in WORKSPACE for managing various python project requirements
My Bazel project structure is like this
├── BUILD
├── WORKSPACE
├── example.py
├── reqs.bzl
└── requirements.txt
I have created my WORKSPACE like this
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name =…

a k
- 531
- 5
- 15
1
vote
1 answer
Bazel pip_parse results in repository not defined
Trying to build a set up Python package dependencies with rules_python per these instructions but when running bazel build I get this error:
ERROR: error loading package under directory '':
error loading package 'zzz':
Unable to find package for…

tomocafe
- 1,425
- 4
- 20
- 35
1
vote
1 answer
Generating C++ files via py_binary and genrule
I have a Python script named blob_to_cpp.py (located at scirpts/blob_to_cpp.py relative to the WORKSPACE.bazel file). The Python script takes an input file (e.g. weights/rt_alb.tza) and generates from that a C++ header (.h) and source file (.cpp)…

Vertexwahn
- 7,709
- 6
- 64
- 90
1
vote
0 answers
Code coverage for Python using Bazel 6.0.0
I want to generate a code coverage report using Bazel for a Python project (my environment: macOS Ventura, M1 arm64, Python 3.10, Bazel 6.0).
The documentation states that for this task Bazel 6.0 and a modified version of coverage.py should work.
It…

Vertexwahn
- 7,709
- 6
- 64
- 90
1
vote
0 answers
Bazel: running tests against different Python versions
I am getting to know Bazel, and I would like to be able to test the same codebase against several python versions, mostly for the purposes of safe transition to a new one.
I'm using python_register_toolchain to specify my python interpreter. I tried…

Ibolit
- 9,218
- 7
- 52
- 96
1
vote
1 answer
Bazel build file load multiple dependencies
I have a Python repo that contains two requirement files. In my WORKSPACE file, I imported both the dependencies.
requirements-1.txt:
numpy
requirements-2.txt:
scipy
WORKSPACE:
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
…

Isaac
- 155
- 9
0
votes
0 answers
Bazel python proto rules overriding "google" module
I encountered an issue with the proto rules provided by rules_python. I believe adding protos that utilizes py_proto_library will overshadow the "google" module, making relevant PIP dependencies unable to be found.
I created a repo with a simple…

Chuan Ye
- 1
- 1
0
votes
0 answers
How to deal with Bazel grpc transitive dependencies?
I tried to setup a grpc Python server using Bazel. On my Mac machine, if I load the grpc rules first before the proto rules, I can build and run the binary just fine. However, if I load the proto rules before grpc rules, I'm unable to build the…

Chuan Ye
- 1
- 1
0
votes
0 answers
Bazel, install python as root — cannot find gcc
I am working on a Bazel mvp at work, and I'm trying to run a simple build on CI. However, there are severe limitations to the environment.
I am trying to build a simple python lib and run some simple python tests. All of that works great on local…

Ibolit
- 9,218
- 7
- 52
- 96