4 ms·
How is that possible? Is nixpkgs an input to the Python derivation? Or do packagers "hard code" a value every time they modify the Python build code? Automated
by mbakke 3y ago
How is that possible? Is nixpkgs an input to the Python derivation? Or do packagers "hard code" a value every time they modify the Python build code? Automated tooling that sets it after pull requests? Something else? :-)
- Smaug123 3y agoGCC respects SOURCE_DATE_EPOCH, and Nixpkgs has specific support for setting that environment variable: https://github.com/NixOS/nixpkgs/blob/92fdbd284c262f3e478033e4b41029dc160b7812/pkgs/build-support/setup-hooks/set-source-date-epoch-to-latest.sh#L12 https://github.com/NixOS/nixpkgs/blob/92fdbd284c262f3e478033... (although I haven't proved that this is actually how it works for cpython's build). Irrelevant spelunking details follow: That string is output by cpython to contain the contents of the __DATE__ C macro (https://github.com/python/cpython/blob/fa35b9e89b2e207fc8bae9eb0284260d0d922e7a/Modules/main.c#L192 https://github.com/python/cpython/blob/fa35b9e89b2e207fc8bae... which calls to https://github.com/python/cpython/blob/fa35b9e89b2e207fc8bae9eb0284260d0d922e7a/Modules/getbuildinfo.c#L45 https://github.com/python/cpython/blob/fa35b9e89b2e207fc8bae... which uses the __DATE__ macro at https://github.com/python/cpython/blob/fa35b9e89b2e207fc8bae9eb0284260d0d922e7a/Modules/getbuildinfo.c#L14 https://github.com/python/cpython/blob/fa35b9e89b2e207fc8bae... ). Cpython is defined in nixpkgs at https://github.com/NixOS/nixpkgs/blob/92fdbd284c262f3e478033e4b41029dc160b7812/pkgs/development/interpreters/python/cpython/default.nix https://github.com/NixOS/nixpkgs/blob/92fdbd284c262f3e478033... which I imagine (but haven't proved) uses GCC.
- mbakke 3y agoThank you! Setting SOURCE_DATE_EPOCH to the most recent file timestamp found in the source input is a clever hack.
- oever 3y ago2023-04-04T22:10:32 is the timestamp of Python-3.10.11/Misc/NEWS from https://www.python.org/ftp/python/3.10.11/Python-3.10.11.tar.xz https://www.python.org/ftp/python/3.10.11/Python-3.10.11.tar...
- raboof 3y agoThe source for the cpython build is the release tarball (https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/cpython/default.nix#L155 https://github.com/NixOS/nixpkgs/blob/master/pkgs/developmen...). In that case, NixOS sets SOURCE_DATE_EPOCH (which I suspect will be picked up by the python build) to the latest timestamp found in that archive (https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/set-source-date-epoch-to-latest.sh https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-supp...)