File tree Expand file tree Collapse file tree 1 file changed +30
-4
lines changed Expand file tree Collapse file tree 1 file changed +30
-4
lines changed Original file line number Diff line number Diff line change 11# Getting a REPL or Interactive Shell
22
3- This document
3+ rules_python provides a REPL to help with debugging and developing. The goal of
4+ the REPL is to present an environment identical to what a ` py_binary ` creates
5+ for your code.
46
5- The goal with this PR here is to create a REPL in an environment identical to what you would see
6- when running your code in a py_binary. I.e. all the things that the first and second stage
7- bootstrap script do. The three that I can think of:
7+ ## Usage
8+
9+
10+
11+ ## Customizing the shell
12+
13+ By default, the ` //python/bin:repl ` target will invoke the shell from the ` code `
14+ module. It's possible to switch to another shell by writing a custom "stub" and
15+ pointing the target at the necessary dependencies.
16+
17+ For an IPython shell, create a file as follows.
18+
19+ ``` python
20+ import IPython
21+ IPython.start_ipython()
22+ ```
23+
24+ Assuming the file is called ` ipython_stub.py ` and the ` pip.parse ` hub's name is
25+ ` my_deps ` , then set this up in the .bazelrc file:
26+ ```
27+ # Allow the REPL stub to import ipython. In this case, @my_deps is the hub name
28+ # of the pip.parse() call.
29+ build --@rules_python//python/bin:repl_stub_dep=@my_deps//ipython
30+
31+ # Point the REPL at the stub created above.
32+ build --@rules_python//python/bin:repl_stub=//path/to:ipython_stub.py
33+ ```
You can’t perform that action at this time.
0 commit comments