Skip to content

Conversation

@e-luks
Copy link

@e-luks e-luks commented Dec 20, 2025

Summary of changes

Parallel builds of extensions that share source files may write to the same object file paths under a common build directory, resulting in race conditions and non-deterministic build outputs.

Use a per-extension subdirectory within build_temp to isolate object files and ensure deterministic, parallel-safe builds.

Pull Request Checklist

Tests

I tested this change downstream at Gentoo after encountering https://bugs.gentoo.org/967476 and https://bugs.gentoo.org/945376 (packages https://pypi.org/project/librt and https://pypi.org/project/pymongo/). Since the build failures are encountered non-determinstically, i compiled both librt and pymongo as often as needed, capping the compilation attempts to 100.

  • Before the change I encountered the build failures after at most 10 compilations
  • After the change I didn't encounter the issue, compiling both librt and pymongo successfully 100 times.

e-luks added a commit to e-luks/gentoo that referenced this pull request Dec 20, 2025
…ension builds

Parallel builds of extensions that share source files may write to the same
object file paths under a common build directory, resulting in race conditions
and non-deterministic build outputs.

Use a per-extension subdirectory within build_temp to isolate object files and
ensure deterministic, parallel-safe builds.

Bug: https://bugs.gentoo.org/967476
Bug: https://bugs.gentoo.org/945376
See-also: pypa/setuptools#5132
Signed-off-by: Lukas Schmelting <lschmelting@posteo.com>
e-luks added a commit to e-luks/gentoo that referenced this pull request Dec 20, 2025
…ension builds

Parallel builds of extensions that share source files may write to the same
object file paths under a common build directory, resulting in race conditions
and non-deterministic build outputs.

Use a per-extension subdirectory within build_temp to isolate object files and
ensure deterministic, parallel-safe builds.

Bug: https://bugs.gentoo.org/967476
Bug: https://bugs.gentoo.org/945376
See-also: pypa/setuptools#5132
Signed-off-by: Lukas Schmelting <lschmelting@posteo.com>
Parallel builds of extensions that share source files may write to the same
object file paths under a common build directory, resulting in race conditions
and non-deterministic build outputs.

Use a per-extension build directory to isolate object files and ensure
deterministic, parallel-safe builds.

Bug: pypa#3942
@e-luks e-luks force-pushed the fix-extension-build-object-file-collisions branch from ca715f5 to 13c9751 Compare December 20, 2025 22:27
@Avasam
Copy link
Contributor

Avasam commented Dec 25, 2025

Please not that https://setuptools.pypa.io/en/latest/development/developer-guide.html#code-conventions-and-other-practices

the setuptools/_distutils directory should not be modified directly when contributing to the setuptools project. Instead, this directory is maintained as a separated project in https://github.com/pypa/distutils, and periodically merged into setuptools.

@e-luks
Copy link
Author

e-luks commented Dec 26, 2025

@Avasam thanks, opened pypa/distutils#393

@e-luks e-luks closed this Dec 26, 2025
@e-luks e-luks deleted the fix-extension-build-object-file-collisions branch December 26, 2025 10:43
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.

2 participants