generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split toolchains and repositories (#323)
### Type of change Currently, rules_py_dependencies and rules_py_toolchains are exported from the same bzl file which makes it impossible to depend on another rule and load from at the same since both macros are in the same file. This changes this to allow adding a dependency and loading from it. - Refactor (a code change that neither fixes a bug or adds a new feature) **For changes visible to end-users** - Breaking change (this change will force users to change their own code or config) - Relevant documentation has been updated ### Test plan - Covered by existing test cases
- Loading branch information
Showing
6 changed files
with
50 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Declare toolchains""" | ||
|
||
load("//py/private/toolchain:autodetecting.bzl", _register_autodetecting_python_toolchain = "register_autodetecting_python_toolchain") | ||
load("//py/private/toolchain:repo.bzl", "prerelease_toolchains_repo", "toolchains_repo") | ||
load("//py/private/toolchain:tools.bzl", "TOOLCHAIN_PLATFORMS", "prebuilt_tool_repo") | ||
load("//tools:version.bzl", "IS_PRERELEASE") | ||
|
||
|
||
register_autodetecting_python_toolchain = _register_autodetecting_python_toolchain | ||
|
||
DEFAULT_TOOLS_REPOSITORY = "rules_py_tools" | ||
|
||
def rules_py_toolchains(name = DEFAULT_TOOLS_REPOSITORY, register = True, is_prerelease = IS_PRERELEASE): | ||
"""Create a downloaded toolchain for every tool under every supported platform. | ||
Args: | ||
name: prefix used in created repositories | ||
register: whether to call the register_toolchains, should be True for WORKSPACE and False for bzlmod. | ||
is_prerelease: True iff there are no pre-built tool binaries for this version of rules_py | ||
""" | ||
if is_prerelease: | ||
prerelease_toolchains_repo(name = name) | ||
if register: | ||
native.register_toolchains( | ||
"@aspect_rules_py//py/private/toolchain/venv/...", | ||
"@aspect_rules_py//py/private/toolchain/unpack/...", | ||
) | ||
else: | ||
for platform in TOOLCHAIN_PLATFORMS.keys(): | ||
prebuilt_tool_repo(name = ".".join([name, platform]), platform = platform) | ||
toolchains_repo(name = name, user_repository_name = name) | ||
|
||
if register: | ||
native.register_toolchains("@{}//:all".format(name)) |