@@ -6,14 +6,47 @@ for your code.
66
77## Usage
88
9+ Start the REPL with the following command:
10+ ``` console
11+ $ bazel run @rules_python//python/bin:repl
12+ Python 3.11.11 (main, Mar 17 2025, 21:02:09) [Clang 20.1.0 ] on linux
13+ Type "help", "copyright", "credits" or "license" for more information.
14+ >>>
15+ ```
16+
17+ Settings like ` //python/config_settings:python_version ` will influence the exact
18+ behaviour.
19+ ``` console
20+ $ bazel run @rules_python//python/bin:repl --@rules_python//python/config_settings:python_version=3.13
21+ Python 3.13.2 (main, Mar 17 2025, 21:02:54) [Clang 20.1.0 ] on linux
22+ Type "help", "copyright", "credits" or "license" for more information.
23+ >>>
24+ ```
25+
26+ See [ //python/config_settings] ( api/rules_python/python/config_settings/index )
27+ and [ Environment Variables] ( environment-variables ) for more settings.
928
29+ ## Importing Python targets
30+
31+ The ` //python/bin:repl_dep ` command line flag gives the REPL access to a target
32+ that provides the ` PyInfo ` provider.
33+
34+ ``` console
35+ $ bazel run @rules_python//python/bin:repl --@rules_python//python/bin:repl_dep=@rules_python//tools:wheelmaker
36+ Python 3.11.11 (main, Mar 17 2025, 21:02:09) [Clang 20.1.0 ] on linux
37+ Type "help", "copyright", "credits" or "license" for more information.
38+ >>> import tools.wheelmaker
39+ >>>
40+ ```
1041
1142## Customizing the shell
1243
1344By default, the ` //python/bin:repl ` target will invoke the shell from the ` code `
1445module. It's possible to switch to another shell by writing a custom "stub" and
1546pointing the target at the necessary dependencies.
1647
48+ ### IPython Example
49+
1750For an IPython shell, create a file as follows.
1851
1952``` python
@@ -22,7 +55,7 @@ IPython.start_ipython()
2255```
2356
2457Assuming 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:
58+ ` my_deps ` , set this up in the .bazelrc file:
2659```
2760# Allow the REPL stub to import ipython. In this case, @my_deps is the hub name
2861# of the pip.parse() call.
0 commit comments