Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fake timestamp in pyc-header #3007
Directly bundling pyc-files makes the build output dependent on the modification time of pyinstaller source files. This change removes that relation and re-enables deterministic builds.
I didn't find a better place to add this than here. We need low-level access to the file to change the header so it can't be done after compressing it.
PEP552 actually made this a bit harder as it changed the pyc-header format. Since we don't know the magic number for the outstanding release that adds PEP552 support, I checked for the presence of the bit-field instead:
Basically, there are three possible pyc file headers:
Since the bit-field is either 0 or 1 we can just check if that's the content of the second word to find out if this a new-style header. Of course this misses an edge-case where the pyinstaller files were last changed on 01/01/1970 around midnight but I guess we can ignore that.
I checked on test which failed with
This looks like a different problem, so I restarted the tests. We'll see.
Did you try running the test-suite on your machine? If not, please do so. Instructions are in test/README.
The errors look like this code is corrupting binary files. I missed the point that at this place, not only Python bytecode is coming along. See https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/building/api.py#L230for a list of possible item types. I assume you need to check whether this actually is Python code ("M", "m" and "s"). Please also check the loop around https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/building/api.py#L230 to ensure all the new code covers all used cases.
As an safety-belt, I suggest to check for