Opened 15 years ago

Closed 13 years ago

#11542 closed (fixed)

Interactive shell is not configurable

Reported by: Seamus Owned by: Seamus
Component: Core (Other) Version: dev
Severity: Keywords: bpython, shell, shell.py, interpreter
Cc: Eduardo de Oliveira Padoan, Hector Lecuanda, funkyhat Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently when you run manage.py shell Django uses the default python interpreter or Ipython if it's installed. What we need is a setting (or perhaps another parameter?) that allows us to use Bpython ( http://bpython-interpreter.org/ ). IPython is currently hard coded into django, and I think we need more options.

-Seamus

Attachments (4)

bshell.py (419 bytes ) - added by Seamus 15 years ago.
manage.py command
shell.2.py (3.1 KB ) - added by Seamus 15 years ago.
Added commenting, help text, and a fallback to plain if it's an older version of bpython without embed()
shell.py (3.6 KB ) - added by Seamus 15 years ago.
Improvements to the manage.py shell command. (BUGFIXES; IMPROVED COMMENTING; USE THIS ATTACHMENT)
shell.py.diff (5.1 KB ) - added by Seamus 15 years ago.

Download all attachments as: .zip

Change History (27)

comment:1 by Roman Kalinichenko, 15 years ago

Yeah. I propose it in #bpython irc. It will be good idea have flaxable configuration shell.

comment:2 by Seamus, 15 years ago

Component: UncategorizedCore framework
Owner: changed from nobody to Seamus
Triage Stage: UnreviewedDesign decision needed

BPython can now be embedded in Django just like IPython is. When the next version of BPython is released I will post my django patch for bpython.

Currently manage.py tries to import IPython, failing that it uses the default interpreter. My modification would have it first try to use IPython, then BPython, then the default. There would also be a --bpython flag for people who use both. Using this method nobody's default behavior gets messed with -- only people who want to use bpython will be affected.

comment:3 by eliast, 15 years ago

Any word on this patch? I'm trying to use bpython from appengine-patch. Thanks!

comment:4 by Eduardo de Oliveira Padoan, 15 years ago

Cc: Eduardo de Oliveira Padoan added

comment:5 by ikanobori, 15 years ago

Seamus, what is the status on this? Hope you got it to work!

by Seamus, 15 years ago

Attachment: bshell.py added

manage.py command

comment:6 by Seamus, 15 years ago

Status: newassigned

The embedding patch is in bpython, in order to get the latest version install mercurial and run this command:

hg clone https://bitbucket.org/bobf/bpython/

After you get it installed download the attached bshell.py and copy it to your dist-packages/django/core/management/commands folder. Run python manage.py bshell in your project folder to get into the bpython shell. Big thanks to the bpython team for coming up with a great embedding solution.

This bshell.py patch should work in all versions of django. My shell.py patch is also working, I'll complete testing and attach it soon.

comment:7 by Seamus, 15 years ago

milestone: 1.2
Version: 1.0SVN

comment:8 by Seamus, 15 years ago

Has patch: set
Needs documentation: set
Needs tests: set

comment:9 by Seamus, 15 years ago

Keywords: bpython shell shell.py interpreter added

by Seamus, 15 years ago

Attachment: shell.2.py added

Added commenting, help text, and a fallback to plain if it's an older version of bpython without embed()

by Seamus, 15 years ago

Attachment: shell.py added

Improvements to the manage.py shell command. (BUGFIXES; IMPROVED COMMENTING; USE THIS ATTACHMENT)

comment:10 by ikanobori, 15 years ago

Thanks Seamus, your patches work fine on my Mac, FreeBSD and Linux system :-)

comment:11 by lvh, 15 years ago

Same as ikanobori, but I only tried it on Debian sid. bpython is already awesome, it'd be cool if we could use it instead of ipython with regards to django as an alternative interactive shell.

comment:12 by Seamus, 15 years ago

milestone: 1.2
Needs tests: unset

I've tested it in every situation I can think of. It works with older versions of bpython (IE, it errors out appropriately when specifying --bpython and it falls back to the plain interpreter if it can't find the embed() function). It works with and without ipython installed.

Keep in mind that if you want to test it you should be testing shell.py. bshell was just an early demonstration. Everything seems to work 100%.

by Seamus, 15 years ago

Attachment: shell.py.diff added

comment:13 by ikanobori, 15 years ago

I have taken some time to make a clean list of things which need to be done to have bpython (http://bpython-interpreter.org) included as a REPL to be used by Django. Seamus has good intentions but might be going over a bit too thin of ice.

bpython 0.9.4, our current version, does not support the embed() method this patch relies on. This is currently only in our mercurial tip, which can be found at http://bitbucket.org/bobf/bpython

Any effort being put into adding bpython embedding to Django should be made after bpython 0.9.5 is released and in repositories.

Furthermore, this patch might be better off being made into a more general patch set which adds support to using any REPL you want (and is also more like the title of this ticket), if it can be embedded. I currently have no idea how to set this up so it is generic enough to be used by Django. I might come back to that on a later time and date.

Seamus has submitted a few files and a diff which adds support for the current embedding functionality of the bpython interpreter.

If there are any questions about the bpython part of this story, feel free to contact me at simon@… or find me on freenode under the nickname I use here as well.

comment:14 by Seamus, 14 years ago

bpython 0.9.5.2 is available at http://bpython-interpreter.org/

Bpython now has full support for embedding, and thus support for Django.

comment:15 by Seamus, 14 years ago

Needs documentation: unset

comment:16 by Lakshman, 14 years ago

Whats the status of this bug? Is it in for 1.2?

comment:17 by InconV, 14 years ago

I am interested in this as well, any news?

comment:18 by Hector Lecuanda, 14 years ago

Cc: Hector Lecuanda added

comment:19 by Sebastian Noack, 14 years ago

See also #12824.

comment:20 by funkyhat, 14 years ago

Cc: funkyhat added

comment:21 by Jeremy Dunck, 14 years ago

See also #11542

comment:22 by Łukasz Rekucki, 14 years ago

I think you meant #14187. This probably needs a more general solution, to let the user choose his favorite python shell.

comment:23 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: assignedclosed

(In [14895]) Fixed #12735, #14892 and #11542 -- Fixed support for the latest IPython (development) version in the shell management command and added a hook to implement additional shell runners (by subclassing django.core.management.commands.shell.Command, extending the shells attribute and implement a method with the same name).

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