37 questions
0
votes
0
answers
30
views
Bazel oci_python_image example doesn't build when adding new Python dependency
I'm new to Bazel Python, so trying to follow the examples in https://github.com/aspect-build/bazel-examples/tree/main/oci_python_image.
The oci_python_image example builds and runs well without any ...
0
votes
1
answer
96
views
What characters are allowed in the file name (Focus equal '=')?
I want to pass a folder as a dependency for a py_test in Bazel. This contains file names with the special character '=', such as 'equal=.txt'. I receive a terminal print that the file could not be ...
2
votes
1
answer
229
views
bazel build and run grpc server with python
I am trying to setup a larger bazel infrastructure to
Create .py files from a .proto file for gRPC using rules_proto_grpc_python
Run the server code that implements the interfaces defined in 1 via a ...
1
vote
0
answers
125
views
How to integrate VSCode debugger for Python Bazel projects without altering source code?
I have a monorepo project built with Bazel and I'm trying to integrate VSCode debuggers directly with Python targets I'm running.
There is a similar question that helps solve the problem here: How to ...
0
votes
0
answers
54
views
Bazel python interpreter commandline flags
How to make a py_binary target that accepts interpreter flags such as -OO and -W?
I want the bazel_binary to create an executable that runs python -OO -W main.py.
py_binary(
name="main",
...
0
votes
1
answer
91
views
How do I include a cmake target as a dependency in a py_library target? (tiny-cuda-nn)
I'm trying to wrap tiny-cuda-nn with bazel to include as a dependency for other projects. This is a cmake project, but it has bindings for Python. The conventional way to install this would be with a ...
1
vote
0
answers
430
views
Build a docker image for Python with Bazel Docker OCI
I’m working on a project that involves building Docker images using Python. I came across an example that uses the py_oci_image rule to construct an OCI image. Unfortunately, the example relies on ...
0
votes
1
answer
153
views
Different Python versions for different Bazel targets?
I have many py_library, py_binary and py_test targets.
Some of these must run against 3.9.16 (constraint outside of my control) and others use 3.10.6 (in order to get more recent features).
In my ...
0
votes
1
answer
418
views
How do I provide a py_binary's runfiles to a C toolchain in Bazel
I am trying to write a compiler, well, a Python wrapper for Clang that does some platform specific stuff in Bazel. I have created a MRE where I can reproduce my problem here: https://github.com/...
1
vote
1
answer
314
views
Issue Running Python Application with Bazel - ImportError with NumPy C-Extensions
I have a Python project which I am building and running with Bazel. The project includes dependencies such as flask, transformers, and numpy. When I attempt to run my application using Bazel, I ...
1
vote
0
answers
208
views
is there a way to run bazel tests in required sequence?
how to enforce bazel test targets to run in specific order on CI builds? because test results of one depends on another tetss results?
I have four targets init,up,down,rm and I want to run the tests ...
0
votes
0
answers
1k
views
How to use an installed requirement in bazel BUILD file?
I am creating a new bazel workspace for a python codebase. The codebase has multiple folders with respective BUILD files. Each of the BUILD file has different external dependencies. These external ...
6
votes
2
answers
2k
views
Bazel cross platform build fails with "Unable to find a CC toolchain using toolchain resolution."
I have a python binary that I build with bazel on Mac. Now, I want to create the binary for linux for deployment.
I am following this instruction.
I added
platform(
name = "linux_x86",
...
2
votes
1
answer
1k
views
binary file not found when running bazel oci_image on local docker
I have a bazel project (monorepo), that has some go and python code. I use bazel for building. For each of these, I want to create separate container. For creating python image, I am following this ...
2
votes
1
answer
209
views
Bazel - How to create Deps for a Rule from dynamic list of targest directories
I want to create deps in a rule in Bazel that will be dynamic and not hardcoded, from a list of directories.
Here is the file structure:
| //plugins_folder
├── code0.py
├── BUILD
├── plugin1
| ├──...
0
votes
1
answer
38
views
Can I create a BUILD file that can reference and run several tests?
I have a python project with unit tests (unittest module) organized like this:
./WORKSPACE
./test/topic_a/BUILD
./test/topic_a/class_name_a_test.py
./test/topic_b/BUILD
./test/topic_b/...
0
votes
1
answer
354
views
Visibility of py_library targets in sub-folders
I'm trying to add a custom build rule that will automatically add all the targets (python files) in each sub-folder to the dependencies for a py_binary in a BUILD file.
Here is the folder structure of ...
2
votes
1
answer
237
views
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 ...
1
vote
0
answers
453
views
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 ...
1
vote
2
answers
1k
views
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....
1
vote
1
answer
1k
views
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:...
3
votes
1
answer
3k
views
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 ...
1
vote
1
answer
421
views
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 ...
2
votes
0
answers
825
views
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 ...
0
votes
2
answers
1k
views
Bazel: install a python dependency for a genrule
I am writing a Bazel macro for uploading python wheels to PyPI. In order to upload the .whl file to PyPI, I'm calling twine as the last step of my macro. Twine is a python package, and it looks like ...
3
votes
0
answers
2k
views
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, ...
0
votes
1
answer
210
views
Bazel, python: moving tests breaks imports in a pip_requirement
I am trying to move a large project to using Bazel, and I am starting small. I have found a small wrapper around pydantic in our project, and I am trying to "bazelify" that first.
The ...
0
votes
0
answers
227
views
Nested Python libraries
I am getting started with Bazel, and I am looking towards a Python monorepo. I would like to have, say, a subtree with "projects", that is something that can be deployed or run, and a ...
2
votes
0
answers
164
views
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 ...
0
votes
0
answers
134
views
NameError with extend_path using Bazel
I am trying to make a python program using bazel. When running the following snippet of code:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
I am given the following error:
...
5
votes
2
answers
2k
views
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 ...
2
votes
1
answer
3k
views
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("@...
0
votes
2
answers
1k
views
How to load multiple dependencies in py3_image bazel rule
I recently started working with bazel so admittedly, have little knowledge of bazel intricacies. I'm using bazel to generate docker images but I want to use multiple deps inside the py3_image rule.
I ...
3
votes
1
answer
2k
views
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 ...
0
votes
2
answers
9k
views
bazel logging inside of a BUILD file
Hi I want to see what is being passed to a rule that is defined in a rules.bzl file. So I would like to add just a logging statement inside of either the BUILD file or the rules.bzl file just to see ...
5
votes
3
answers
10k
views
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
...
4
votes
1
answer
1k
views
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 --...