-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
python: don't use keep for hooks, so they will be spliced #228139
base: master
Are you sure you want to change the base?
Conversation
13115fe
to
6659658
Compare
26007de
to
ac0cf11
Compare
@Ericson2314 maybe made them not splice to work around #211340
|
`lib.extends hooks pythonPackagesFun` includes python which we want to splice what this fixes: ``` nix-repl> lib.elemAt pkgsCross.aarch64-multiplatform.python3Packages.xpybutil.nativeBuildInputs 0 «derivation /nix/store/39dkb51rciw6zwg0c2c44gpmpjapddxc-python3-aarch64-unknown-linux-gnu-3.10.12.drv» ``` to ``` nix-repl> lib.elemAt pkgsCross.aarch64-multiplatform.python3Packages.xpybutil.nativeBuildInputs 0 «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv» ``` Before NixOS#194205 The keep python used to work by accident because self was passed from __splicedPackages https://github.com/NixOS/nixpkgs/pull/196052/files#diff-44ce3495c4f983ce64dd47c86a9d3e77bad210b2709c098a3806998dcd9b000bR213 But now it does not work because overrideAttrs is used on python in python-packages-base.nix Preferably we would [ splice the hooks too ](NixOS#228139) but we cannot do that until [Package sets within derivations (i.e. python3.pkgs) are not spliced](NixOS#211340) is fixed, because people often use `python3.pkgs.wrapPython` in `nativeBuildInputs` (it's correct but python3.pkgs should be python3Packages to get splicing.
Let me be totally honest here, I'm trying to remove setup hooks from nixpkgs -- starting from the The main reason why setup hooks exist is that there are pieces of data that get stuffed into It turns out that 99% of this stuff is actually knowable at Eval time. But you have to stop the avalanche before it starts. That is my mission. With all that said, @Artturin I appreciate your heroic efforts to tame the bash-monster, and we need these efforts. I just wanted to explain why it's really hard for me to motivate myself to get a deep enough understanding of problems with this stuff on one hand when I'm putting a lot of effort into being able to get rid of it on the other. It's also starting to look like I'm probably the only even-semi-qualified reviewer for a lot of this stuff. I will give it a try. Please keep pestering me. I'm going to cherry-pick this into my local tree and rebuild my 100%-cross platforms (aarch64 and mips) overnight to see what breaks. |
This is interesting. I've been wanting this as well, however, a big worry is that eval time increases. E.g., with Python we still use propagated-build-inputs. We can get rid of that in two ways, either writing a custom file linking runtime deps, or keeping track of deps in eval only and writing references out when building an env. |
Addendum: the kicker starts with this commit, which isn't part of the PR I linked (but goes immediately on top of it). This commit does not eval, but it's sort of the first milestone I've been working towards:
You definitely want to do this.
Why would it though? The evaluator still has to instantiate all ancestral dependencies either way. So the number of derivations instantiated is the same either way; the only difference is whether the list is passed as lines in
|
This breaks eval for Built on:
Edit: got up to |
Hrm, so my biggest concern is that #227902 no longer works in the presence of this PR. Also (and independently), I'm digging to find out why. Other fails are: python-frozenlisterror: builder for '/nix/store/ci6hmcv0niclbd3vqrhr1zg19x9gq25b-python3.10-frozenlist-1.3.3-aarch64-unknown-linux-gnu.drv' failed with exit code 1; last 10 log lines: > patching sources > updateAutotoolsGnuConfigScriptsPhase > updateAutotoolsGnuConfigScriptsPhase > configuring > no configure script, doing nothing > building > Executing setuptoolsBuildPhase > /nix/store/g8m639c6973656mlg2xaiqh3b88grkbs-python3.10-cython-0.29.34/bin/.cython-wrapped: /nix/store/g8m639c6973656mlg2xaiqh3b88grkbs-python3.10-cython-0.29.34/bin/cython: line 3: syntax error near unexpected token `lambda' > /nix/store/g8m639c6973656mlg2xaiqh3b88grkbs-python3.10-cython-0.29.34/bin/.cython-wrapped: /nix/store/g8m639c6973656mlg2xaiqh3b88grkbs-python3.10-cython-0.29.34/bin/cython: line 3: `import sys;import site;import functools;sys.argv[0] = '/nix/store/g8m639c6973656mlg2xaiqh3b88grkbs-python3.10-cython-0.29.34/bin/cython';functools.reduce(lambda k, p: site.addsitedir(p, k), ['/nix/store/g8m639c6973656mlg2xaiqh3b88grkbs-python3.10-cython-0.29.34/lib/python3.10/site-packages','/nix/store/ci5b14j87px5h2j83244qrdxzy9c89lc-python3-3.10.12/lib/python3.10/site-packages'], site._init_pathinfo());' > /nix/store/giycz6b15x39q4ffaabcjaimv3p57pis-stdenv-linux/setup: line 144: pop_var_context: head of shell_variables not a function context aiosignalerror: 1 dependencies of derivation '/nix/store/h0s4w0dymgg3sq2qymk9xk1qfjdalj0h-python3.10-aiosignal-1.3.1-aarch64-unknown-linux-gnu.drv' failed to build error: build of '/nix/store/wxibxw134xjkgrqxyak7llqialpm8m5a-python3.10-webencodings-0.5.1.drv' on 'ssh://[email protected]' failed: builder for '/nix/store/wxibxw134xjkgrqxyak7llqialpm8m5a-python3.10-webencodings-0.5.1.drv' failed with exit code 2 error: builder for '/nix/store/wxibxw134xjkgrqxyak7llqialpm8m5a-python3.10-webencodings-0.5.1.drv' failed with exit code 1; last 10 log lines: > patching script interpreter paths in /nix/store/7158a4001i2spia03v71jx88nkaavnkl-python3.10-webencodings-0.5.1 > stripping (with command strip and flags -S -p) in /nix/store/7158a4001i2spia03v71jx88nkaavnkl-python3.10-webencodings-0.5.1/lib > shrinking RPATHs of ELF executables and libraries in /nix/store/4qnpss02qlvap8ifwhk0s90nnn8y3s2l-python3.10-webencodings-0.5.1-dist > checking for references to /build/ in /nix/store/4qnpss02qlvap8ifwhk0s90nnn8y3s2l-python3.10-webencodings-0.5.1-dist... > patching script interpreter paths in /nix/store/4qnpss02qlvap8ifwhk0s90nnn8y3s2l-python3.10-webencodings-0.5.1-dist > Executing pythonRemoveTestsDir > Finished executing pythonRemoveTestsDir > running install tests > /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/.py.test-wrapped: /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/py.test: line 3: syntax error near unexpected token `lambda' > /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/.py.test-wrapped: /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/py.test: line 3: `import sys;import site;import functools;sys.argv[0] = '/nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/py.test';functools.reduce(lambda k, p: site.addsitedir(p, k), ['/nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/lib/python3.10/site-packages','/nix/store/fb1wnff0hgr0spxg3nrqyyrav748djcy-python3.10-attrs-22.2.0/lib/python3.10/site-packages','/nix/store/ci5b14j87px5h2j83244qrdxzy9c89lc-python3-3.10.12/lib/python3.10/site-packages','/nix/store/fmh8m17gz5sv22924wzyscmq6sjnvi0m-python3.10-iniconfig-2.0.0/lib/python3.10/site-packages','/nix/store/gfikmbv231cw767abgwym6bilpw2zqh4-python3.10-packaging-23.0/lib/python3.10/site-packages','/nix/store/yswzkw3s0qrycx66hr9265m4m6z8fja2-python3.10-pluggy-1.0.0/lib/python3.10/site-packages','/nix/store/yab91szh63mkj5mdf6xzp2x95fdl8sz8-python3.10-py-1.11.0/lib/python3.10/site-packages','/nix/store/j46b4k3z06djd451x4arkwy6b408vpyf-python3.10-tomli-2.0.1/lib/python3.10/site-packages','/nix/store/4q783kasfnf7b22rlhka87bjqqghwaxs-python3.10-exceptiongroup-1.1.0/lib/python3.10/site-packages'], site._init_pathinfo());' python-flakyerror: build of '/nix/store/h3k4r2dbpb7jvl37b2yndv9jsc4agdam-python3.10-flaky-3.7.0.drv' on 'ssh://[email protected]' failed: builder for '/nix/store/h3k4r2dbpb7jvl37b2yndv9jsc4agdam-python3.10-flaky-3.7.0.drv' failed with exit code 2 error: builder for '/nix/store/h3k4r2dbpb7jvl37b2yndv9jsc4agdam-python3.10-flaky-3.7.0.drv' failed with exit code 1; last 10 log lines: > patching script interpreter paths in /nix/store/gz768x9yvp10n8lk4hd50zggz9dybi7h-python3.10-flaky-3.7.0 > stripping (with command strip and flags -S -p) in /nix/store/gz768x9yvp10n8lk4hd50zggz9dybi7h-python3.10-flaky-3.7.0/lib > shrinking RPATHs of ELF executables and libraries in /nix/store/jlqmcqkr120m45hd2q9f8kwnvkpjl8ay-python3.10-flaky-3.7.0-dist > checking for references to /build/ in /nix/store/jlqmcqkr120m45hd2q9f8kwnvkpjl8ay-python3.10-flaky-3.7.0-dist... > patching script interpreter paths in /nix/store/jlqmcqkr120m45hd2q9f8kwnvkpjl8ay-python3.10-flaky-3.7.0-dist > Executing pythonRemoveTestsDir > Finished executing pythonRemoveTestsDir > running install tests > /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/.pytest-wrapped: /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/pytest: line 3: syntax error near unexpected token `lambda' > /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/.pytest-wrapped: /nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/pytest: line 3: `import sys;import site;import functools;sys.argv[0] = '/nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/bin/pytest';functools.reduce(lambda k, p: site.addsitedir(p, k), ['/nix/store/nlhs8d6nrdzk4kqv173gzj0igb0j7ikk-python3.10-pytest-7.2.1/lib/python3.10/site-packages','/nix/store/fb1wnff0hgr0spxg3nrqyyrav748djcy-python3.10-attrs-22.2.0/lib/python3.10/site-packages','/nix/store/ci5b14j87px5h2j83244qrdxzy9c89lc-python3-3.10.12/lib/python3.10/site-packages','/nix/store/fmh8m17gz5sv22924wzyscmq6sjnvi0m-python3.10-iniconfig-2.0.0/lib/python3.10/site-packages','/nix/store/gfikmbv231cw767abgwym6bilpw2zqh4-python3.10-packaging-23.0/lib/python3.10/site-packages','/nix/store/yswzkw3s0qrycx66hr9265m4m6z8fja2-python3.10-pluggy-1.0.0/lib/python3.10/site-packages','/nix/store/yab91szh63mkj5mdf6xzp2x95fdl8sz8-python3.10-py-1.11.0/lib/python3.10/site-packages','/nix/store/j46b4k3z06djd451x4arkwy6b408vpyf-python3.10-tomli-2.0.1/lib/python3.10/site-packages','/nix/store/4q783kasfnf7b22rlhka87bjqqghwaxs-python3.10-exceptiongroup-1.1.0/lib/python3.10/site-packages'], site._init_pathinfo());' For full logs, run 'nix log /nix/store/h3k4r2dbpb7jvl37b2yndv9jsc4agdam-python3.10-flaky-3.7.0.drv'. python3-cryptographyerror: builder for '/nix/store/k9wrb5z6gnj5xiymdjs6pzwlkq746ss7-python3.10-cryptography-40.0.1-aarch64-unknown-linux-gnu.drv' failed with exit code 1; last 10 log lines: > Python: 3.10.12 > platform: Linux-5.15.82-x86_64-with-glibc2.37 > pip: 23.0.1 > setuptools: 67.4.0.post0 > setuptools_rust: 1.5.2 > rustc: 1.70.0 (90c541806 2023-05-31) (built from a source tarball) > =============================DEBUG ASSISTANCE============================= > > error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path src/rust/Cargo.toml --target x86_64-unknown-linux-gnu --release -v --features 'pyo3/abi3-py36 pyo3/extension-module' -- --crate-type cdylib` failed with code 101 > /nix/store/giycz6b15x39q4ffaabcjaimv3p57pis-stdenv-linux/setup: line 1596: pop_var_context: head of shell_variables not a function context For full logs, run 'nix log /nix/store/k9wrb5z6gnj5xiymdjs6pzwlkq746ss7-python3.10-cryptography-40.0.1-aarch64-unknown-linux-gnu.drv'. |
useful |
as far as i can see there should be no reason to not splice the hooks wrapPython for some reason has to be not spliced because 'substitutions.pythonHost = python;' causes ``` error: output '/nix/store/li07bad6s9brxx7cf8j408631nca39ka-python3.10-chardet-5.1.0-aarch64-unknown-linux-gnu' is not allowed to refer to the following paths: /nix/store/fdqpyj613dr0v1l1lrzqhzay7sk4xg87-python3-3.10.10 ``` ericson said in NixOS#104201 (comment) that the reason they were in keep was to not splice them but before the commit which broke hook splicing (33d12e5) everything appeared to be working correctly when cross-compiling we also somehow get a correctly spliced python in nativeBuildInputs for free
Using __spliced is the easiest (maybe only) way to get the correct python here. wrapPython goes in nativeBuildInputs. By adding `substitutions.python1 = python;` to wrap-python.nix we can see that hostHost contains a python for aarch64 but not hostTarget for some reason. ``` nix-repl> p = lib.elemAt pkgsCross.aarch64-multiplatform.__splicedPackages.python3Packages.chardet.nativeBuildInputs 1 nix-repl> p.python1.__spliced { buildBuild = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; buildHost = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; buildTarget = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; hostHost = «derivation /nix/store/39dkb51rciw6zwg0c2c44gpmpjapddxc-python3-aarch64-unknown-linux-gnu-3.10.12.drv»; hostTarget = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; } ```
For whatever reason after 1 year `targetTarget` now contains cross python while in the previous commit (commit msg from it) By adding `substitutions.python1 = python;` to wrap-python.nix we can see that hostHost contains a python for aarch64 but not hostTarget for some reason. ``` nix-repl> p = lib.elemAt pkgsCross.aarch64-multiplatform.__splicedPackages.python3Packages.chardet.nativeBuildInputs 1 nix-repl> p.python1.__spliced { buildBuild = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; buildHost = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; buildTarget = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; hostHost = «derivation /nix/store/39dkb51rciw6zwg0c2c44gpmpjapddxc-python3-aarch64-unknown-linux-gnu-3.10.12.drv»; hostTarget = «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv»; } ``` NOW nix-repl> pkgsCross.aarch64-multiplatform.buildPackages.python3Packages.wrapPython.python1.__spliced { buildBuild = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; buildHost = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; buildTarget = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; hostHost = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; hostTarget = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; targetTarget = «derivation /nix/store/iqjs63kixgafzs41jkc8m8gizvjwl1lh-python3-aarch64-unknown-linux-gnu-3.12.5.drv»; } note that previously there wasn't even a `targetTarget`
fixes ``` python3.12-packaging> /nix/store/wk4c4cjrrssz3vrq3pxh04wmzd3d93y6-python-runtime-deps-check-hook.sh/nix-support/setup-hook: line 11: /nix/store/vc4xlrlswjpwfjcd1f018ykpdd3rla8i-python3-aarch64-unknown-linux-gnu-3.12.5/bin/python3.12: cannot execute binary file: Exec format error ``` `.override` discards splicing
ac0cf11
to
9bd2b9e
Compare
`wrap-python.nix` ``` passthru = { python1 = python; }; ``` ``` nix-repl> p = lib.elemAt pkgsCross.aarch64-multiplatform.flashfocus.nativeBuildInputs 1 nix-repl> p.python1.__spliced { buildBuild = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; buildHost = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; buildTarget = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; hostHost = «derivation /nix/store/iqjs63kixgafzs41jkc8m8gizvjwl1lh-python3-aarch64-unknown-linux-gnu-3.12.5.drv»; hostTarget = «derivation /nix/store/5k1b6g2qgy2a7kiis6snyidzryz6bljl-python3-3.12.5.drv»; } ```
doesn't work `pkgsCross.aarch64-multiplatform.flashfocus` ``` > /nix/store/lxmqqrafnjnjkdplvsk2yy6fx5f5g00z-python3.12-build-1.2.1/bin/.pyproject-build-wrapped: /nix/store/lxmqqrafnjnjkdplvsk2yy6fx5f5g00z-python3.12-build-1.2.1/bin/pyproject-build: line 3: syntax error near unexpected token `lambda' > /nix/store/lxmqqrafnjnjkdplvsk2yy6fx5f5g00z-python3.12-build-1.2.1/bin/.pyproject-build-wrapped: /nix/store/lxmqqrafnjnjkdplvsk2yy6fx5f5g00z-python3.12-build-1.2.1/bin/pyproject-build: line 3: `import sys;import site;import functools;sys.argv[0] = '/nix/store/lxmqqrafnjnjkdplvsk2yy6fx5f5g00z-python3.12-build-1.2.1/bin/pyproject-build';functools.reduce(lambda k, p: site.addsitedir(p, k), ['/nix/store/lxmqqrafnjnjkdplvsk2yy6fx5f5g00z-python3.12-build-1.2.1/lib/python3.12/site-packages','/nix/store/gmldyqksmb8m3q55r89plzl69i2hpn1z-python3.12-packaging-24.1/lib/python3.12/site-packages','/nix/store/h3i0acpmr8mrjx07519xxmidv8mpax4y-python3-3.12.5/lib/python3.12/site-packages','/nix/store/85r0faqh44wfff7250qxad4iif2kng05-python3.12-pyproject-hooks-1.0.0/lib/python3.12/site-packages'], site._init_pathinfo());' For full logs, run 'nix log /nix/store/dcygh555yx6sqzqrlnnd0xdq1bflycsk-python3.12-setuptools-72.1.0.drv'. error: builder for '/nix/store/4mzla40czanjwsg3swqgviyzc342j1mq-python3.12-typing-extensions-4.12.2.drv' failed with exit code 2; ```
Yeah idk what's going on, doesn't work hostHost not always correct, maybe the conditional needs tweaking |
See #211340 for prerequisite
wrapPython for some reason has to be not spliced because 'substitutions.pythonHost = python;' causes
ericson said in #104201 (comment) that the reason they were in keep was to not splice them but before the commit which broke hook splicing (33d12e5) everything appeared to be working correctly when cross-compiling
Description of changes
experimenting with hook splicing fix @amjoseph-nixpkgs
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)