Skip to content

Commit e9e227d

Browse files
committed
feat(cli): fallback to build-in poetry-core on build
1 parent 8f95399 commit e9e227d

File tree

8 files changed

+43
-0
lines changed

8 files changed

+43
-0
lines changed

src/poetry/console/commands/build.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ def _requires_isolated_build(self) -> bool:
9191
9292
:returns: True if an isolated build is required, False otherwise.
9393
"""
94+
if not self._has_build_backend_defined():
95+
self.io.write_error_line(
96+
"<warning>WARNING: No build backend defined. Please define one in the pyproject.toml.\n"
97+
"Fallback to the build-in `poetry-core` version.\n"
98+
"This warning will turn into an error in the future.\n"
99+
"More details can be found at https://python-poetry.org/docs/main/libraries/#packaging</>"
100+
)
101+
return False
102+
94103
if (
95104
self.poetry.package.build_script
96105
or len(self.poetry.build_system_dependencies) != 1
@@ -114,6 +123,9 @@ def _get_builder(self) -> Callable[..., None]:
114123

115124
return self._build
116125

126+
def _has_build_backend_defined(self) -> bool:
127+
return "build-backend" in self.poetry.pyproject.data.get("build-system", {})
128+
117129
def build(self, options: BuildOptions) -> int:
118130
if not self.poetry.is_package_mode:
119131
self.io.write_error_line(

tests/console/commands/test_build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ def test_prepare_formats(fmt: str | None, expected_formats: list[str]) -> None:
269269
("multiple_build_deps", True),
270270
("no_core", True),
271271
("core_from_git", True),
272+
("no_build_system", False),
273+
("no_build_backend", False),
272274
],
273275
)
274276
def test_requires_isolated_build(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
My Package
2+
==========
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[project]
2+
name = "simple-project"
3+
version = "1.2.3"
4+
description = "Some description."
5+
authors = [
6+
{ name = "Poetry Contributors", email = "[email protected]" }
7+
]
8+
license = { text = "MIT" }
9+
readme = "README.md"
10+
keywords = ["packaging", "dependency", "poetry"]
11+
requires-python = ">=3.4"
12+
13+
[build-system]
14+
requires = ["poetry-core>=1.1.0a7"]

tests/fixtures/build_systems/no_build_backend/simple_project/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
My Package
2+
==========
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[project]
2+
name = "simple-project"
3+
version = "1.2.3"
4+
description = "Some description."
5+
authors = [
6+
{ name = "Poetry Contributors", email = "[email protected]" }
7+
]
8+
license = { text = "MIT" }
9+
readme = "README.md"
10+
keywords = ["packaging", "dependency", "poetry"]
11+
requires-python = ">=3.4"

tests/fixtures/build_systems/no_build_system/simple_project/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)