Skip to content

Commit 3b9cdd8

Browse files
committed
fixup the default_python_version setting
1 parent f768fe6 commit 3b9cdd8

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

python/private/pypi/generate_whl_library_build_bazel.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ whl_library_targets_from_requires(
4545
def generate_whl_library_build_bazel(
4646
*,
4747
annotation = None,
48-
python_version = None,
48+
default_python_version = None,
4949
**kwargs):
5050
"""Generate a BUILD file for an unzipped Wheel
5151
5252
Args:
5353
annotation: The annotation for the build file.
54-
python_version: The python version to use to parse the METADATA.
54+
default_python_version: The python version to use to parse the METADATA.
5555
**kwargs: Extra args serialized to be passed to the
5656
{obj}`whl_library_targets`.
5757
@@ -80,8 +80,8 @@ def generate_whl_library_build_bazel(
8080
kwargs["srcs_exclude"] = annotation.srcs_exclude_glob
8181
if annotation.additive_build_content:
8282
additional_content.append(annotation.additive_build_content)
83-
if python_version:
84-
kwargs["python_version"] = repr(python_version)
83+
if default_python_version:
84+
kwargs["default_python_version"] = default_python_version
8585

8686
contents = "\n".join(
8787
[

python/private/pypi/pep508_deps.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ load(":pep508_evaluate.bzl", "evaluate")
2222
load(":pep508_platform.bzl", "platform", "platform_from_str")
2323
load(":pep508_requirement.bzl", "requirement")
2424

25-
def deps(name, *, requires_dist, platforms = [], extras = [], excludes = [], host_python_version = None):
25+
def deps(name, *, requires_dist, platforms = [], extras = [], excludes = [], default_python_version = None):
2626
"""Parse the RequiresDist from wheel METADATA
2727
2828
Args:
@@ -32,7 +32,7 @@ def deps(name, *, requires_dist, platforms = [], extras = [], excludes = [], hos
3232
excludes: {type}`list[str]` what packages should we exclude.
3333
extras: {type}`list[str]` the requested extras to generate targets for.
3434
platforms: {type}`list[str]` the list of target platform strings.
35-
host_python_version: {type}`str` the host python version.
35+
default_python_version: {type}`str` the host python version.
3636
3737
Returns:
3838
A struct with attributes:
@@ -52,15 +52,15 @@ def deps(name, *, requires_dist, platforms = [], extras = [], excludes = [], hos
5252
# drop self edges
5353
excludes = [name] + [normalize_name(x) for x in excludes]
5454

55-
host_python_version = host_python_version or DEFAULT_PYTHON_VERSION
55+
default_python_version = default_python_version or DEFAULT_PYTHON_VERSION
5656
platforms = [
57-
platform_from_str(p, python_version = host_python_version)
57+
platform_from_str(p, python_version = default_python_version)
5858
for p in platforms
5959
]
6060

6161
abis = sorted({p.abi: True for p in platforms if p.abi})
62-
if host_python_version and len(abis) > 1:
63-
_, _, minor_version = host_python_version.partition(".")
62+
if default_python_version and len(abis) > 1:
63+
_, _, minor_version = default_python_version.partition(".")
6464
minor_version, _, _ = minor_version.partition(".")
6565
default_abi = "cp3" + minor_version
6666
elif len(abis) > 1:

python/private/pypi/whl_library.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def _whl_library_impl(rctx):
387387
if BZLMOD_ENABLED:
388388
# The following attributes are unset on bzlmod and we pass data through
389389
# the hub via load statements.
390-
python_version = None
390+
default_python_version = None
391391
target_platforms = []
392392
else:
393393
# NOTE @aignas 2025-04-16: if BZLMOD_ENABLED, we should use
@@ -397,9 +397,9 @@ def _whl_library_impl(rctx):
397397
# `pip_parse` invocation, so we will have the host target platform
398398
# only. Even if somebody would change the code to support
399399
# `experimental_target_platforms`, they would be for a single python
400-
# version. Hence, using the `python_version` that we get from the
400+
# version. Hence, using the `default_python_version` that we get from the
401401
# interpreter is correct. Hence, we unset the argument if we are on bzlmod.
402-
python_version = metadata["python_version"]
402+
default_python_version = metadata["python_version"]
403403
target_platforms = rctx.attr.experimental_target_platforms or [host_platform(rctx)]
404404

405405
metadata = whl_metadata(
@@ -416,7 +416,7 @@ def _whl_library_impl(rctx):
416416
dep_template = rctx.attr.dep_template or "@{}{{name}}//:{{target}}".format(rctx.attr.repo_prefix),
417417
entry_points = entry_points,
418418
target_platforms = target_platforms,
419-
python_version = python_version,
419+
default_python_version = default_python_version,
420420
# TODO @aignas 2025-04-14: load through the hub:
421421
annotation = None if not rctx.attr.annotation else struct(**json.decode(rctx.read(rctx.attr.annotation))),
422422
data_exclude = rctx.attr.pip_data_exclude,

python/private/pypi/whl_library_targets.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def whl_library_targets_from_requires(
4141
requires_dist = [],
4242
extras = [],
4343
target_platforms = [],
44-
python_version = None,
44+
default_python_version = None,
4545
group_deps = [],
4646
**kwargs):
4747
"""The macro to create whl targets from the METADATA.
@@ -59,14 +59,14 @@ def whl_library_targets_from_requires(
5959
extras: {type}`list[str]` The list of requested extras. This essentially includes extra transitive dependencies in the final targets depending on the wheel `METADATA`.
6060
target_platforms: {type}`list[str]` The list of target platforms to create
6161
dependency closures for.
62-
python_version: {type}`str` The python version to assume when parsing
62+
default_python_version: {type}`str` The python version to assume when parsing
6363
the `METADATA`. This is only used when the `target_platforms` do not
6464
include the version information.
6565
**kwargs: Extra args passed to the {obj}`whl_library_targets`
6666
"""
6767
package_deps = _parse_requires_dist(
6868
name = name,
69-
python_version = python_version,
69+
default_python_version = default_python_version,
7070
requires_dist = requires_dist,
7171
excludes = group_deps,
7272
extras = extras,
@@ -86,7 +86,7 @@ def whl_library_targets_from_requires(
8686
def _parse_requires_dist(
8787
*,
8888
name,
89-
python_version,
89+
default_python_version,
9090
requires_dist,
9191
excludes,
9292
extras,
@@ -110,7 +110,7 @@ def _parse_requires_dist(
110110
platforms = target_platforms,
111111
excludes = excludes,
112112
extras = extras,
113-
host_python_version = python_version,
113+
default_python_version = default_python_version,
114114
)
115115

116116
def whl_library_targets(

0 commit comments

Comments
 (0)