Skip to content

Commit 13be4df

Browse files
committed
fix: propagate exceptions in Bootstrapper._build_sdist to fail on sdist build errors
Previously, _build_sdist() would catch and log all exceptions, causing the build to continue even if building the source distribution failed. This could result in undefined or misleading behavior. Now, exceptions are allowed to propagate, ensuring that build failures are reported and handled properly. Fixes #637 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
1 parent 1699e54 commit 13be4df

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

src/fromager/bootstrapper.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -323,32 +323,20 @@ def _build_sdist(
323323
sdist_root_dir: pathlib.Path,
324324
build_env: build_environment.BuildEnvironment,
325325
) -> pathlib.Path:
326-
sdist_filename: pathlib.Path | None = None
327-
try:
328-
find_sdist_result = finders.find_sdist(
329-
self.ctx, self.ctx.sdists_builds, req, str(resolved_version)
326+
find_sdist_result = finders.find_sdist(
327+
self.ctx, self.ctx.sdists_builds, req, str(resolved_version)
328+
)
329+
if not find_sdist_result:
330+
sdist_filename = sources.build_sdist(
331+
ctx=self.ctx,
332+
req=req,
333+
version=resolved_version,
334+
sdist_root_dir=sdist_root_dir,
335+
build_env=build_env,
330336
)
331-
if not find_sdist_result:
332-
sdist_filename = sources.build_sdist(
333-
ctx=self.ctx,
334-
req=req,
335-
version=resolved_version,
336-
sdist_root_dir=sdist_root_dir,
337-
build_env=build_env,
338-
)
339-
else:
340-
sdist_filename = find_sdist_result
341-
logger.info(
342-
f"have sdist version {resolved_version}: {find_sdist_result}"
343-
)
344-
except Exception as err:
345-
logger.warning(f"failed to build source distribution: {err}")
346-
# Re-raise the exception since we cannot continue without a sdist
347-
raise
348-
349-
if sdist_filename is None:
350-
raise RuntimeError(f"Failed to build or find sdist for {req}")
351-
337+
else:
338+
sdist_filename = find_sdist_result
339+
logger.info(f"have sdist version {resolved_version}: {find_sdist_result}")
352340
return sdist_filename
353341

354342
def _build_wheel(

0 commit comments

Comments
 (0)