Skip to content

Commit 116019e

Browse files
committed
chore: make pipstar non-switchable
At the same time cleanup pystar env var docs.
1 parent d18adbb commit 116019e

5 files changed

Lines changed: 31 additions & 101 deletions

File tree

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: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,6 @@ Supported keys:
447447
* `platform_system`, defaults to a value inferred from the {attr}`os_name`.
448448
* `platform_version`, defaults to `0`.
449449
* `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-
::::
454450
""",
455451
),
456452
"index_url": attr.string(

python/private/pypi/whl_library.bzl

Lines changed: 30 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,7 @@ def _whl_library_impl(rctx):
344344
# build deps from PyPI (e.g. `flit_core`) if they are missing.
345345
extra_pip_args.extend(["--find-links", "."])
346346

347-
# also enable pipstar for any whls that are downloaded without `pip`
348-
enable_pipstar = (rp_config.enable_pipstar or whl_path) and rctx.attr.config_load
349-
enable_pipstar_extract = enable_pipstar and rp_config.bazel_8_or_later
347+
enable_pipstar_extract = rp_config.bazel_8_or_later
350348

351349
# When pipstar is enabled, Python isn't used, so there's no need
352350
# to setup env vars to run Python, unless we need to build an sdist
@@ -428,65 +426,34 @@ def _whl_library_impl(rctx):
428426
logger = logger,
429427
)
430428

431-
# NOTE @aignas 2025-09-28: if someone has an old vendored file that does not have the
432-
# dep_template set or the packages is not set either, we should still not break, best to
433-
# disable pipstar for that particular case.
434-
#
435-
# Remove non-pipstar and config_load check when we release rules_python 2.
436-
if enable_pipstar:
437-
install_dir_path = whl_path.dirname.get_child("site-packages")
438-
metadata = whl_metadata(
439-
install_dir = install_dir_path,
440-
read_fn = rctx.read,
441-
logger = logger,
442-
)
443-
namespace_package_files = pypi_repo_utils.find_namespace_package_files(rctx, install_dir_path)
444-
445-
build_file_contents = generate_whl_library_build_bazel(
446-
name = whl_path.basename,
447-
sdist_filename = sdist_filename,
448-
dep_template = rctx.attr.dep_template or "@{}{{name}}//:{{target}}".format(
449-
rctx.attr.repo_prefix,
450-
),
451-
config_load = rctx.attr.config_load,
452-
metadata_name = metadata.name,
453-
metadata_version = metadata.version,
454-
requires_dist = metadata.requires_dist,
455-
# TODO @aignas 2025-05-17: maybe have a build flag for this instead
456-
enable_implicit_namespace_pkgs = rctx.attr.enable_implicit_namespace_pkgs,
457-
# TODO @aignas 2025-04-14: load through the hub:
458-
annotation = None if not rctx.attr.annotation else struct(**json.decode(rctx.read(rctx.attr.annotation))),
459-
data_exclude = rctx.attr.pip_data_exclude,
460-
group_deps = rctx.attr.group_deps,
461-
group_name = rctx.attr.group_name,
462-
namespace_package_files = namespace_package_files,
463-
extras = requirement(rctx.attr.requirement).extras,
464-
)
465-
else:
466-
metadata = json.decode(rctx.read("metadata.json"))
467-
rctx.delete("metadata.json")
468-
469-
namespace_package_files = pypi_repo_utils.find_namespace_package_files(rctx, rctx.path("site-packages"))
470-
471-
build_file_contents = generate_whl_library_build_bazel(
472-
name = whl_path.basename,
473-
sdist_filename = sdist_filename,
474-
dep_template = rctx.attr.dep_template or "@{}{{name}}//:{{target}}".format(rctx.attr.repo_prefix),
475-
# TODO @aignas 2025-05-17: maybe have a build flag for this instead
476-
enable_implicit_namespace_pkgs = rctx.attr.enable_implicit_namespace_pkgs,
477-
# TODO @aignas 2025-04-14: load through the hub:
478-
dependencies = metadata["deps"],
479-
dependencies_by_platform = metadata["deps_by_platform"],
480-
annotation = None if not rctx.attr.annotation else struct(**json.decode(rctx.read(rctx.attr.annotation))),
481-
data_exclude = rctx.attr.pip_data_exclude,
482-
group_deps = rctx.attr.group_deps,
483-
group_name = rctx.attr.group_name,
484-
tags = [
485-
"pypi_name={}".format(metadata["name"]),
486-
"pypi_version={}".format(metadata["version"]),
487-
],
488-
namespace_package_files = namespace_package_files,
489-
)
429+
install_dir_path = whl_path.dirname.get_child("site-packages")
430+
metadata = whl_metadata(
431+
install_dir = install_dir_path,
432+
read_fn = rctx.read,
433+
logger = logger,
434+
)
435+
namespace_package_files = pypi_repo_utils.find_namespace_package_files(rctx, install_dir_path)
436+
437+
build_file_contents = generate_whl_library_build_bazel(
438+
name = whl_path.basename,
439+
sdist_filename = sdist_filename,
440+
dep_template = rctx.attr.dep_template or "@{}{{name}}//:{{target}}".format(
441+
rctx.attr.repo_prefix,
442+
),
443+
config_load = rctx.attr.config_load,
444+
metadata_name = metadata.name,
445+
metadata_version = metadata.version,
446+
requires_dist = metadata.requires_dist,
447+
# TODO @aignas 2025-05-17: maybe have a build flag for this instead
448+
enable_implicit_namespace_pkgs = rctx.attr.enable_implicit_namespace_pkgs,
449+
# TODO @aignas 2025-04-14: load through the hub:
450+
annotation = None if not rctx.attr.annotation else struct(**json.decode(rctx.read(rctx.attr.annotation))),
451+
data_exclude = rctx.attr.pip_data_exclude,
452+
group_deps = rctx.attr.group_deps,
453+
group_name = rctx.attr.group_name,
454+
namespace_package_files = namespace_package_files,
455+
extras = requirement(rctx.attr.requirement).extras,
456+
)
490457

491458
# Delete these in case the wheel had them. They generally don't cause
492459
# a problem, but let's avoid the chance of that happening.
@@ -509,7 +476,7 @@ def _whl_library_impl(rctx):
509476

510477
rctx.file("BUILD.bazel", build_file_contents)
511478

512-
if enable_pipstar and enable_pipstar_extract:
479+
if enable_pipstar_extract:
513480
if hasattr(rctx, "repo_metadata"):
514481
return rctx.repo_metadata(reproducible = True)
515482

0 commit comments

Comments
 (0)