-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
xonsh startup script fails on some platforms #266
Comments
I've been investigating along similar lines for improving xonsh startup on Windows. Currently we have
Googling the unbuffered issue turned up some ugly ways of monkey patching |
Can you try installing with I run GNU/Linux almost exclusively, and I have not had a problem at all when installing things that way (not sure whether installing from pypi with pip or installing from conda. |
I think that we could safely change the python executable to python3. |
Also, I am for whatever changes need to be made to the xonsh.bat script too. |
For the conda packaging it is enough to add the following to the build recipe: build:
entry_points:
- xonsh = xonsh.main:main The conda build machinery will create a if __name__ == '__main__':
import sys
from xonsh.main import main
sys.exit(main()) It just overrides any script defined in setup.py, so there is no problem with adding this. |
I like this idea, but my concern is losing the unbuffered mode mentioned above. Is there a way to enable unbuffered mode with this method? |
Hi @rbrewer123 .... I don't know. Are you sure that it is not already enabled? Can you give me a simple way to test it? |
A thread that may be of interest: StackOverflow: disable output buffering class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
import sys
sys.stdout = Unbuffered(sys.stdout) or # reopen stdout file descriptor with write mode
# and 0 as the buffer size (unbuffered)
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) More simply, you could just make it a shell script. This is what I'm now using on Linux: #!/usr/bin/env sh
export PYTHONUNBUFFERED="XONSH_SET"
/usr/bin/env python -c "from xonsh.main import main; main()"
I'm not sure what best practice is but in e.g. Perl |
Thanks for the pointer @lmmx - if anyone has a PR I am happy to review & merge. I have never experienced this issue, so lacking a way to test, I am not the best person to propose a fix. |
The output on Linux Mint 17 (Ubuntu 14.04) for the
Apparently |
Export an environment variable PYTHONUNBUFFERED: equivalent to the `-u` flag, producing unbuffered output from python. Environment variable is an arbitrary string.
I am curious as to why sudo comes into this at all. Are you running |
I'm closing this issue as it seems to be resolved, but please reopen if that isn't the case. |
Hello all, I just found out about xonsh yesterday and have been checking it out. After installing it (cloned from github, then used pip install . in the cloned directory) my first discovery was that it wasn't put anywhere on my path. Then I found the 'xonsh' script in the scripts directory. Upon executing it, I get:
/usr/bin/env: python -u: No such file or directory
The problem is the shebang at the top of the script. It called /usr/bin/env python -u. Aside from the fact that 'python' on my system will get you Python 2.7 and Python 3 is called python3 (a common configuration when legacy and current Python are both installed), the real issue is that using parameters like that in a shebang doesn't work on many systems. After doing some reading, it appears that this would work OK on OSX but fail on most (if not all) Linux systems. The system processes "python -u" as a single string and looks for an executable with that whole name.
I'm not sure how you'd like this fixed. Personally I set the PYTHONUNBUFFERED environment variable to 1 before launching the script after changing the shebang to be #!/usr/bin/env python3. I don't think that's a good general answer, though. It would fail on systems which have python3 as just 'python' and not guarantee unbuffered access. Perhaps the disabling of buffering should be handled in code?
The text was updated successfully, but these errors were encountered: