Skip to content

Commit 3a1f889

Browse files
committed
Init toolchain
1 parent 750d8da commit 3a1f889

File tree

8 files changed

+7
-37
lines changed

8 files changed

+7
-37
lines changed

examples/bzlmod/BUILD.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ load("@python_versions//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile
1212
load("@python_versions//3.9:defs.bzl", compile_pip_requirements_3_9 = "compile_pip_requirements")
1313
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
1414

15-
exports_files([
16-
"requirements.in",
17-
])
18-
1915
# This stanza calls a rule that generates targets for managing pip dependencies
2016
# with pip-compile.
2117
compile_pip_requirements_3_9(

examples/bzlmod/MODULE.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ use_repo(pip, "whl_mods_hub")
9494
# Alternatively, `python_interpreter_target` can be used to directly specify
9595
# the Python interpreter to run to resolve dependencies.
9696
pip.parse(
97-
dependencies_file = ":requirements.in",
9897
# We can use `envsubst in the above
9998
envsubst = ["PIP_INDEX_URL"],
10099
# Use the bazel downloader to query the simple API for downloading the sources
@@ -149,7 +148,6 @@ pip.parse(
149148
},
150149
)
151150
pip.parse(
152-
dependencies_file = ":requirements.in",
153151
experimental_requirement_cycles = {
154152
"sphinx": [
155153
"sphinx",

examples/bzlmod/other_module/BUILD.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
load("@python_versions//3.11:defs.bzl", compile_pip_requirements_311 = "compile_pip_requirements")
22

3-
exports_files([
4-
"requirements.in",
5-
])
6-
73
# NOTE: To update the requirements, you need to uncomment the rules_python
84
# override in the MODULE.bazel.
95
compile_pip_requirements_311(

python/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ that @rules_python//python is only concerned with the core rules.
2525

2626
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2727
load("//python/private:autodetecting_toolchain.bzl", "define_autodetecting_toolchain")
28+
load("//python/private/pypi:resolved_toolchain.bzl", "uv_resolved_toolchain")
2829
load(":current_py_toolchain.bzl", "current_py_toolchain")
2930

3031
package(default_visibility = ["//visibility:public"])
@@ -348,7 +349,7 @@ toolchain_type(
348349
visibility = ["//visibility:public"],
349350
)
350351

351-
resolved_toolchain(
352+
uv_resolved_toolchain(
352353
name = "uv_resolved_toolchain",
353354
# Marked manual so that `bazel test //...` passes
354355
# even if no toolchain is registered.

python/extensions.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Overriding the default is only permitted in the root module.
1515
def _uv_toolchain_extension(module_ctx):
1616
registrations = {}
1717
for mod in module_ctx.modules:
18-
for toolchain in mod.tags.uv_toolchain:
18+
for toolchain in mod.tags.toolchain:
1919
if toolchain.name != _DEFAULT_NAME and not mod.is_root:
2020
fail("""\
2121
Only the root module may override the default name for the uv toolchain.

python/private/pypi/bzlmod.bzl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ def _pip_impl(module_ctx):
483483
},
484484
default_version = _major_minor_version(DEFAULT_PYTHON_VERSION),
485485
groups = hub_group_map.get(hub_name),
486-
dependencies_file = pip_attr.dependencies_file, # buildifier: disable=uninitialized
487486
)
488487

489488
if bazel_features.external_deps.extension_metadata_has_reproducible:
@@ -515,10 +514,6 @@ def _pip_parse_ext_attrs(**kwargs):
515514
A dict of attributes.
516515
"""
517516
attrs = dict({
518-
"dependencies_file": attr.label(
519-
mandatory = True,
520-
allow_single_file = [".in", ".toml"],
521-
),
522517
"experimental_extra_index_urls": attr.string_list(
523518
doc = """\
524519
The extra index URLs to use for downloading wheels using bazel downloader.

python/private/pypi/hub_repository.bzl

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ load("@rules_python//python/private:py_lock_dependencies.bzl", "py_lock_dependen
2727
2828
# Ensure the `requirements.bzl` source can be accessed by stardoc, since users load() from it
2929
exports_files(["requirements.bzl"])
30-
31-
py_lock_dependencies(
32-
name = "lock",
33-
dependencies_file = "{dependencies_file}",
34-
visibility = ["//visibility:public"],
35-
)
3630
"""
3731

3832
def _impl(rctx):
@@ -55,9 +49,7 @@ def _impl(rctx):
5549
# `requirement`, et al. macros.
5650
macro_tmpl = "@@{name}//{{}}:{{}}".format(name = rctx.attr.name)
5751

58-
rctx.file("BUILD.bazel", _BUILD_FILE_CONTENTS.format(
59-
dependencies_file = str(rctx.attr.dependencies_file),
60-
))
52+
rctx.file("BUILD.bazel", _BUILD_FILE_CONTENTS)
6153
rctx.template("requirements.bzl", rctx.attr._template, substitutions = {
6254
"%%ALL_DATA_REQUIREMENTS%%": render.list([
6355
macro_tmpl.format(p, "data")
@@ -76,26 +68,16 @@ def _impl(rctx):
7668

7769
hub_repository = repository_rule(
7870
attrs = {
79-
"constraints_file": attr.label(
80-
allow_single_file = [".txt"],
81-
),
8271
"default_version": attr.string(
8372
mandatory = True,
8473
doc = """\
8574
This is the default python version in the format of X.Y. This should match
8675
what is setup by the 'python' extension using the 'is_default = True'
8776
setting.""",
8877
),
89-
"dependencies_file": attr.label(
90-
mandatory = True,
91-
allow_single_file = [".in", ".toml"],
92-
),
9378
"groups": attr.string_list_dict(
9479
mandatory = False,
9580
),
96-
"overrides_file": attr.label(
97-
allow_single_file = [".txt"],
98-
),
9981
"repo_name": attr.string(
10082
mandatory = True,
10183
doc = "The apparent name of the repo. This is needed because in bzlmod, the name attribute becomes the canonical name.",

python/private/py_lock_dependencies.bzl renamed to python/private/pypi/py_lock_dependencies.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"Rule for locking third-party dependencies."
1616

1717
def _py_lock_dependencies(ctx):
18-
uv = ctx.toolchains["//python/private/uv:toolchain_type"].uv
18+
info = ctx.toolchains["//python/:uv_toolchain_type"].uvtoolchaininfo
19+
uv = info.uv_path
20+
1921
python = ctx.toolchains["@bazel_tools//tools/python:toolchain_type"].py3_runtime.interpreter
2022
dependencies_file = ctx.file.dependencies_file
2123

0 commit comments

Comments
 (0)