quaint-telephone-89068
07/30/2026, 10:15 PMpoetry_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:
[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:
poetry_requirements(
name = "poetry",
dependency_groups = ["main", "special"]
)
pants.toml:
[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