Skip to content

Reproducible installs #5648

@ntninja

Description

@ntninja

What's the problem this feature will solve?

Reproducible installations. Currently when running pip install all relevant Python packages are installed into their respective and Python bytecode file are generated appropriately. Unfortunately these files are not reproducible (their contain the timestamps of the files they were generated for) and will therefor cause filesystem images they were created for to be non-reproducible as well.

Describe the solution you'd like
With Python 3.7 and PEP-552 a new and clean solution for this problem is now finally visible on the horizion.
Basically the call to py_compile.compile in PIP should be enhanced like this:

py_compile.compile(…, invalidation_mode=py_compile.PycInvalidationMode.UNCHECKED_HASH)

Since I'm guessing that PIP devs don't want to do this for all installations – there is no good reason IMHO, just assuming – another command-line flag will be required that allows one to the installation as reproducible as possible by enabling this flag.
(For full reproducibility installed shared libraries would require their timestamps to be zeroed as well, but I don't see how PIP can be any help in this currently.)

If the PIP team is willing to enable this by default, then it should only be enabled for non-editable system installs. Otherwise people will be surprised that their Python source changes are ignored by the interpreter.

My main (personal) use-case currently is docker-image-rebuilder: It runs a full docker build procedure then hashes the resulting filesystem and publishes the new version if there were any changes. PEP-552 also mentions build systems like Bazel and just about any Linux-distro as its use-cases. Most of these likely don't use PIP for gathering packages through.

Alternative Solutions
Since there are other non-reproducible files generated as well, I resort to filepath filtering rules for skipping this problem like "**/__pycache__/*.pyc" right now.

Additional context
Reproducible Builds (and, by extension, installs as well) are the future! 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions