I need to ship a compiled version of a python script and be able to prove (using a hash) that the compiled file is indeed the same as the original one.
What we use so far is a simple:
find . -name "*.py" -print0 | xargs -0 python2 -m py_compile
The issue is that this is not reproducible (not sure what are the fluctuating factors but 2 executions will not give us the same .pyc for the same python file) and forces us to always ship the same compiled version instead of being able to just give the build script to anyone to produce a new compiled version.
Is there a way to achieve that?
Thanks
.pyc
s you've still got to fight zips' inclusion of file permissions, file order, and file modification timestamps. See github.com/bboe/deterministic_zip and Barriers to deterministic, reproducible zip files by Mark Rushakoff (2014) for more details. – Braud