Skip to content

Make wheel builds reproducible - #218

Merged
bdraco merged 3 commits into
masterfrom
fix-reproducibility-68
May 8, 2026
Merged

bdraco merged 3 commits into
masterfrom
fix-reproducibility-68

Conversation

@bdraco

@bdraco bdraco commented May 8, 2026 •

Copy link
Copy Markdown
Member

What do these changes do?

Ports the two yarl reproducibility fixes (aio-libs/yarl#1590, aio-libs/yarl#1591) to propcache; addresses the random tmp dir path leaking into compiled C-extensions.

First, adds a build-inplace PEP 517 config setting and a PROPCACHE_BUILD_INPLACE environment variable so downstream packagers can opt the wheel build into the source tree, skipping the tmp dir entirely. Editable installs still build in-tree as before.

Second, when the default tmp-dir build is used, the backend now injects -ffile-prefix-map=$tmpdir=$srcdir into CFLAGS, so debug paths in the resulting C-extensions are normalized to the original source path. This makes the default wheel build reproducible without any opt-in.

Are there changes in behavior for the user?

End users see no behavior change; default build paths now produce deterministic compiled artifacts. Downstream packagers get a new opt-in (--config-setting=build-inplace=true) for in-tree builds.

Related issue number

Closes #68

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

Adds a `build-inplace` PEP 517 config setting (and
`PROPCACHE_BUILD_INPLACE` env var) so downstream packagers can
opt out of the temporary build directory and skip the random
tmp dir name leaking into compiled artifacts.

Additionally, when wheels are built in the default temporary
directory, the build backend now injects
`-ffile-prefix-map=$tmpdir=$srcdir` into CFLAGS so paths in
compiled C-extensions are normalized to the original source
directory, making the default build reproducible too.

Closes #68
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label May 8, 2026
@bdraco
bdraco requested a review from Copilot May 8, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves wheel build reproducibility in propcache’s in-tree PEP 517 backend by avoiding random temporary build paths leaking into compiled extension artifacts, and by providing an opt-in in-tree build mode for downstream packagers.

Changes:

  • Added a new build-inplace PEP 517 config setting (and PROPCACHE_BUILD_INPLACE env var) to choose in-tree vs temporary-directory wheel builds.
  • When building from a temporary directory, injects a compiler prefix-map flag into CFLAGS to normalize embedded source paths.
  • Documented the new behavior in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packaging/pep517_backend/_cython_configuration.py Extends the build env patching to add reproducibility-related CFLAGS when building in a temp dir.
packaging/pep517_backend/_backend.py Adds build-inplace setting/env var support and threads temp-build path context into the Cython env patching.
CHANGES/218.packaging.rst Documents the new reproducible-build behavior and the build-inplace setting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGES/218.packaging.rst Resolved
- Skip `-ffile-prefix-map` on Windows since MSVC does not
  understand the flag; assert that the original source directory
  is set when the prefix map is emitted.
- Fix comma splice in the change note.
@bdraco
bdraco marked this pull request as ready for review May 8, 2026 17:02
@codspeed

codspeed Bot commented May 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing fix-reproducibility-68 (8c0afff) with master (fdacd6c)

Open in CodSpeed

@codecov

codecov Bot commented May 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.72%. Comparing base (fdacd6c) to head (8c0afff).
⚠️ Report is 50 commits behind head on master.

❌ Your project status has failed because the head coverage (97.35%) is below the target coverage (98.20%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
+ Coverage   97.63%   97.72%   +0.09%     
==========================================
  Files          17       17              
  Lines         847      881      +34     
  Branches       44       44              
==========================================
+ Hits          827      861      +34     
  Misses         12       12              
  Partials        8        8              
Flag Coverage Δ
CI-GHA 97.72% <100.00%> (+0.09%) ⬆️
MyPy 92.16% <100.00%> (+0.31%) ⬆️
OS-Linux 97.49% <ø> (ø)
OS-Windows 94.53% <ø> (ø)
OS-macOS 94.53% <ø> (ø)
Py-3.10.11 92.71% <ø> (ø)
Py-3.10.20 94.53% <ø> (ø)
Py-3.11.15 96.12% <ø> (ø)
Py-3.11.9 94.30% <ø> (ø)
Py-3.12.10 94.30% <ø> (ø)
Py-3.12.13 96.12% <ø> (ø)
Py-3.13.13 96.12% <ø> (ø)
Py-3.13.13t 96.12% <ø> (ø)
Py-3.14.4 96.10% <ø> (ø)
Py-3.14.4t 96.10% <ø> (ø)
Py-pypy3.10.16-7.3.19 78.13% <ø> (ø)
VM-macos-latest 94.53% <ø> (ø)
VM-ubuntu-latest 97.49% <ø> (ø)
VM-windows-11-arm 94.30% <ø> (ø)
VM-windows-latest 94.53% <ø> (ø)
pytest 97.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco
bdraco merged commit b88f846 into master May 8, 2026
58 of 59 checks passed
@bdraco
bdraco deleted the fix-reproducibility-68 branch May 8, 2026 17:18
PURE_PYTHON_CONFIG_SETTING = 'pure-python'
"""Config setting name toggle that is used to opt out of making C-exts."""

BUILD_INPLACE_CONFIG_SETTING = 'build-inplace'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bdraco this got injected in-between a pair of coupled config setting and env var. They are expected to be kept together.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will address when I finish working on some CVEs

aiolibsbot added a commit to aiolibsbot/frozenlist that referenced this pull request May 20, 2026
Ports the propcache reproducibility fix (aio-libs/propcache#218) to
frozenlist. Adds a `build-inplace` PEP 517 config setting (and a
`FROZENLIST_BUILD_INPLACE` env var) so downstream packagers can opt
the wheel build into the source tree, skipping the random temporary
directory entirely.

For the default temporary-directory build, the backend now injects
`-ffile-prefix-map=$tmpdir=$srcdir` into both `CFLAGS` and
`CXXFLAGS`, so the random tmp path that previously leaked into the
DWARF debug info of the compiled extension is rewritten back to the
original source directory. The extension compiles as C++
(`# distutils: language = c++`), so `CXXFLAGS` is the variable
setuptools' `customize_compiler` consults for the actual compile
step; `CFLAGS` is set too for forks that switch the language.

Fixes aio-libs#577.
aiolibsbot added a commit to aiolibsbot/frozenlist that referenced this pull request Oct 7, 2026
Ports the propcache reproducibility fix (aio-libs/propcache#218) to
frozenlist. Adds a `build-inplace` PEP 517 config setting (and a
`FROZENLIST_BUILD_INPLACE` env var) so downstream packagers can opt
the wheel build into the source tree, skipping the random temporary
directory entirely.

For the default temporary-directory build, the backend now injects
`-ffile-prefix-map=$tmpdir=$srcdir` into both `CFLAGS` and
`CXXFLAGS`, so the random tmp path that previously leaked into the
DWARF debug info of the compiled extension is rewritten back to the
original source directory. The extension compiles as C++
(`# distutils: language = c++`), so `CXXFLAGS` is the variable
setuptools' `customize_compiler` consults for the actual compile
step; `CFLAGS` is set too for forks that switch the language.

Fixes aio-libs#577.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Propcache is not reproducible

3 participants