Repository navigation
Make wheel builds reproducible - #218
Conversation
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
There was a problem hiding this comment.
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-inplacePEP 517 config setting (andPROPCACHE_BUILD_INPLACEenv var) to choose in-tree vs temporary-directory wheel builds. - When building from a temporary directory, injects a compiler prefix-map flag into
CFLAGSto 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.
- 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.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| 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' |
There was a problem hiding this comment.
@bdraco this got injected in-between a pair of coupled config setting and env var. They are expected to be kept together.
There was a problem hiding this comment.
Will address when I finish working on some CVEs
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.
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.
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-inplacePEP 517 config setting and aPROPCACHE_BUILD_INPLACEenvironment 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=$srcdirinto 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