Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
2e51b61
refactor: define internal vars for each tag class
aignas Aug 8, 2024
e7e2cbe
refactor: rename some classes and thread the available tool versions
aignas Aug 8, 2024
330008a
spike the override tag classes
aignas Aug 8, 2024
2d8642c
add base_url override as well
aignas Aug 8, 2024
12d8ec6
refactor: move the register_all_versions to python.override
aignas Aug 9, 2024
5ec8acd
wip
aignas Aug 13, 2024
35492e4
Add an example on how to override the URLs
aignas Aug 23, 2024
4b5da0e
add a doc
aignas Aug 23, 2024
c765d11
minor refactoring in processing the tag classes
aignas Aug 23, 2024
46af7f9
version_override -> single_version_override
aignas Aug 26, 2024
0a88a6e
improve docs - add repositories.bzl docs and improve docs for bzlmod
aignas Aug 26, 2024
b0e2f13
clarify docs
aignas Aug 26, 2024
dd70a04
cleanup the override impl
aignas Aug 27, 2024
53105dc
make patch_strip handling identical to strip_prefix
aignas Aug 27, 2024
30e922d
add docs
aignas Aug 27, 2024
1f28f07
add some thoughts
aignas Aug 28, 2024
82ae48f
refactor a little
aignas Aug 28, 2024
2a30710
ensure that only the root module can do overrides
aignas Aug 30, 2024
260d458
chore: move full_version usage to the extension
aignas Aug 30, 2024
eba99bd
allow overriding the minor_mapping used to register the toolchains
aignas Aug 30, 2024
dc039be
reduce the API a bit
aignas Aug 30, 2024
f2433f9
correctly set the overrides
aignas Aug 30, 2024
c262084
allow overriding just about everything
aignas Aug 30, 2024
de1f69d
wip
aignas Aug 30, 2024
1cddfe9
docs
aignas Aug 30, 2024
f4ac7c2
docs
aignas Aug 30, 2024
d0493ec
docs
aignas Aug 30, 2024
0508e2b
docs
aignas Aug 30, 2024
7379373
docs
aignas Aug 30, 2024
42c3f23
docs
aignas Aug 30, 2024
9553168
Merge branch 'main' into python-override
aignas Aug 31, 2024
e3bb92d
fix docs
aignas Aug 31, 2024
915a6ff
spike a unit test
aignas Sep 1, 2024
cd5b101
move the ignore_root_user_error to a different place
aignas Sep 1, 2024
3655ab0
move coverage registration tool so that we can reuse structs
aignas Sep 1, 2024
3ff9618
remove a duplicated var
aignas Sep 1, 2024
7beb84a
remove the default_toolchain from the struct
aignas Sep 1, 2024
933e6f8
make global_toolchain_versions an implementation detail
aignas Sep 1, 2024
ad6edba
refactor tests and ensure we have an ordering test
aignas Sep 1, 2024
3a459c8
refactor: expose from the module processing function only the bare mi…
aignas Sep 1, 2024
760d0eb
add a test to check what happens if multiple toolchain calls are made
aignas Sep 1, 2024
fab7a23
add todo notes
aignas Sep 1, 2024
061b760
remove todo
aignas Sep 1, 2024
c32b259
docs: attempt to add `module_ctx` inventory
aignas Sep 1, 2024
671d0d9
wip
aignas Sep 1, 2024
5e5b8f6
Allow overriding ignore_root_user_error via override API
aignas Sep 2, 2024
e17f208
test: add more override tests
aignas Sep 2, 2024
75314e5
refactor: dryer tests
aignas Sep 2, 2024
7a173e4
refactor: dryer tests
aignas Sep 2, 2024
43e0168
test that we can set patches
aignas Sep 2, 2024
a12751c
add a test for single version platform override
aignas Sep 2, 2024
a04d245
Merge branch 'main' into python-override
aignas Sep 2, 2024
4e2bb3e
docs
aignas Sep 2, 2024
f60febd
ensure that the new python version can be also added with a different…
aignas Sep 2, 2024
0a40f88
add a reference to a ticket
aignas Sep 2, 2024
83d2c64
fix the examples/bzlmod
aignas Sep 2, 2024
bd06e6d
improve example docs
aignas Sep 2, 2024
88a1d5e
cleanup
aignas Sep 2, 2024
581191d
remove TODOs
aignas Sep 3, 2024
c8b0833
refactor: add a semver function to consolidate code
aignas Sep 3, 2024
0aac200
improve the docs
aignas Sep 3, 2024
246febe
update the lock file
aignas Sep 3, 2024
cd3f844
Merge branch 'main' into python-override
aignas Sep 3, 2024
266e9ab
add path to inventory
aignas Sep 3, 2024
09b9cd6
fix integration tests
aignas Sep 4, 2024
93684eb
register_all_versions fix and fixup tests
aignas Sep 4, 2024
2f89234
improve the docs
aignas Sep 4, 2024
6cfd483
fixup tests
aignas Sep 5, 2024
cf96d55
Merge branch 'main' into python-override
aignas Sep 6, 2024
def721a
fix merge conflicts
aignas Sep 6, 2024
80a81aa
more cleanup
aignas Sep 6, 2024
8ad05af
infer MINOR_MAPPING automatically when registering toolchains
aignas Sep 6, 2024
f8d143f
chore: bazel mod deps --lockfile_mode=update
aignas Sep 6, 2024
f844962
fix a case when the first module in mctx.modules is not a root module
aignas Sep 6, 2024
f70676c
further cleanup
aignas Sep 6, 2024
d844c01
cleanup
aignas Sep 6, 2024
f0209a2
cleanup
aignas Sep 6, 2024
293685e
fixup
aignas Sep 6, 2024
dc07b3e
simplify
aignas Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ A brief description of the categories of changes:
[x.x.x]: https://github.com/bazelbuild/rules_python/releases/tag/x.x.x

### Changed
* (gazelle): Update error messages when unable to resolve a dependency to be more human-friendly.
* (gazelle): Update error messages when unable to resolve a dependency to be
more human-friendly.
* (toolchain): The toolchain patches now expose the `patch_strip` attribute
that one should use when patching toolchains. Please set it if you are
patching python interpreter. In the next release the default will be set to
`0` which better reflects the defaults used in public `bazel` APIs.

### Fixed
* (whl_library): Remove `--no-index` and add `--no-build-isolation` to the
Expand All @@ -43,7 +48,11 @@ A brief description of the categories of changes:
* (bzlmod) Properly handle relative path URLs in parse_simpleapi_html.bzl

### Added
* Nothing yet
* (bzlmod): Toolchain overrides can now be done to fully override anything from
within the TOOL_VERSIONS dict using the new
{rule}`python.override`,
{rule}`python.single_version_override` and
{rule}`python.single_version_platform_override`.

### Removed
* Nothing yet
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dev_python = use_extension(
"python",
dev_dependency = True,
)
dev_python.rules_python_private_testing(
dev_python.override(
register_all_versions = True,
)

Expand Down
2 changes: 2 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ sphinx_stardocs(
"//python/private/common:py_library_rule_bazel_bzl",
"//python/private/common:py_runtime_rule_bzl",
"//python/private/common:py_test_rule_bazel_bzl",
# FIXME @aignas 2024-08-26: should we have this here?
"//python:repositories_bzl",
] + ([
# Bazel 6 + Stardoc isn't able to parse something about the python bzlmod extension
"//python/extensions:python_bzl",
Expand Down
41 changes: 41 additions & 0 deletions examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,47 @@ python.toolchain(
python_version = "3.10",
)

# One can override the actual toolchain versions that are available
python.override(
available_python_versions = [
"3.10.9",
"3.9.19",
# Keep the following versions which are present in MINOR_MAPPING, but
# are not present above
"3.10.14",
],
)

# Or the sources that the toolchains come from for all platforms
python.single_version_override(
patch_strip = 1,
# The user can specify patches to be applied to all interpreters, they will
# be applied before the platform specific patches are applied.
patches = [],
sha256 = {
"aarch64-apple-darwin": "1409acd9a506e2d1d3b65c1488db4e40d8f19d09a7df099667c87a506f71c0ef",
"aarch64-unknown-linux-gnu": "8f351a8cc348bb45c0f95b8634c8345ec6e749e483384188ad865b7428342703",
"x86_64-apple-darwin": "8146ad4390710ec69b316a5649912df0247d35f4a42e2aa9615bffd87b3e235a",
"x86_64-pc-windows-msvc": "a1d9a594cd3103baa24937ad9150c1a389544b4350e859200b3e5c036ac352bd",
"x86_64-unknown-linux-gnu": "9b64eca2a94f7aff9409ad70bdaa7fbbf8148692662e764401883957943620dd",
},
urls = ["20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz"],
version = "3.10.2",
)

# Or a single platform. This can be used in combination with the
# `single_version_override` and `single_version_platform_override` will be
# applied after `single_version_override`.
# TODO @aignas 2024-08-27: implement that
python.single_version_platform_override(
patch_strip = 1,
patches = [],
platform = "aarch64-apple-darwin",
sha256 = "1409acd9a506e2d1d3b65c1488db4e40d8f19d09a7df099667c87a506f71c0ef",
urls = ["20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz"],
version = "3.10.2",
)

# You only need to load this repositories if you are using multiple Python versions.
# See the tests folder for various examples on using multiple Python versions.
# The names "python_3_9" and "python_3_10" are autmatically created by the repo
Expand Down
4 changes: 2 additions & 2 deletions examples/bzlmod/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ bzl_library(
name = "python_bzl",
srcs = ["python.bzl"],
deps = [
":python_repositories_bzl",
":pythons_hub_bzl",
":repo_utils_bzl",
":toolchains_repo_bzl",
":util_bzl",
"//python:repositories_bzl",
"@bazel_features//:features",
],
)
Expand Down Expand Up @@ -298,6 +298,7 @@ bzl_library(
srcs = ["toolchains_repo.bzl"],
deps = [
":repo_utils_bzl",
":text_util_bzl",
"//python:versions_bzl",
],
)
Expand Down
8 changes: 4 additions & 4 deletions python/private/common/py_runtime_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ See @bazel_tools//tools/python:python_bootstrap_template.txt for more variables.
"coverage_tool": attr.label(
allow_files = False,
doc = """
This is a target to use for collecting code coverage information from `py_binary`
and `py_test` targets.
This is a target to use for collecting code coverage information from
{rule}`py_binary` and {rule}`py_test` targets.

If set, the target must either produce a single file or be an executable target.
The path to the single file, or the executable if the target is executable,
Expand All @@ -214,7 +214,7 @@ runfiles will be added to the runfiles when coverage is enabled.

The entry point for the tool must be loadable by a Python interpreter (e.g. a
`.py` or `.pyc` file). It must accept the command line arguments
of coverage.py (https://coverage.readthedocs.io), at least including
of [`coverage.py`](https://coverage.readthedocs.io), at least including
the `run` and `lcov` subcommands.
""",
),
Expand Down Expand Up @@ -306,7 +306,7 @@ The template to use when two stage bootstrapping is enabled
default = DEFAULT_STUB_SHEBANG,
doc = """
"Shebang" expression prepended to the bootstrapping Python stub script
used when executing `py_binary` targets.
used when executing {rule}`py_binary` targets.

See https://github.com/bazelbuild/bazel/issues/8685 for
motivation.
Expand Down
Loading