'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 have a BUILD.bazel which has python rule as follows:

load("@io_bazel_rules_docker//python3:image.bzl", "py3_image")
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
load("@custom_deps//:requirements.bzl", "requirement")

exports_files(["component.yaml"])

py3_image(
    name = "custom",
    srcs = [
        "src/payload_populator/bq_populator.py",
        "src/payload_populator/cloudsql_fetcher.py",
        "src/payload_populator/config.py",
        "src/payload_populator/SingleListing.py",
        "src/payload_populator/sql.py",
        "src/custom/browse.py",
        "src/custom/closet.py",
        "src/custom/constants.py",
        "src/custom/listing.py",
        "src/custom/util.py",
        "src/session/session.py"
    ],
    base = "@python//image",
    main = "src/payload_populator/bq_populator.py",
    visibility = ["//visibility:public"],
    deps = [
        requirement("google-cloud-bigquery"),
        requirement("google-cloud-core"),
        "//common:common_lib",
    ],
)

# https://github.com/bazelbuild/rules_docker/tree/e15c9ebf203b7fa708e69ff5f1cdcf427d7edf6f#container_push
container_push(
    name = "push_custom",
    format = "Docker",
    image = ":custom",
    registry = "gcr.io",
    repository = "rental-ds/custom",
    tag = "$(BRANCH_NAME)",
)

I have 120+ dependencies that my code relies on inside

deps = [
        requirement("google-cloud-bigquery"),
        requirement("google-cloud-core"),
        "//common:common_lib",
    ],

I don't want to list out all of them independently to use them in the code. Is there a simple way to either import all of them in one go from requirement or a way to bypass my calling of requirement("library")?

I've tried to scour Bazel docs: https://docs.bazel.build/versions/main/be/python.html

and the github page for docker-rules: https://github.com/bazelbuild/rules_docker

If I'm missing some knowledge that's obvious, please link a reference for the read as well.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source