-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
stdenv: set SOURCE_DATE_EPOCH to a value python supports #89794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
in nix-shell this value breaks the build because python's packaging refuses to build timestamps that date before 1980.
|
If there are no objections I would also fix the python docs before merging this. |
|
This is handled for python packages using the |
|
I think this has pretty big ramifications from a philosophical / purist perspective. cc @edolstra EDIT: also, this opens of the door to having to support any new archive format which may or may not support a given date range. |
Well. it is sort of annoying so and it is not added when you add python to buildInputs. |
I don't get this point. Please backup with technical reasons. |
I don't see any reason not to change it again if we have good reason to. It does not comes with any cost if time it with another stdenv rebuild. |
I'm definitely not the best to comment on this. cc @FRidh Trust me, I think it's annoying as well. I've just gotten used to including the hook to all my environments. |
|
See earlier #60446 |
|
I don't agree that we have to switch nix store dates. In a nix-shell it is enough to have SOURCE_DATE_EPOCH with the value given here set for python wheels to be build successfully. If that is all arguments against changing this value I would like to proceed to merge it. |
|
If Python packaging using Nix needs it, then it needs to propagate the hook. Just make sure you propagate from the right tools. |
So should we added it to python's setup hook? |
|
The interpreter does not do anything with wheels. The logical place would be the tools consuming or producing the wheels. When again does the issue occur, when building or installing wheels? If I am correct it is when building wheels. Thus the PEP 517 backends should propagate the hook. |
Still this is bad UX. If someone includes |
|
That's just because you use |
|
|
I don't know if it can or cannot be changed, and suggest you ask around further in the community, considering this is the |
|
I agree with @Mic92. The python issue is a major annoyance with a non-trivial fix. We can work around it with little to no cost. The fix isn't perfect, but strictly better than the status quo. |
Set the floor of SOURCE_DATE_EPOCH to 1980, as ZIP file format does not support timestamps prior to 1980, meaning zip, jar, egg, wheel all fail to be created or used. Without this fix, if one removes the hand override of SOURCE_DATE_EPOCH from py3-userpath, the build fails: ```console melange build py3-userpath.yaml --arch x86_64 --pipeline-dir ./pipelines/ -k https://packages.wolfi.dev/os/wolfi-signing.rsa.pub -r https://packages.wolfi.dev/os --source-dir ./py3-userpath/ ... 2024/09/27 14:55:33 INFO * Building wheel... name="Python Build" 2024/09/27 14:55:33 WARN Traceback (most recent call last): name="Python Build" 2024/09/27 14:55:33 WARN File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in <module> name="Python Build" 2024/09/27 14:55:33 WARN main() name="Python Build" 2024/09/27 14:55:33 WARN File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 357, in main name="Python Build" 2024/09/27 14:55:33 WARN json_out["return_val"] = hook(**hook_input["kwargs"]) name="Python Build" 2024/09/27 14:55:33 WARN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ name="Python Build" 2024/09/27 14:55:33 WARN File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 271, in build_wheel name="Python Build" 2024/09/27 14:55:33 WARN return _build_backend().build_wheel( name="Python Build" 2024/09/27 14:55:33 WARN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ name="Python Build" 2024/09/27 14:55:33 WARN File "/tmp/build-env-u9wepgmk/lib/python3.12/site-packages/hatchling/build.py", line 58, in build_wheel name="Python Build" 2024/09/27 14:55:33 WARN return os.path.basename(next(builder.build(directory=wheel_directory, versions=['standard']))) name="Python Build" 2024/09/27 14:55:33 WARN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ name="Python Build" 2024/09/27 14:55:33 WARN File "/tmp/build-env-u9wepgmk/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 155, in build name="Python Build" 2024/09/27 14:55:33 WARN artifact = version_api[version](directory, **build_data) name="Python Build" 2024/09/27 14:55:33 WARN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ name="Python Build" 2024/09/27 14:55:33 WARN File "/tmp/build-env-u9wepgmk/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 476, in build_standard name="Python Build" 2024/09/27 14:55:33 WARN record = archive.add_file(included_file) name="Python Build" 2024/09/27 14:55:33 WARN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ name="Python Build" 2024/09/27 14:55:33 WARN File "/tmp/build-env-u9wepgmk/lib/python3.12/site-packages/hatchling/builders/wheel.py", line 98, in add_file name="Python Build" 2024/09/27 14:55:33 WARN zip_info = zipfile.ZipInfo(relative_path, cast(TIME_TUPLE, self.time_tuple)) name="Python Build" 2024/09/27 14:55:33 WARN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ name="Python Build" 2024/09/27 14:55:33 WARN File "/usr/lib/python3.12/zipfile/__init__.py", line 398, in __init__ name="Python Build" 2024/09/27 14:55:33 WARN raise ValueError('ZIP does not support timestamps before 1980') name="Python Build" 2024/09/27 14:55:33 WARN ValueError: ZIP does not support timestamps before 1980 name="Python Build" 2024/09/27 14:55:33 INFO name="Python Build" 2024/09/27 14:55:33 INFO ERROR Backend subprocess exited when trying to invoke build_wheel name="Python Build" 2024/09/27 14:55:33 ERRO ERROR: failed to build package. the build environment has been preserved: 2024/09/27 14:55:33 INFO workspace dir: /tmp/melange-workspace-1020228742 2024/09/27 14:55:33 INFO guest dir: /tmp/melange-guest-609671933 2024/09/27 14:55:33 ERRO failed to build package: unable to run package py3-userpath pipeline: unable to run pipeline: exit status 1 ``` With this fix inplace it just builds correctly. This will remove many custom overrides of SOURCE_DATE_EPOCH in wolfi-dev/os, and prevent any developer hitting such pitfall. This is similar to what was done in NixOS, Debian, Python and probably other projects. In Wolfi this will fix building brand new packages, and building things directly with melange/wolfictl outside of pipelines and makefiles. See for example NixOS/nixpkgs#89794
in nix-shell this value breaks the build because python's
packaging refuses to build timestamps that date before 1980.
Motivation for this change
I am surprised this has been not done before... Tell me if I miss anything here.
cc @FRidh @jonringer
Things done
sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)nix path-info -Sbefore and after)