Opened 6 years ago

Closed 4 years ago

#11542 closed (fixed)

Interactive shell is not configurable

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

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 6 years ago.
manage.py command
shell.2.py (3.1 KB) - added by Seamus 6 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 6 years ago.
Improvements to the manage.py shell command. (BUGFIXES; IMPROVED COMMENTING; USE THIS ATTACHMENT)
shell.py.diff (5.1 KB) - added by Seamus 6 years ago.

Download all attachments as: .zip

Change History (27)

comment:1 Changed 6 years ago by romankrv

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 6 years ago by Seamus

  • Component changed from Uncategorized to Core framework
  • Owner changed from nobody to Seamus
  • Triage Stage changed from Unreviewed to Design 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 Changed 6 years ago by eliast

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

comment:4 Changed 6 years ago by edcrypt

  • Cc edcrypt added

comment:5 Changed 6 years ago by ikanobori

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

Changed 6 years ago by Seamus

manage.py command

comment:6 Changed 6 years ago by Seamus

  • Status changed from new to assigned

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 Changed 6 years ago by Seamus

  • milestone set to 1.2
  • Version changed from 1.0 to SVN

comment:8 Changed 6 years ago by Seamus

  • Has patch set
  • Needs documentation set
  • Needs tests set

comment:9 Changed 6 years ago by Seamus

  • Keywords bpython shell shell.py interpreter added

Changed 6 years ago by Seamus

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

Changed 6 years ago by Seamus

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

comment:10 Changed 6 years ago by ikanobori

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

comment:11 Changed 6 years ago by lvh

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 Changed 6 years ago by Seamus

  • milestone 1.2 deleted
  • 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%.

Changed 6 years ago by Seamus

comment:13 Changed 6 years ago by ikanobori

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 Changed 5 years ago by Seamus

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 Changed 5 years ago by Seamus

  • Needs documentation unset

comment:16 Changed 5 years ago by becomingGuru

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

comment:17 Changed 5 years ago by InconV

I am interested in this as well, any news?

comment:18 Changed 5 years ago by hlecuanda

  • Cc hlecuanda added

comment:19 Changed 5 years ago by sebastian_noack

See also #12824.

comment:20 Changed 5 years ago by funkyhat

  • Cc funkyhat added

comment:21 Changed 5 years ago by jdunck

See also #11542

comment:22 Changed 5 years ago by lrekucki

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

comment:23 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from assigned to closed

(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