Re: Transforming django-admin.py to a shell script

155 views
Skip to first unread message

Alex Ogier

unread,
Mar 1, 2013, 1:40:20 PM3/1/13
to django-d...@googlegroups.com
On Fri, Mar 1, 2013 at 1:25 PM, Alon Nisser <alon...@gmail.com> wrote:
> and then it could be called as `django-admin somecommend` instead of `python
> django-admin.py somecommand`.
> since python (using setuptools entry points) makes making a python script
> into a shell script quite easy I guess this has been Discussed before but I
> didn't find the discussion and the explanation why doesn't Django team deem
> this path worthy.
> I think most python web frameworks use some kind of a shell script (or using
> a customized paster/gearbox to provide this functionality) except for
> Django.

django-admin.py is already an executable script. So you don't need
`python django-admin.py somecommand`, just `django-admin.py
somecommand` should suffice. The .py suffix is a bit ugly, to be sure,
but it's not worth breaking every single introductory tutorial on the
web to fix. Besides, it does have some merit as it is consistent with
`./manage.py somecommand`, which is the recommended way to run pretty
much every command except "startproject".

Best,
Alex Ogier

Alon Nisser

unread,
Mar 1, 2013, 4:38:38 PM3/1/13
to django-d...@googlegroups.com
at least from my windows exprience with Django (yes, I know this isn't a common use case, but still) the current django-admin.py and manage.py do need python preface to run right (while inside a virtualenv) - but maybe I'm wrong, at least from my peak in Django setup.py It doesn't utilize `entrypoints` so I guess this is why on some platforms the basic shell usage fails. anyway wouldn't it be more future proof to start enabling the option to use Django-admin and manage as shell script. the current .py version would continue to work (even if in a somewhat broken way) but slowly the tutorials would move to simpler shell script without the .py ending.

Łukasz Rekucki

unread,
Mar 1, 2013, 5:17:25 PM3/1/13
to django-developers
On 1 March 2013 22:38, Alon Nisser <alon...@gmail.com> wrote:
at least from my windows exprience with Django (yes, I know this isn't a common use case, but still) the current django-admin.py and manage.py do need python preface to run right (while inside a virtualenv)

I'm not 100% sure if the Windows Python Launcher[1] works with virtualenv, but it most likely works with venv support in Python 3.3. It should also allow you to run Python scripts without the .py suffix

Anyways, what kind of "shell" you had in mind? Batch ? Powershell ? Bash ?.

Alon Nisser

unread,
Mar 2, 2013, 3:57:43 PM3/2/13
to django-d...@googlegroups.com
much simpler. simply making it run with simple `manage somecommand` instead of `python manage.py somecommand`. using setuptools or something similiar

Joe Tennies

unread,
Mar 2, 2013, 9:06:00 PM3/2/13
to django-d...@googlegroups.com
So, you are asking for the startproject (which again, you only run once, so I wouldn't think it would be TOO bad) to create a manage.bat that had the following line in it?

python manage.py %*

I'm not saying that this is a bad idea. It does make it fairly easy for Windows people. In the case of Linux and Mac, I think the old way "just works" in 90+% of the cases.

That stated, could we get the following lines added to virtualenv's activate.bat:

assoc .py=Python.File
ftype Python.File=(magic path to python.exe or pythonw.exe)

From what I'm reading*, that would solve this problem not just for Django but for everyone. I'll create a patch for virtualenv once I get a chance to test this theory.

*(http://stackoverflow.com/questions/8012956/python-django-virtualenv-windows)




--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Joe Tennies
ten...@gmail.com

Alon Nisser

unread,
Mar 3, 2013, 4:50:43 AM3/3/13
to django-d...@googlegroups.com
Yes! Actually I also bumped into the annoying `ImportError: No module named django.core` problem, so fixing virtualenv would be a blessing.
But.. I still think this is the wrong path, since python setuptools has a better solution for that with cross platform compatibility etc.
you can see that Turbogears (as well as almost any other python webframework or commandline tool) uses setuptools entry points to establish a commandline script (under the working scripts/bin folder, according to the platform). why wouldn't Django do that? and then solve both problems in one shoot?

On Friday, March 1, 2013 8:25:50 PM UTC+2, Alon Nisser wrote:
and then it could be called as `django-admin somecommend` instead of `python django-admin.py somecommand`.
since python (using setuptools entry points) makes making a python script into a shell script quite easy I guess this has been Discussed before but I didn't find the discussion and the explanation why doesn't Django team deem this path worthy.
I think most python web frameworks use some kind of a shell script (or using a customized paster/gearbox to provide this functionality) except for Django.

thanks for the clarification

Reply all
Reply to author
Forward
0 new messages