Skip to content

Commit 06cef67

Browse files
committed
Remove the macro-generator
1 parent d0dce4f commit 06cef67

File tree

6 files changed

+11
-38
lines changed

6 files changed

+11
-38
lines changed

.bazelrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,3 @@ build:rtd --enable_bzlmod
3636
common --incompatible_python_disallow_native_rules
3737

3838
build --lockfile_mode=update
39-
40-
run:repl --//python/config_settings:bootstrap_impl=script //python/bin:repl

python/bin/repl.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
from pathlib import Path
33

44
def start_repl():
5+
# Point libedit/readline at the correct terminfo databases.
6+
# https://github.com/astral-sh/python-build-standalone/blob/f0abfc9cb1f6a985fc5561cf5435f7f6e8a64e5b/docs/quirks.rst#backspace-key-doesnt-work-in-python-repl
7+
os.environ["TERMINFO_DIRS"] = "/etc/terminfo:/lib/terminfo:/usr/share/terminfo"
8+
59
# Simulate Python's behavior when a valid startup script is defined by the
610
# PYTHONSTARTUP variable. If this file path fails to load, print the error
711
# and revert to the default behavior.

python/private/py_library_macro.bzl

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,8 @@
1414
"""Implementation of macro-half of py_library rule."""
1515

1616
load(":py_library_rule.bzl", py_library_rule = "py_library")
17-
load(":py_binary_rule.bzl", py_binary_rule = "py_binary")
18-
19-
# The py_library's attributes we don't want to forward to auto-generated
20-
# targets.
21-
_LIBRARY_ONLY_ATTRS = [
22-
"srcs",
23-
"deps",
24-
"data",
25-
"imports",
26-
]
2717

2818
# A wrapper macro is used to avoid any user-observable changes between a
2919
# rule and macro. It also makes generator_function look as expected.
30-
def py_library(name, **kwargs):
31-
library_only_attrs = {
32-
attr: kwargs.pop(attr, None)
33-
for attr in _LIBRARY_ONLY_ATTRS
34-
}
35-
py_library_rule(
36-
name = name,
37-
**(library_only_attrs | kwargs)
38-
)
39-
py_binary_rule(
40-
name = "%s.repl" % name,
41-
srcs = [],
42-
main_module = "python.bin.repl",
43-
deps = [
44-
":%s" % name,
45-
"@rules_python//python/bin:repl",
46-
],
47-
**kwargs
48-
)
20+
def py_library(**kwargs):
21+
py_library_rule(**kwargs)

python/private/sentinel.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ Label attributes with defaults cannot accept None, otherwise they fall
1818
back to using the default. A sentinel allows detecting an intended None value.
1919
"""
2020

21-
load("//python:py_info.bzl", "PyInfo")
22-
2321
SentinelInfo = provider(
2422
doc = "Indicates this was the sentinel target.",
2523
fields = [],
@@ -31,7 +29,6 @@ def _sentinel_impl(ctx):
3129
SentinelInfo(),
3230
# Also output ToolchainInfo to allow it to be used for noop toolchains
3331
platform_common.ToolchainInfo(),
34-
PyInfo(transitive_sources=depset()),
3532
]
3633

3734
sentinel = rule(implementation = _sentinel_impl)

python/private/stage1_bootstrap_template.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ command=(
238238
"$@"
239239
)
240240

241-
# Point libedit/readline at the correct terminfo databases.
242-
# https://github.com/astral-sh/python-build-standalone/blob/f0abfc9cb1f6a985fc5561cf5435f7f6e8a64e5b/docs/quirks.rst#backspace-key-doesnt-work-in-python-repl
243-
export TERMINFO_DIRS=/etc/terminfo:/lib/terminfo:/usr/share/terminfo
244-
245241
# We use `exec` instead of a child process so that signals sent directly (e.g.
246242
# using `kill`) to this process (the PID seen by the calling process) are
247243
# received by the Python process. Otherwise, this process receives the signal

python/private/stage2_bootstrap_template.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,14 @@ def main():
372372
# TODO(philsc): Can we point at python.bin.repl instead? That would mean
373373
# adding it as a dependency to all binaries.
374374
MAIN_MODULE = "code"
375+
375376
# Prevent subprocesses from also entering the REPL.
376377
del os.environ["RULES_PYTHON_BOOTSTRAP_REPL"]
377378

379+
# Point libedit/readline at the correct terminfo databases.
380+
# https://github.com/astral-sh/python-build-standalone/blob/f0abfc9cb1f6a985fc5561cf5435f7f6e8a64e5b/docs/quirks.rst#backspace-key-doesnt-work-in-python-repl
381+
os.environ["TERMINFO_DIRS"] = "/etc/terminfo:/lib/terminfo:/usr/share/terminfo"
382+
378383
main_rel_path = None
379384
# todo: things happen to work because find_runfiles_root
380385
# ends up using stage2_bootstrap, and ends up computing the proper

0 commit comments

Comments
 (0)