--
Ticket URL: <https://code.djangoproject.com/ticket/20027>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0
Comment:
There isn't any guarantee that the executables for Python 2 and 3 are
called python and python3. They may just as well be called python2 and
python.
--
Ticket URL: <https://code.djangoproject.com/ticket/20027#comment:1>
Comment (by anonymous):
Right, so what about using the name of the binary that was used? As in
sys.executable.
--
Ticket URL: <https://code.djangoproject.com/ticket/20027#comment:2>
Comment (by aaugustin):
If you're going to share the code — either because it's open source, or
with co-workers — this could still be a problem. (Rewriting sheebangs
always causes trouble.)
The recommended way to deal with this is to create a virtualenv with the
Python binary you want, and to activate it whenever your work on your
Django project.
--
Ticket URL: <https://code.djangoproject.com/ticket/20027#comment:3>
Comment (by rhertzog):
What about rewriting it at least when "python" does not exist on the PATH?
When I wrote a test suite for the Debian package, I tested specifically in
a Python3 only environment (and in Debian, much like most sane distros,
Python 3 is /usr/bin/python3) and I was astonished that django-admin
createproject would not create a working ./manage.py...
--
Ticket URL: <https://code.djangoproject.com/ticket/20027#comment:4>
Comment (by collinanderson):
I expect this will become more of an issue soon when people start using
Ubuntu 16.04, which doesn't have /usr/bin/python installed by default. It
basically means Django won't work outside of a virtualenv unless you
manually change manage.py.
os.path.basename(sys.executable) seems reasonable to me.
Or, we could hard code it as python3 and and tell people to change it by
hand if they really want to start a new project using python 2. :)
Or just wait til January when we remove py2 support anyway.
--
Ticket URL: <https://code.djangoproject.com/ticket/20027#comment:5>
Comment (by bhch):
setuptools automatically replaces the shebang line with the interpreter
being used. For example, if you install Django in a virtualenv, the
shebang gets re-written from this - `#!/usr/bin/env python` to this -
`#!/path/to/venv/bin/python`. So why hardcode the shebang when all works
perfectly anyway?
--
Ticket URL: <https://code.djangoproject.com/ticket/20027#comment:6>