Opened 12 years ago

Closed 12 years ago

Last modified 7 years ago

#20027 closed Bug (wontfix)

manage.py shebang should reflect used python executable

Reported by: anonymous Owned by: nobody
Component: Python 3 Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,
since Django now supports both Python 2 and Python 3, it seems that shebang in generated manage.py in new projects should reflect this. Currently, manage.py always points to "python", but IMHO when generated with python3, it should point to "python3". I think it makes sense to manage a project with python version that was used to generate it.

Change History (6)

comment:1 by Aymeric Augustin, 12 years ago

Resolution: wontfix
Status: newclosed

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.

comment:2 by anonymous, 12 years ago

Right, so what about using the name of the binary that was used? As in sys.executable.

comment:3 by Aymeric Augustin, 12 years ago

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.

comment:4 by Raphaël Hertzog, 9 years ago

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...

Version 0, edited 9 years ago by Raphaël Hertzog (next)

comment:5 by Collin Anderson, 9 years ago

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.

comment:6 by bhch, 7 years ago

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?

Note: See TracTickets for help on using tickets.
Back to Top