Skip to content

Commit 332c503

Browse files
committed
Merge branch 'main' into uv-lock-rule-instead-of-genrule
2 parents db84a49 + 701ba45 commit 332c503

14 files changed

+122
-18
lines changed

.bcr/metadata.template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
}
1414
],
1515
"repository": [
16-
"github:bazelbuild/rules_python"
16+
"github:bazelbuild/rules_python",
17+
"github:bazel-contrib/rules_python"
1718
],
1819
"versions": [],
1920
"yanked_versions": {}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ Unreleased changes template.
9494
* (rules) APIs for creating custom rules based on the core py_binary, py_test,
9595
and py_library rules
9696
([#1647](https://github.com/bazelbuild/rules_python/issues/1647))
97+
* (rules) Added env-var to allow additional interpreter args for stage1 bootstrap.
98+
See {obj}`RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` environment variable.
99+
Only applicable for {obj}`--bootstrap_impl=script`.
100+
* (rules) Added {obj}`interpreter_args` attribute to `py_binary` and `py_test`,
101+
which allows pass arguments to the interpreter before the regular args.
97102

98103
{#v0-0-0-removed}
99104
### Removed

docs/environment-variables.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Environment Variables
22

3+
::::{envvar} RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS
4+
5+
This variable allows for additional arguments to be provided to the Python interpreter
6+
at bootstrap time when the `bash` bootstrap is used. If
7+
`RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` were provided as `-Xaaa`, then the command
8+
would be;
9+
10+
```
11+
python -Xaaa /path/to/file.py
12+
```
13+
14+
This feature is likely to be useful for the integration of debuggers. For example,
15+
it would be possible to configure the `RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` to
16+
be set to `/path/to/debugger.py --port 12344 --file` resulting
17+
in the command executed being;
18+
19+
```
20+
python /path/to/debugger.py --port 12345 --file /path/to/file.py
21+
```
22+
23+
:::{seealso}
24+
The {bzl:obj}`interpreter_args` attribute.
25+
:::
26+
27+
:::{versionadded} VERSION_NEXT_FEATURE
28+
29+
::::
30+
331
:::{envvar} RULES_PYTHON_BOOTSTRAP_VERBOSE
432

533
When `1`, debug information about bootstrapping of a program is printed to

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ in this repository are simple aliases. On Bazel 7 and above `rules_python` uses
1313
a separate Starlark implementation,
1414
see {ref}`Migrating from the Bundled Rules` below.
1515

16-
Once rules_python 1.0 is released, they will follow
16+
This repository follows
1717
[semantic versioning](https://semver.org) and the breaking change policy
1818
outlined in the [support](support) page.
1919

examples/bzlmod/requirements_lock_3_10.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ isort==5.12.0 \
5050
--hash=sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504 \
5151
--hash=sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6
5252
# via pylint
53-
jinja2==3.1.4 \
54-
--hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
55-
--hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
53+
jinja2==3.1.6 \
54+
--hash=sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d \
55+
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
5656
# via sphinx
5757
lazy-object-proxy==1.9.0 \
5858
--hash=sha256:09763491ce220c0299688940f8dc2c5d05fd1f45af1e42e636b2e8b2303e4382 \

examples/bzlmod/requirements_lock_3_9.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ isort==5.11.4 \
5151
--hash=sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6 \
5252
--hash=sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b
5353
# via pylint
54-
jinja2==3.1.4 \
55-
--hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
56-
--hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
54+
jinja2==3.1.6 \
55+
--hash=sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d \
56+
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
5757
# via sphinx
5858
lazy-object-proxy==1.10.0 \
5959
--hash=sha256:009e6bb1f1935a62889ddc8541514b6a9e1fcf302667dcb049a0be5c8f613e56 \

examples/bzlmod/requirements_windows_3_10.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ isort==5.12.0 \
5353
--hash=sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504 \
5454
--hash=sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6
5555
# via pylint
56-
jinja2==3.1.4 \
57-
--hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
58-
--hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
56+
jinja2==3.1.6 \
57+
--hash=sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d \
58+
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
5959
# via sphinx
6060
lazy-object-proxy==1.9.0 \
6161
--hash=sha256:09763491ce220c0299688940f8dc2c5d05fd1f45af1e42e636b2e8b2303e4382 \

python/private/py_executable.bzl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@ EXECUTABLE_ATTRS = dicts.add(
8787
IMPORTS_ATTRS,
8888
COVERAGE_ATTRS,
8989
{
90+
"interpreter_args": lambda: attrb.StringList(
91+
doc = """
92+
Arguments that are only applicable to the interpreter.
93+
94+
The args an interpreter supports are specific to the interpreter. For
95+
CPython, see https://docs.python.org/3/using/cmdline.html.
96+
97+
:::{note}
98+
Only supported for {obj}`--bootstrap_impl=script`. Ignored otherwise.
99+
:::
100+
101+
:::{seealso}
102+
The {obj}`RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` environment variable
103+
:::
104+
105+
:::{versionadded} VERSION_NEXT_FEATURE
106+
:::
107+
""",
108+
),
90109
"legacy_create_init": lambda: attrb.Int(
91110
default = -1,
92111
values = [-1, 0, 1],
@@ -658,6 +677,10 @@ def _create_stage1_bootstrap(
658677
python_binary_actual = venv.interpreter_actual_path if venv else ""
659678

660679
subs = {
680+
"%interpreter_args%": "\n".join([
681+
'"{}"'.format(v)
682+
for v in ctx.attr.interpreter_args
683+
]),
661684
"%is_zipfile%": "1" if is_for_zip else "0",
662685
"%python_binary%": python_binary_path,
663686
"%python_binary_actual%": python_binary_actual,

python/private/pypi/whl_library.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def _get_xcode_location_cflags(rctx):
3434
"""Query the xcode sdk location to update cflags
3535
3636
Figure out if this interpreter target comes from rules_python, and patch the xcode sdk location if so.
37-
Pip won't be able to compile c extensions from sdists with the pre built python distributions from indygreg
38-
otherwise. See https://github.com/indygreg/python-build-standalone/issues/103
37+
Pip won't be able to compile c extensions from sdists with the pre built python distributions from astral-sh
38+
otherwise. See https://github.com/astral-sh/python-build-standalone/issues/103
3939
"""
4040

4141
# Only run on MacOS hosts
@@ -63,8 +63,8 @@ def _get_xcode_location_cflags(rctx):
6363
def _get_toolchain_unix_cflags(rctx, python_interpreter, logger = None):
6464
"""Gather cflags from a standalone toolchain for unix systems.
6565
66-
Pip won't be able to compile c extensions from sdists with the pre built python distributions from indygreg
67-
otherwise. See https://github.com/indygreg/python-build-standalone/issues/103
66+
Pip won't be able to compile c extensions from sdists with the pre built python distributions from astral-sh
67+
otherwise. See https://github.com/astral-sh/python-build-standalone/issues/103
6868
"""
6969

7070
# Only run on Unix systems

python/private/python_repository.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _python_repository_impl(rctx):
161161
python_bin = "python.exe" if ("windows" in platform) else "bin/python3"
162162

163163
if "linux" in platform:
164-
# Workaround around https://github.com/indygreg/python-build-standalone/issues/231
164+
# Workaround around https://github.com/astral-sh/python-build-standalone/issues/231
165165
for url in urls:
166166
head_and_release, _, _ = url.rpartition("/")
167167
_, _, release = head_and_release.rpartition("/")
@@ -177,7 +177,7 @@ def _python_repository_impl(rctx):
177177
# building on.
178178
#
179179
# Link to the first affected release:
180-
# https://github.com/indygreg/python-build-standalone/releases/tag/20240224
180+
# https://github.com/astral-sh/python-build-standalone/releases/tag/20240224
181181
rctx.delete("share/terminfo")
182182
break
183183

0 commit comments

Comments
 (0)