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
werkzeug: patch reloader to find nix wrapped python scripts #33094
Conversation
Actually, because the script is being given a shebang, it should not be run anymore like |
Well; I'm not sure that Werkzeug is in the wrong here. Other than reassigning the value in python, I'm not sure it is possible to get
https://docs.python.org/3/library/sys.html#sys.argv I'm happy to change this patch to check the |
Sphinx had made the same mistake a while ago |
Ah OK; I'll send a patch upstream and backport it here |
cross reference to upstream: pallets/werkzeug#1242 |
Fix merged upstream |
I'm reverting this in Werkzeug due to the number of unintended side effects of this change. |
Fixes #33093
Motivation for this change
Currently, the werkzeug will crash if the entrypoint is wrapped by Nix (for example;
This commit adds a patch to fix this. This patch is quite Nix specific; and therefore would not make sense to upstream.
An alternate way to fix this would be to stop Nix from changing the
sys.argv[0]
value when wrapping python scripts. However, I assume that thesys.argv[0]
reassignment happens for a reason; and it is simple to patch werkzeug.How to test
This can be tested using Flask.
Create a script
main.py
:Then run it using Flask:
When using the old version; this will crash during startup (as descried in #33093).
When using the patch; this will run and not crash. The reloader will as intended.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)