8000 feat(bzlmod): mark pip extension as os/arch dependent (#1433) · kilian-funk/rules_python@cdb5902 · GitHub
[go: up one dir, main page]

Skip to content

Commit cdb5902

Browse files
aignasrickeylev
andauthored
feat(bzlmod): mark pip extension as os/arch dependent (bazel-contrib#1433)
This ensures that under bzlmod with `--lockfile-mode=update` we would generate an entry per os/arch, which is needed because the hermetic toolchain interpreter path is os/arch dependent. Summary: - add bazel_features dep - mark the pip extension as arch/os dependent Related: bazelbuild/bazel#19154 --------- Co-authored-by: Richard Levasseur <richardlev@gmail.com>
1 parent f2a4dd5 commit cdb5902

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ A brief description of the categories of changes:
3737
cases. An error about `@rules_python_internal` means the `py_repositories()`
3838
call is missing in `WORKSPACE`.
3939

40+
* (bzlmod) The `pip.parse` extension will generate os/arch specific lock
41+
file entries on `bazel>=6.4`.
42+
4043

4144
### Added
4245

MODULE.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ module(
44
compatibility_level = 1,
55
)
66

7-
bazel_dep(name = "platforms", version = "0.0.4")
7+
bazel_dep(name = "bazel_features", version = "1.1.0")
88
bazel_dep(name = "bazel_skylib", version = "1.3.0")
9+
bazel_dep(name = "platforms", version = "0.0.4")
910

1011
# Those are loaded only when using py_proto_library
1112
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

python/extensions/pip.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"pip module extension for use with bzlmod"
1616

17+
load("@bazel_features//:features.bzl", "bazel_features")
1718
load("@pythons_hub//:interpreters.bzl", "DEFAULT_PYTHON_VERSION", "INTERPRETER_LABELS")
1819
load(
1920
"//python/pip_install:pip_repository.bzl",
@@ -380,6 +381,17 @@ cannot have a child module that uses the same `hub_name`.
380381
}
381382
return attrs
382383

384+
def _extension_extra_args():
385+
args = {}
386+
387+
if bazel_features.external_deps.module_extension_has_os_arch_dependent:
388+
args = args | {
389+
"arch_dependent": True,
390+
"os_dependent": True,
391+
}
392+
393+
return args
394+
383395
pip = module_extension(
384396
doc = """\
385397
This extension is used to make dependencies from pip available.
@@ -422,6 +434,7 @@ extension.
422434
""",
423435
),
424436
},
437+
**_extension_extra_args()
425438
)
426439

427440
def _whl_mods_repo_impl(rctx):

0 commit comments

Comments
 (0)
0