-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent __pycache__
directories in /layers
at build time
#426
Comments
@fg-j Can you clarify what you did to set Did you run How did you modify this variable only for build time, and not for launch time? |
I see in paketo-buildpacks/conda-env-update#189 that you modified the conda-env-update buildpack. I assume you did that for all buildpacks to test this. I assume that because you aren't setting this environment variable on the layer but just for the buildpack process itself, that this does not interfere with the launch time modifications in #352 |
@robdimsdale For most of my investigation, I used the In paketo-buildpacks/conda-env-update#189, I experimented with setting the environment variable in the buildpack code itself, since I needed to splice out the Throughout my investigation, I set the environment variable only at build time. The change should not have had any impact on the value of |
Great, super helpful, thanks. I constantly find myself confused about when the lifecycle will set an env var for build vs launch. Can you confirm (or correct) my understanding:
I appreciate that this isn't really for you to answer, but you've been spending time in this space so hopefully you can help me get an accurate mental model. Also cc @ryanmoran - is my model above of environment variables accurate? |
@robdimsdale Everything you laid out there looks correct to me. One bit of nuance is that it's possible to set the BuildEnv, LaunchEnv, ProcessLaunchEnv and SharedEnv for a given layer (see packit). So, if you want, you can decide when an environment variable should apply regardless of when the layer is present. A layer needs to be present for its environment variables to impact the build/launch env. But when a layer is present, each associated environment variable may/may not impact the environment depending on how it's been set. To give a concrete example: In the dotnet-core-sdk buildpack, we put the layer containing the SDK on the |
Ah, ok. That's helpful context. Again, mostly for my own notes: It sounds like there is a slight difference in what I was describing about setting the environment variable in the layers:
I think that what that means for the Python
For posterity, the official spec is here. |
Describe the Enhancement
Per investigation in paketo-buildpacks/python#507, when
pip
installs dependencies, it caches precompiled Python bytecode in__pycache__
directories. The bytecode isn't reproducible, because it contains timestamps. Currently, those__pycache__
directories end up in/layers
, which makes python builds non-reproducible.Possible Solution
As #352 indicated, setting
PYTHONPYCACHEPREFIX
changes the location where these cached files are stored. The environment variable should be set to some temporary location at build time so__pycache__
directories don't pollute otherwise-reproducible layers.Motivation
Exploration in paketo-buildpacks/python#507 indicates that setting
PYTHONPYCACHEPREFIX
to/tmp
at build time is sufficient to make python + pip-install image builds reproducible!The text was updated successfully, but these errors were encountered: