Skip to content

Commit d48433b

Browse files
committed
Incorporate some of the feedback
1 parent 8a00d32 commit d48433b

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

python/bin/repl_stub.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
"""Simulates the REPL that Python spawns when invoking the binary with no arguments.
2+
3+
The code module is responsible for the default shell.
4+
5+
The import and `ocde.interact()` call here his is equivalent to doing:
6+
7+
$ python3 -m code
8+
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
9+
Type "help", "copyright", "credits" or "license" for more information.
10+
(InteractiveConsole)
11+
>>>
12+
13+
The logic for PYTHONSTARTUP is handled in python/private/repl_template.py.
14+
"""
15+
116
import code
217

318
code.interact()

python/private/repl.bzl

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# Copyright 2025 The Bazel Authors. All rights reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
151
"""Implementation of the rules to expose a REPL."""
162

173
load("//python:py_binary.bzl", "py_binary")
@@ -33,19 +19,24 @@ _generate_repl_main = rule(
3319
attrs = {
3420
"out": attr.output(
3521
mandatory = True,
22+
doc = "The path to the file to generate.",
3623
),
3724
"stub": attr.label(
3825
mandatory = True,
3926
allow_single_file = True,
27+
doc = ("The stub responsible for actually invoking the final shell. " +
28+
"See the \"Customizing the REPL\" docs for details."),
4029
),
4130
"_template": attr.label(
4231
default = "//python/private:repl_template.py",
4332
allow_single_file = True,
33+
doc = "The template to use for generating `out`.",
4434
),
4535
},
4636
)
4737

4838
def py_repl_binary(name, stub, deps = [], data = [], **kwargs):
39+
"""A
4940
_generate_repl_main(
5041
name = "%s_py" % name,
5142
stub = stub,

0 commit comments

Comments
 (0)