<#23591 Add `dependency_groups` to `poetry_require...
# github-notifications
q
#23591 Add `dependency_groups` to `poetry_requirements()`. Issue created by originalrkk Is your feature request related to a problem? Please describe. The
poetry_requirements()
BUILD rule imports the entirety of Poetry requirements. We would like to be able to restrict which dependency groups are included in that. (Our use case is specific; I can go into more detail about why we do this, if you need it, but suffice it to say, it would be a great help.) Describe the solution you'd like The proposal is that when
dependency_groups
is specified, ONLY dependencies from those groups are resolved. A very contrived example... pyproject.toml:
Copy code
[tool.poetry.dependencies]
pandas = "2.2.3"
mlflow = { version = "3.14.0", optional = true }
dagster = { version = "1.12.22", optional = true }

[tool.poetry.group.special.dependencies]
mlflow = "3.14.0"

[tool.poetry.group.another.dependencies]
dagster = "1.12.22"
BUILD:
Copy code
poetry_requirements(
    name = "poetry",
    dependency_groups = ["main", "special"]
)
pants.toml:
Copy code
[python]
interpreter_constraints = ["CPython==3.11.14"]
enable_resolves = true
resolves = { python-default = "python-default.lock" }
Then,
pants generate-lockfiles
would build
python-default.lock
with
pandas
and
mlflow
but NOT
dagster
. I think this should be a pretty small tweak to src/python/pants/backend/python/macros/poetry_requirements.py -- I could propose a PR if you'd be willing to accept it. pantsbuild/pants