Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore): Remove the extra indirection and bzlmod folder #2022

Merged
merged 10 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "rules_proto", version = "6.0.0-rc1")
bazel_dep(name = "protobuf", version = "24.4", repo_name = "com_google_protobuf")

internal_deps = use_extension("//python/private/bzlmod:internal_deps.bzl", "internal_deps")
internal_deps = use_extension("//python/private:internal_deps.bzl", "internal_deps")
use_repo(
internal_deps,
"pypi__build",
Expand Down Expand Up @@ -54,7 +54,7 @@ register_toolchains("@pythons_hub//:all")
#####################
# Install twine for our own runfiles wheel publishing and allow bzlmod users to use it.

pip = use_extension("//python/private/bzlmod:pip.bzl", "pip_internal")
pip = use_extension("//python/private/pypi:pip.bzl", "pip_internal")
pip.parse(
hub_name = "rules_python_publish_deps",
python_version = "3.11",
Expand All @@ -77,7 +77,7 @@ bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_nam
bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name = "bazel_gazelle")

dev_pip = use_extension(
"//python/private/bzlmod:pip.bzl",
"//python/private/pypi:pip.bzl",
"pip_internal",
dev_dependency = True,
)
Expand Down
4 changes: 2 additions & 2 deletions python/extensions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ bzl_library(
name = "pip_bzl",
srcs = ["pip.bzl"],
visibility = ["//:__subpackages__"],
deps = ["//python/private/bzlmod:pip_bzl"],
deps = ["//python/private/pypi:pip_bzl"],
)

bzl_library(
name = "python_bzl",
srcs = ["python.bzl"],
visibility = ["//:__subpackages__"],
deps = [
"//python/private/bzlmod:python_bzl",
"//python/private:python_bzl",
],
)
2 changes: 1 addition & 1 deletion python/extensions/pip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

"pip module extension for use with bzlmod"

load("//python/private/bzlmod:pip.bzl", _pip = "pip")
load("//python/private/pypi:pip.bzl", _pip = "pip")
groodt marked this conversation as resolved.
Show resolved Hide resolved

pip = _pip
2 changes: 1 addition & 1 deletion python/extensions/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

"Python toolchain module extensions for use with bzlmod"

load("//python/private/bzlmod:python.bzl", _python = "python")
load("//python/private:python.bzl", _python = "python")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we should have a separate python/private/toolchain or python/private/interpreter directory, which could have all of the python extension related things. The pythons_hub.bzl could be in that folder as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. Probably an independent PR? It's a bigger change to discuss. Because we could also leave the python stuff where it is and move everything else out, which then makes it less urgent to change the Python toolchain or language rules.


python = _python
23 changes: 22 additions & 1 deletion python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ licenses(["notice"])
filegroup(
name = "distribution",
srcs = glob(["**"]) + [
"//python/private/bzlmod:distribution",
"//python/private/common:distribution",
"//python/private/proto:distribution",
"//python/private/pypi:distribution",
Expand Down Expand Up @@ -128,6 +127,28 @@ bzl_library(
srcs = ["normalize_name.bzl"],
)

bzl_library(
name = "python_bzl",
srcs = ["python.bzl"],
deps = [
":pythons_hub_bzl",
":toolchains_repo_bzl",
":util_bzl",
"//python:repositories_bzl",
"@bazel_features//:features",
],
)

bzl_library(
name = "pythons_hub_bzl",
srcs = ["pythons_hub.bzl"],
deps = [
":full_version_bzl",
":py_toolchain_suite_bzl",
"//python:versions_bzl",
],
)

bzl_library(
name = "py_cc_toolchain_bzl",
srcs = [
Expand Down
55 changes: 0 additions & 55 deletions python/private/bzlmod/BUILD.bazel

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"Python toolchain module extension for internal rule use"

load("@bazel_skylib//lib:modules.bzl", "modules")
load("//python/private:internal_config_repo.bzl", "internal_config_repo")
load("//python/private/pypi:deps.bzl", "pypi_deps")
load(":internal_config_repo.bzl", "internal_config_repo")

def _internal_deps():
internal_config_repo(name = "rules_python_internal")
Expand Down
12 changes: 10 additions & 2 deletions python/private/pypi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ bzl_library(
)

bzl_library(
name = "bzlmod_bzl",
srcs = ["bzlmod.bzl"],
name = "extension_bzl",
srcs = ["extension.bzl"],
deps = [
":attrs_bzl",
":hub_repository_bzl",
Expand Down Expand Up @@ -190,6 +190,14 @@ bzl_library(
],
)

bzl_library(
name = "pip_bzl",
srcs = ["pip.bzl"],
deps = [
":extension_bzl",
],
)

bzl_library(
name = "pip_compile_bzl",
srcs = ["pip_compile.bzl"],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"pip module extensions for use with bzlmod."

load("//python/private/pypi:bzlmod.bzl", "pypi", "pypi_internal")
load("//python/private/pypi:extension.bzl", "pypi", "pypi_internal")

pip = pypi
pip_internal = pypi_internal
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

load("@bazel_features//:features.bzl", "bazel_features")
load("//python:repositories.bzl", "python_register_toolchains")
load("//python/private:toolchains_repo.bzl", "multi_toolchain_aliases")
load("//python/private:util.bzl", "IS_BAZEL_6_4_OR_HIGHER")
load(":pythons_hub.bzl", "hub_repo")
load(":toolchains_repo.bzl", "multi_toolchain_aliases")
load(":util.bzl", "IS_BAZEL_6_4_OR_HIGHER")

# This limit can be increased essentially arbitrarily, but doing so will cause a rebuild of all
# targets using any of these toolchains due to the changed repository name.
Expand Down