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-wrapper: Wrap interpreter rather than script #7931
Conversation
0e6dfea
to
0d7788a
Compare
Hmm, interesting approach. It would fix issues like #7368. Do you think of any downsides? |
I haven't been able to think of any downsides. I tested on a good number of packages without finding any breakage. There are only two minor things I'm still somewhat unsure of. The first is putting the python wrapper in The second thing is the handling of EGG-INFO scripts. Should I be skipping them? Do they need to have their shebangs patched in some way? Other than that, I believe this is ready for a merge. I think it's significantly simpler and more robust than the current approach. |
Resolved conflict with current master. |
Wrapping python scripts changes sys.argv[0], so we have had to patch these scripts to set sys.argv[0] back to the right value. Doing this patching correctly is difficult, and tends to break scripts. See NixOS#7366 for an example. This implements an alternative approach in which python scripts are not wrapped at all. Instead, the python interpreter is wrapped, and the python scripts have their shebang modified to point at the wrapped python.
I've updated this to master and re-tested it, but am now running into shebang lines which are too long. I'm not sure why I didn't encounter this problem last time I tested it, but regardless this is a problem that could be fixed by #11133, if we can't find another approach. |
Any idea how this would work with alternative interpreters like IPython/Jupyter? |
@FRidh Perhaps I don't understand the question, but I can't think of any way this would impact IPython/Jupyter use, since this PR only effects executable python scripts. |
If I understand correctly you will wrap the Python interpreter, and patch the shebangs of all scripts in say /bin to use the patched interpreter. However, IPython/Jupyter resides also in /bin, and being an alternative interpreter, needs to be able to import modules in a similar way as CPython, which is currently broken when using python.buildEnv, but not when using nix-shell though). See #11147. I'm trying to see whether and how work here relates to that. If I am correct I can't just wrap everything in /bin in case this PR would get merged. |
this is broken in the same way that the current wrapping mechanism is broken, |
@FRidh would you test this with jupyter? |
@FRidh is this still relevant? If I'm informed correctly, the python infrastructure has changed significantly since this PR was created, so perhaps we can close this? Even if it is closed, the diff will stay if anyone would like to look at it later. |
@bennofs you're right, let's close this. |
A quick implementation of an alternative approach to solving #7366. According to a post on nix-dev, the solution in d4460d1 still causes problems.
This was written quite quickly, and it's highly unlikely that it's completely ready for a merge. So please discuss and review carefully.
@domenkozar @aszlig