Skip to content

Commit

Permalink
Fix poetry_requirements handling of python. (pantsbuild#12278)
Browse files Browse the repository at this point in the history
We now skip this entry since it is not representative of an actual
third party distribution requirement.

Fixes pantsbuild#12276
  • Loading branch information
jsirois authored Jul 4, 2021
1 parent 38780c5 commit 2a496aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/python/pants/backend/python/macros/poetry_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ def parse_pyproject_toml(toml_contents: str, file_path: str) -> set[Requirement]
)
)
dependencies = poetry_vals.get("dependencies", {})
# N.B.: The "python" dependency is a special dependency required by Poetry that only serves to
# constraint the python interpreter versions the project works with; so we skip that.
# See: https://python-poetry.org/docs/pyproject/#dependencies-and-dev-dependencies
dependencies.pop("python", None)

dev_dependencies = poetry_vals.get("dev-dependencies", {})
if not dependencies and not dev_dependencies:
logger.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def test_parse_multi_reqs() -> None:
"""
retval = parse_pyproject_toml(toml_str, "/path/to/file")
actual_reqs = {
Requirement.parse("python<4.0.0,>=3.8"),
Requirement.parse("junk@ https://github.com/myrepo/junk.whl"),
Requirement.parse("poetry@ git+https://github.com/python-poetry/[email protected]"),
Requirement.parse('requests<3.0.0,>=2.25.1; python_version > "2.7"'),
Expand Down

0 comments on commit 2a496aa

Please sign in to comment.