Skip to content

Add Poetry macros to generate Python requirements and constraints #10655

@Eric-Arellano

Description

@Eric-Arellano

Some orgs use Poetry for dependency management because it has an excellent resolver and lockfile support. While they can translate from Poetry into the pip/Pex world of requirements.txt and constraints.txt, this requires running poetry export. Pants can automate some of that via macros, similar to the python_requirements() macro converting requirements.txt into python_requirement_library targets.

We want to distinguish between the high-level pyproject.toml, where the dependencies you want are declared, vs. poetry.lock, where all transitive deps are used. The former should be used to generate python_requirement_library targets, which get used for things like dependency inference. The latter should be used for a constraints file.

Strawman design:

# BUILD
poetry_requirements(
  pyproject="pyproject.toml",   # the default
  lock="poetry.lock",  # the default
  module_mapping={"my_dist": ["module1"]},   # if you want augment Pants's default module mapping
)

Relates to #11710 for better Pipenv support.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions