Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: limit build-system to current major version of poetry-core by default #9812

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/poetry/layouts/layout.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import importlib.metadata

from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any

from packaging.utils import canonicalize_name
from poetry.core.constraints.version import Version
from poetry.core.utils.helpers import module_name
from poetry.core.utils.patterns import AUTHOR_REGEX
from tomlkit import inline_table
Expand Down Expand Up @@ -41,8 +44,16 @@
[tool.poetry.group.dev.dependencies]
"""

BUILD_SYSTEM_MIN_VERSION: str | None = None
BUILD_SYSTEM_MAX_VERSION: str | None = None
poetry_core_version = Version.parse(importlib.metadata.version("poetry-core"))

BUILD_SYSTEM_MIN_VERSION: str | None = Version.from_parts(
major=poetry_core_version.major,
minor=poetry_core_version.minor if poetry_core_version.major == 0 else 0,
patch=poetry_core_version.patch
if (poetry_core_version.major, poetry_core_version.minor) == (0, 0)
else 0,
).to_string()
BUILD_SYSTEM_MAX_VERSION: str | None = poetry_core_version.next_breaking().to_string()


class Layout:
Expand Down
13 changes: 13 additions & 0 deletions tests/console/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess
import sys
import textwrap

from pathlib import Path
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -95,6 +96,14 @@ def test_noninteractive(
assert 'name = "my-package"' in toml_content
assert '"pytest (>=3.6.0,<4.0.0)"' in toml_content

expected_build_system = textwrap.dedent("""
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"
""")

assert expected_build_system in toml_content


def test_interactive_with_dependencies(
tester: CommandTester, repo: TestRepository
Expand Down Expand Up @@ -148,6 +157,10 @@ def test_interactive_with_dependencies(

[tool.poetry.group.dev.dependencies]
pytest = "^3.6.0"

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"
"""

assert expected in tester.io.fetch_output()
Expand Down
Loading