Skip to content

Commit 4f78a8c

Browse files
committed
chore: make pipstar non-switchable
At the same time cleanup pystar env var docs. Also cleanup dead code.
1 parent d18adbb commit 4f78a8c

17 files changed

Lines changed: 44 additions & 1106 deletions

docs/environment-variables.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,6 @@ When `1`, `rules_python` will warn users about deprecated functionality that wil
5252
be removed in a subsequent major `rules_python` version. Defaults to `0` if unset.
5353
:::
5454

55-
::::{envvar} RULES_PYTHON_ENABLE_PYSTAR
56-
57-
When `1`, the `rules_python` Starlark implementation of the core rules is used
58-
instead of the Bazel-builtin rules. Note that this requires Bazel 7+. Defaults
59-
to `1`.
60-
61-
:::{versionadded} 0.26.0
62-
Defaults to `0` if unspecified.
63-
:::
64-
:::{versionchanged} 0.40.0
65-
The default became `1` if unspecified
66-
:::
67-
::::
68-
69-
::::{envvar} RULES_PYTHON_ENABLE_PIPSTAR
70-
71-
When `1`, the `rules_python` Starlark implementation of the PyPI/pip integration is used
72-
instead of the legacy Python scripts.
73-
74-
:::{versionadded} 1.5.0
75-
:::
76-
:::{versionchanged} 1.7.0
77-
Flipped to be enabled by default.
78-
:::
79-
::::
80-
8155
::::{envvar} RULES_PYTHON_EXTRACT_ROOT
8256

8357
Directory to use as the root for creating files necessary for bootstrapping so

docs/readthedocs_build.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ done < <(env -0)
1212
# In order to get the build number, we extract it from the host name
1313
extra_env+=("--@sphinxdocs//sphinxdocs:extra_env=HOSTNAME=$HOSTNAME")
1414

15-
export RULES_PYTHON_ENABLE_PIPSTAR=1
16-
1715
set -x
18-
export RULES_PYTHON_ENABLE_PIPSTAR=1
1916
bazel run \
2017
--config=rtd \
2118
"--@sphinxdocs//sphinxdocs:extra_defines=version=$READTHEDOCS_VERSION" \

python/private/internal_config_repo.bzl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ settings for rules to later use.
2121
load("//python/private:text_util.bzl", "render")
2222
load(":repo_utils.bzl", "repo_utils")
2323

24-
_ENABLE_PIPSTAR_ENVVAR_NAME = "RULES_PYTHON_ENABLE_PIPSTAR"
25-
_ENABLE_PIPSTAR_DEFAULT = "1"
2624
_ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME = "RULES_PYTHON_DEPRECATION_WARNINGS"
2725
_ENABLE_DEPRECATION_WARNINGS_DEFAULT = "0"
2826

@@ -31,7 +29,6 @@ config = struct(
3129
build_python_zip_default = {build_python_zip_default},
3230
supports_whl_extraction = {supports_whl_extraction},
3331
enable_pystar = True,
34-
enable_pipstar = {enable_pipstar},
3532
enable_deprecation_warnings = {enable_deprecation_warnings},
3633
bazel_8_or_later = {bazel_8_or_later},
3734
bazel_9_or_later = {bazel_9_or_later},
@@ -104,7 +101,6 @@ def _internal_config_repo_impl(rctx):
104101

105102
rctx.file("rules_python_config.bzl", _CONFIG_TEMPLATE.format(
106103
build_python_zip_default = repo_utils.get_platforms_os_name(rctx) == "windows",
107-
enable_pipstar = _bool_from_environ(rctx, _ENABLE_PIPSTAR_ENVVAR_NAME, _ENABLE_PIPSTAR_DEFAULT),
108104
enable_deprecation_warnings = _bool_from_environ(rctx, _ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME, _ENABLE_DEPRECATION_WARNINGS_DEFAULT),
109105
builtin_py_info_symbol = builtin_py_info_symbol,
110106
builtin_py_runtime_info_symbol = builtin_py_runtime_info_symbol,
@@ -139,7 +135,7 @@ def _internal_config_repo_impl(rctx):
139135
internal_config_repo = repository_rule(
140136
implementation = _internal_config_repo_impl,
141137
configure = True,
142-
environ = [_ENABLE_PIPSTAR_ENVVAR_NAME],
138+
environ = [],
143139
attrs = {
144140
"transition_setting_generators": attr.string_list_dict(),
145141
"transition_settings": attr.string_list(),

python/private/pypi/extension.bzl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,11 @@ def _configure(config, *, override = False, **kwargs):
7171
def build_config(
7272
*,
7373
module_ctx,
74-
enable_pipstar,
7574
enable_pipstar_extract):
7675
"""Parse 'configure' and 'default' extension tags
7776
7877
Args:
7978
module_ctx: {type}`module_ctx` module context.
80-
enable_pipstar: {type}`bool` a flag to enable dropping Python dependency for
81-
evaluation of the extension.
8279
enable_pipstar_extract: {type}`bool | None` a flag to also not pass Python
8380
interpreter to `whl_library` when possible.
8481
@@ -132,24 +129,20 @@ def build_config(
132129
name: _plat(**values)
133130
for name, values in defaults["platforms"].items()
134131
},
135-
enable_pipstar = enable_pipstar,
136132
enable_pipstar_extract = enable_pipstar_extract,
137133
)
138134

139135
def parse_modules(
140136
module_ctx,
141137
_fail = fail,
142138
simpleapi_download = simpleapi_download,
143-
enable_pipstar = False,
144139
enable_pipstar_extract = False,
145140
**kwargs):
146141
"""Implementation of parsing the tag classes for the extension and return a struct for registering repositories.
147142
148143
Args:
149144
module_ctx: {type}`module_ctx` module context.
150145
simpleapi_download: Used for testing overrides
151-
enable_pipstar: {type}`bool` a flag to enable dropping Python dependency for
152-
evaluation of the extension.
153146
enable_pipstar_extract: {type}`bool` a flag to enable dropping Python dependency for
154147
extracting wheels.
155148
_fail: {type}`function` the failure function, mainly for testing.
@@ -189,7 +182,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
189182
srcs_exclude_glob = whl_mod.srcs_exclude_glob,
190183
)
191184

192-
config = build_config(module_ctx = module_ctx, enable_pipstar = enable_pipstar, enable_pipstar_extract = enable_pipstar_extract)
185+
config = build_config(module_ctx = module_ctx, enable_pipstar_extract = enable_pipstar_extract)
193186

194187
# TODO @aignas 2025-06-03: Merge override API with the builder?
195188
_overriden_whl_set = {}
@@ -377,8 +370,7 @@ def _pip_impl(module_ctx):
377370

378371
mods = parse_modules(
379372
module_ctx,
380-
enable_pipstar = rp_config.enable_pipstar,
381-
enable_pipstar_extract = rp_config.enable_pipstar and rp_config.bazel_8_or_later,
373+
enable_pipstar_extract = rp_config.bazel_8_or_later,
382374
)
383375

384376
# Build all of the wheel modifications if the tag class is called.
@@ -447,10 +439,6 @@ Supported keys:
447439
* `platform_system`, defaults to a value inferred from the {attr}`os_name`.
448440
* `platform_version`, defaults to `0`.
449441
* `sys_platform`, defaults to a value inferred from the {attr}`os_name`.
450-
451-
::::{note}
452-
This is only used if the {envvar}`RULES_PYTHON_ENABLE_PIPSTAR` is enabled.
453-
::::
454442
""",
455443
),
456444
"index_url": attr.string(

python/private/pypi/hub_builder.bzl

Lines changed: 8 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ load("//python/private:text_util.bzl", "render")
77
load("//python/private:version.bzl", "version")
88
load("//python/private:version_label.bzl", "version_label")
99
load(":attrs.bzl", "use_isolated")
10-
load(":evaluate_markers.bzl", "evaluate_markers_py", evaluate_markers_star = "evaluate_markers")
10+
load(":evaluate_markers.bzl", evaluate_markers_star = "evaluate_markers")
1111
load(":parse_requirements.bzl", "parse_requirements")
1212
load(":pep508_env.bzl", "env")
1313
load(":pep508_evaluate.bzl", "evaluate")
@@ -194,7 +194,6 @@ def _pip_parse(self, module_ctx, pip_attr):
194194
self,
195195
module_ctx,
196196
pip_attr = pip_attr,
197-
enable_pipstar = bool(self._config.enable_pipstar or self._get_index_urls.get(pip_attr.python_version)),
198197
enable_pipstar_extract = bool(self._config.enable_pipstar_extract or self._get_index_urls.get(pip_attr.python_version)),
199198
)
200199

@@ -297,24 +296,21 @@ def _diff_dict(first, second):
297296
else:
298297
return None
299298

300-
def _add_whl_library(self, *, python_version, whl, repo, enable_pipstar):
299+
def _add_whl_library(self, *, python_version, whl, repo):
301300
"""Add a whl_library and kwargs to call it with for the hub.
302301
303302
Args:
304303
self: implicitly added
305304
python_version: {type}`str` the python version to assume
306305
whl: struct from `_whl_library_args()`
307306
repo: struct from `_whl_repo`
308-
enable_pipstar: {type}`bool` if pipstar is enabled.
309307
"""
310308
if repo == None:
311309
# NOTE @aignas 2025-07-07: we guard against an edge-case where there
312310
# are more platforms defined than there are wheels for and users
313311
# disallow building from sdist.
314312
return
315313

316-
platforms = self._platforms[python_version]
317-
318314
# TODO @aignas 2025-06-29: we should not need the version in the repo_name if
319315
# we are using pipstar and we are downloading the wheel using the downloader
320316
#
@@ -339,17 +335,6 @@ def _add_whl_library(self, *, python_version, whl, repo, enable_pipstar):
339335
return
340336
self._whl_libraries[repo_name] = repo.args
341337

342-
if not enable_pipstar and "experimental_target_platforms" in repo.args:
343-
self._whl_libraries[repo_name] |= {
344-
"experimental_target_platforms": sorted({
345-
# TODO @aignas 2025-07-07: this should be solved in a better way
346-
platforms[candidate].triple.partition("_")[-1]: None
347-
for p in repo.args["experimental_target_platforms"]
348-
for candidate in platforms
349-
if candidate.endswith(p)
350-
}),
351-
}
352-
353338
mapping = self._whl_map.setdefault(whl.name, {})
354339
if repo.config_setting in mapping and mapping[repo.config_setting] != repo_name:
355340
fail(
@@ -480,61 +465,27 @@ def _platforms(module_ctx, *, python_version, config, target_platforms):
480465
)
481466
return platforms
482467

483-
def _evaluate_markers(self, pip_attr, enable_pipstar):
468+
def _evaluate_markers(self, pip_attr):
484469
if self._evaluate_markers_fn:
485470
return self._evaluate_markers_fn
486471

487-
if enable_pipstar:
488-
return lambda _, requirements: evaluate_markers_star(
489-
requirements = requirements,
490-
platforms = self._platforms[pip_attr.python_version],
491-
)
492-
493-
interpreter = _detect_interpreter(self, pip_attr)
494-
495-
# NOTE @aignas 2024-08-02: , we will execute any interpreter that we find either
496-
# in the PATH or if specified as a label. We will configure the env
497-
# markers when evaluating the requirement lines based on the output
498-
# from the `requirements_files_by_platform` which should have something
499-
# similar to:
500-
# {
501-
# "//:requirements.txt": ["cp311_linux_x86_64", ...]
502-
# }
503-
#
504-
# We know the target python versions that we need to evaluate the
505-
# markers for and thus we don't need to use multiple python interpreter
506-
# instances to perform this manipulation. This function should be executed
507-
# only once by the underlying code to minimize the overhead needed to
508-
# spin up a Python interpreter.
509-
return lambda module_ctx, requirements: evaluate_markers_py(
510-
module_ctx,
511-
requirements = {
512-
k: {
513-
p: self._platforms[pip_attr.python_version][p].triple
514-
for p in plats
515-
}
516-
for k, plats in requirements.items()
517-
},
518-
python_interpreter = interpreter.path,
519-
python_interpreter_target = interpreter.target,
520-
srcs = pip_attr._evaluate_markers_srcs,
521-
logger = self._logger,
472+
return lambda _, requirements: evaluate_markers_star(
473+
requirements = requirements,
474+
platforms = self._platforms[pip_attr.python_version],
522475
)
523476

524477
def _create_whl_repos(
525478
self,
526479
module_ctx,
527480
*,
528481
pip_attr,
529-
enable_pipstar = False,
530482
enable_pipstar_extract = False):
531483
"""create all of the whl repositories
532484
533485
Args:
534486
self: the builder.
535487
module_ctx: {type}`module_ctx`.
536488
pip_attr: {type}`struct` - the struct that comes from the tag class iteration.
537-
enable_pipstar: {type}`bool` - enable the pipstar or not.
538489
enable_pipstar_extract: {type}`bool` - enable the pipstar extraction or not.
539490
"""
540491
logger = self._logger
@@ -558,7 +509,7 @@ def _create_whl_repos(
558509
platforms = platforms,
559510
extra_pip_args = pip_attr.extra_pip_args,
560511
get_index_urls = self._get_index_urls.get(pip_attr.python_version),
561-
evaluate_markers = _evaluate_markers(self, pip_attr, enable_pipstar),
512+
evaluate_markers = _evaluate_markers(self, pip_attr),
562513
logger = logger,
563514
)
564515

@@ -577,7 +528,6 @@ def _create_whl_repos(
577528
self,
578529
module_ctx,
579530
pip_attr = pip_attr,
580-
enable_pipstar = enable_pipstar,
581531
)
582532

583533
interpreter = _detect_interpreter(self, pip_attr)
@@ -600,18 +550,16 @@ def _create_whl_repos(
600550
python_version = _major_minor_version(pip_attr.python_version),
601551
is_multiple_versions = whl.is_multiple_versions,
602552
interpreter = interpreter,
603-
enable_pipstar = enable_pipstar,
604553
enable_pipstar_extract = enable_pipstar_extract,
605554
)
606555
_add_whl_library(
607556
self,
608557
python_version = pip_attr.python_version,
609558
whl = whl,
610559
repo = repo,
611-
enable_pipstar = enable_pipstar,
612560
)
613561

614-
def _common_args(self, module_ctx, *, pip_attr, enable_pipstar):
562+
def _common_args(self, module_ctx, *, pip_attr):
615563
# Construct args separately so that the lock file can be smaller and does not include unused
616564
# attrs.
617565
whl_library_args = dict(
@@ -627,8 +575,6 @@ def _common_args(self, module_ctx, *, pip_attr, enable_pipstar):
627575
envsubst = pip_attr.envsubst,
628576
pip_data_exclude = pip_attr.pip_data_exclude,
629577
)
630-
if not enable_pipstar:
631-
maybe_args["experimental_target_platforms"] = pip_attr.experimental_target_platforms
632578

633579
whl_library_args.update({k: v for k, v in maybe_args.items() if v})
634580
maybe_args_with_default = dict(
@@ -679,7 +625,6 @@ def _whl_repo(
679625
python_version,
680626
use_downloader,
681627
interpreter,
682-
enable_pipstar = False,
683628
enable_pipstar_extract = False):
684629
args = dict(whl_library_args)
685630
args["requirement"] = src.requirement_line
@@ -731,14 +676,6 @@ def _whl_repo(
731676
args["urls"] = [src.url]
732677
args["sha256"] = src.sha256
733678
args["filename"] = src.filename
734-
if not enable_pipstar:
735-
args["experimental_target_platforms"] = [
736-
# Get rid of the version for the target platforms because we are
737-
# passing the interpreter any way. Ideally we should search of ways
738-
# how to pass the target platforms through the hub repo.
739-
p.partition("_")[2]
740-
for p in src.target_platforms
741-
]
742679

743680
# TODO @aignas 2025-11-02: once we have pipstar enabled we can add extra
744681
# targets to each hub for each extra combination and solve this more cleanly as opposed to

python/private/pypi/whl_installer/arguments.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ def parser(**kwargs: Any) -> argparse.ArgumentParser:
4747
type=Platform.from_string,
4848
help="Platforms to target dependencies. Can be used multiple times.",
4949
)
50-
parser.add_argument(
51-
"--enable-pipstar",
52-
action="store_true",
53-
help="Disable certain code paths if we expect to process the whl in Starlark.",
54-
)
5550
parser.add_argument(
5651
"--pip_data_exclude",
5752
action="store",

0 commit comments

Comments
 (0)