On NixOS python is patched so that if the environment variable DETERMINISTIC_BUILD is present the interpreter set the bytecode timestamps to 0. I suppose they did something similar.
Also, Debian binary packages don't ship prebuilt python bytecode, which is compiled at installation time. (just to reply to the specific example)
Sometimes by eliminating the timestamps (don't put __DATE__ and __TIME__ in C code, for instance), but when that isn't possible: