Skip to content

Commit 1b29701

Browse files
jaracoclaude
andcommitted
Select the top-level pyproject.toml when reading build requirements
pip 26.2.1 builds with flit_core and its sdist now ships a second pyproject.toml under build-project/ that has no [build-system] table. _read_pyproject grabbed the first basename match (the build-project one), so build_deps found no build requirements, flit-core was never installed, and the --no-build-isolation build failed with "BackendUnavailable: Cannot import 'flit_core.buildapi'". Select the shallowest match instead, i.e. the project's own {name}-{version}/pyproject.toml. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent bb1b381 commit 1b29701

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎setuptools/tests/integration/test_pip_install_sdist.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,15 @@ def build_deps(package, sdist_file):
215215

216216

217217
def _read_pyproject(archive):
218-
contents = (
219-
archive.get_content(member)
218+
members = [
219+
member
220220
for member in archive
221221
if os.path.basename(archive.get_name(member)) == "pyproject.toml"
222-
)
223-
return next(contents, "")
222+
]
223+
if not members:
224+
return ""
225+
# An sdist may contain nested pyproject.toml files (e.g. pip ships a
226+
# ``build-project/`` helper). The project's own build metadata lives in the
227+
# top-level ``{name}-{version}/pyproject.toml``, i.e. the shallowest one.
228+
top = min(members, key=lambda m: archive.get_name(m).count("/"))
229+
return archive.get_content(top)

0 commit comments

Comments
 (0)