Set PYTHONPYCACHEPREFIX to /tmp during build phase. #442
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enables reproducible builds by discarding the
__pycache__
directories at the end of the build phase for this buildpack and all subsequent buildpacks that depend on this.This is in contrast to the current behavior of persisting the
__pycache__
directories in each buildpack's layer.It also updates the README to include this new configuration and various other minor README improvements.
We have not observed any performance issues with this configuration: discarding the
__pycache__
directories at the end of each buildpack's build phase does not seem to impact the performance of any buildpack.Background
__pycache__
directories are not reproducible and are effectively opaque to us. We cannot make them reproducible, so discarding them is the only option for reproducible builds.PYTHONPYCACHEPREFIX
environment variable was chosen to allow users to override it if needed, whereas settingPYTHONDONTWRITEBYTECODE=true
would have been harder, if not impossible, to allow users to override.os.SetEnv()
) means all subsequent buildpacks (e.g. pip, poetry, etc) will have this environment variable set automatically by the lifecycle, rather than having to implement this themselves in each buildpack.__pycache__
directories at launch time if they wish. The current launch-time behavior of defaulting to$HOME/.pycache
is unchanged.Use Cases
Enables reproducible builds in this buildpack and some subsequent buildpacks.
Fixes #426
Checklist