Skip to content

Dev dependencies and testonly packages #228

@m-pilia

Description

@m-pilia

Hi! Currently rules_pycross with lock_import allows to import development groups (e.g. with the development_groups argument). Would it be possible to make it so that targets coming from an imported dev dependency group are testonly in Bazel?

For instance, let's pretend we have a uv lockfile generated from a pyproject.toml that looks like this

[project]
...
dependencies = ["prod_dep_1", "prod_dep_2"]

[dependency-groups]
dev = ["dev_dep"]

And then we import it with lock_import

lock_import.import_uv(
    lock_file = "//:uv.lock",
    project_file = "//:pyproject.toml",
    repo = "my_deps",
    development_groups = ["dev"],
    ...
)

This will generate Bazel targets like

@my_deps://prod_dep_1
@my_deps://prod_dep_2
@my_deps://dev_dep

Would be interesting if @my_deps://dev_dep was testonly so that it cannot be accidentally added as a dependency of a non-test target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions