Skip to content

Conversation

neutrinoceros
Copy link

@neutrinoceros neutrinoceros commented Sep 14, 2025

Summary of changes

This allows build_ext.finalize_options to be called more than once without crashing. This is helpful in h5py and yt where we cannot really finalize options of this class before needing side effects (which live in the run method, as recommended).

I'm opening as a draft and without a test for now because I'm running out of time but I'll make sure to add one before opening for review.

Pull Request Checklist

@neutrinoceros neutrinoceros force-pushed the enh/build-ext-finalize-options-idempotency branch from cea9987 to f95a3cb Compare September 14, 2025 21:12
@neutrinoceros neutrinoceros changed the title ENH: improve idempotency in distutils.build_ext.finalize_options ENH: improve resiliency in distutils.build_ext.finalize_options Sep 14, 2025
@neutrinoceros neutrinoceros force-pushed the enh/build-ext-finalize-options-idempotency branch from f95a3cb to 472d8fb Compare September 14, 2025 21:18
@neutrinoceros neutrinoceros marked this pull request as ready for review September 14, 2025 21:18
if self.undef:
self.undef = self.undef.split(',')

if self.swig_opts is None:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case the bug isn't obvious: this if/else fork originally assumed that self.swig_opts could be either None or str, but it immediately binds it to a list, so it fails on the second pass with AttributeError: list has no attribute 'split'.

@neutrinoceros neutrinoceros force-pushed the enh/build-ext-finalize-options-idempotency branch from 472d8fb to b3d1e54 Compare September 15, 2025 09:48
@neutrinoceros neutrinoceros changed the title ENH: improve resiliency in distutils.build_ext.finalize_options ENH: improve resiliency in distutils.build_ext.finalize_options Sep 15, 2025
@neutrinoceros neutrinoceros force-pushed the enh/build-ext-finalize-options-idempotency branch from 4005da7 to 6c72bfb Compare September 15, 2025 09:59
@neutrinoceros neutrinoceros marked this pull request as draft September 15, 2025 10:14
@neutrinoceros neutrinoceros force-pushed the enh/build-ext-finalize-options-idempotency branch from 6c72bfb to e3857b0 Compare September 15, 2025 10:16
@neutrinoceros neutrinoceros marked this pull request as ready for review September 15, 2025 10:16
@neutrinoceros neutrinoceros force-pushed the enh/build-ext-finalize-options-idempotency branch 2 times, most recently from bb76220 to 6f8cada Compare September 15, 2025 10:19
@neutrinoceros neutrinoceros changed the title ENH: improve resiliency in distutils.build_ext.finalize_options BUG: improve resiliency in distutils.build_ext.finalize_options Sep 15, 2025
@neutrinoceros neutrinoceros force-pushed the enh/build-ext-finalize-options-idempotency branch from 6f8cada to 4595b98 Compare September 15, 2025 11:58
@neutrinoceros neutrinoceros changed the title BUG: improve resiliency in distutils.build_ext.finalize_options BUG: fix a bug where calling distutils.build_ext.finalize_options more than once would raise an exception Sep 15, 2025
@neutrinoceros
Copy link
Author

neutrinoceros commented Sep 15, 2025

this evolved into 2 separate bug fixes, so I split the second one out into #5084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant