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: Autoformat with buildifier #480

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@pypi//:requirements.bzl", "all_whl_requirements")
load("@rules_python//python:defs.bzl", "py_runtime", "py_runtime_pair")
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")
load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
load("@rules_python//python:defs.bzl", "py_runtime", "py_runtime_pair")
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")

# gazelle:exclude internal_python_deps.bzl
# gazelle:exclude internal_deps.bzl
Expand Down
7 changes: 2 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module(
name = "aspect_rules_py",
compatibility_level = 1,
version = "0.0.0",
compatibility_level = 1,
)

# Lower-bound versions of direct dependencies.
Expand All @@ -12,7 +12,7 @@ module(
# py_image_layer requires 2.x for the `tar` rule.
# py_image_layer needs compute_unused_inputs attribute
# py_image_layer needs repo_mapping fix.
bazel_dep(name = "aspect_bazel_lib", version = "2.9.4")
bazel_dep(name = "aspect_bazel_lib", version = "2.9.4")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "rules_python", version = "0.29.0")
bazel_dep(name = "platforms", version = "0.0.7")
Expand Down Expand Up @@ -53,7 +53,6 @@ rust = use_extension(
"rust",
# In released versions: dev_dependency = True
)

rust.toolchain(
edition = "2021",
versions = ["1.81.0"],
Expand All @@ -70,7 +69,6 @@ crate = use_extension(
"crate",
# In released versions: dev_dependency = True
)

crate.from_cargo(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
Expand All @@ -83,5 +81,4 @@ crate.from_cargo(
"//py/tools/unpack_bin:Cargo.toml",
],
)

use_repo(crate, "crate_index")
3 changes: 2 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

############################################
# Gazelle, for generating bzl_library targets
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

Comment on lines +118 to 123
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is the only one where I am not sure if the order has an impact

go_rules_dependencies()

Expand Down
5 changes: 3 additions & 2 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Bazel dependencies"
bazel_dep(name = "aspect_rules_py", dev_dependency = True, version = "0.0.0")

bazel_dep(name = "aspect_rules_py", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_py",
path = "../..",
Expand All @@ -15,12 +15,13 @@ rust.toolchain(
versions = ["1.81.0"],
)
use_repo(rust, "rust_toolchains")

register_toolchains("@rust_toolchains//:all")

#---SNIP--- Below here is re-used in the snippet published on releases
# Minimum version needs:
# feat: add interpreter_version_info to py_runtime by @mattem in #1671
bazel_dep(name = "rules_python", dev_dependency = True, version = "0.29.0")
bazel_dep(name = "rules_python", version = "0.29.0", dev_dependency = True)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
Expand Down
5 changes: 3 additions & 2 deletions e2e/system-interpreter/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Bazel dependencies"
bazel_dep(name = "aspect_rules_py", dev_dependency = True, version = "0.0.0")

bazel_dep(name = "aspect_rules_py", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_py",
path = "../..",
Expand All @@ -15,11 +15,12 @@ rust.toolchain(
versions = ["1.81.0"],
)
use_repo(rust, "rust_toolchains")

register_toolchains("@rust_toolchains//:all")

#---SNIP--- Below here is re-used in the snippet published on releases
# Minimum version needs:
# feat: add interpreter_version_info to py_runtime by @mattem in #1671
bazel_dep(name = "rules_python", dev_dependency = True, version = "0.29.0")
bazel_dep(name = "rules_python", version = "0.29.0", dev_dependency = True)

register_toolchains("//:default")
1 change: 0 additions & 1 deletion e2e/use_release/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
bazel_dep(name = "aspect_rules_py", version = "0.7.0")

local_path_override(
module_name = "aspect_rules_py",
path = "../..",
Expand Down
8 changes: 5 additions & 3 deletions examples/multi_version/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ load("@aspect_rules_py//py:defs.bzl", "py_binary", "py_pytest_main", "py_test")
py_binary(
name = "multi_version",
srcs = ["say.py"],
python_version = "3.8.12",
deps = [
"@pypi_cowsay//:pkg",
],
python_version = "3.8.12"
)

py_pytest_main(
name = "__test__",
deps = ["@pypi_pytest//:pkg"],
Expand All @@ -20,11 +21,12 @@ py_test(
":__test__",
],
main = ":__test__.py",
python_version = "3.8.12",
deps = [
":__test__",
],
python_version = "3.8.12"
)

py_test(
name = "py_version_default_test",
srcs = [
Expand All @@ -35,4 +37,4 @@ py_test(
deps = [
":__test__",
],
)
)
8 changes: 4 additions & 4 deletions examples/py_pex_binary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ py_binary(
srcs = ["say.py"],
data = ["data.txt"],
env = {
"TEST": "1"
"TEST": "1",
},
deps = [
"@pypi_cowsay//:pkg",
"@bazel_tools//tools/python/runfiles",
"@pypi_cowsay//:pkg",
],
)

py_pex_binary(
name = "py_pex_binary",
binary = ":binary",
inject_env = {
"TEST": "1"
}
"TEST": "1",
},
)
2 changes: 1 addition & 1 deletion examples/uv_pip_compile/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
load("@rules_uv//uv:pip.bzl", "pip_compile")

pip_compile(name = "generate_requirements_txt")
pip_compile(name = "generate_requirements_txt")
5 changes: 3 additions & 2 deletions examples/uv_pip_compile/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"uv pip compile example with py"

bazel_dep(name = "rules_uv", version = "0.14.0", dev_dependency = True)

bazel_dep(name = "rules_python", version = "0.34.0")
bazel_dep(name = "aspect_rules_py", version = "0.7.4", dev_dependency = True)

bazel_dep(name = "aspect_rules_py", version = "0.7.4", dev_dependency = True)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.9.13")

use_repo(python, "python_3_9_13")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
Expand Down
6 changes: 3 additions & 3 deletions py/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
# For stardoc to reference the files
exports_files(["defs.bzl"])

# For Bazel 6.x compatibility, since
# For Bazel 6.x compatibility, since
# PyRuntimeInfo shipped only with Bazel 7
# Users can set, e.g. --@aspect_rules_py//py:interpreter_version=3.9.18
string_flag(
Expand All @@ -31,14 +31,14 @@ bzl_library(
deps = [
"//py/private:py_binary",
"//py/private:py_executable",
"//py/private:py_image_layer",
"//py/private:py_library",
"//py/private:py_pex_binary",
"//py/private:py_pytest_main",
"//py/private:py_unpacked_wheel",
"//py/private:py_venv",
"//py/private:py_wheel",
"//py/private:virtual",
"//py/private:py_pex_binary",
"//py/private:py_image_layer",
"@aspect_bazel_lib//lib:utils",
],
)
2 changes: 1 addition & 1 deletion py/extensions.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"Module Extensions used from MODULE.bazel"

load(":toolchains.bzl", "DEFAULT_TOOLS_REPOSITORY", "rules_py_toolchains")
load("//tools:version.bzl", "IS_PRERELEASE")
load(":toolchains.bzl", "DEFAULT_TOOLS_REPOSITORY", "rules_py_toolchains")

py_toolchain = tag_class(attrs = {
"name": attr.string(doc = """\
Expand Down
5 changes: 2 additions & 3 deletions py/private/py_image_layer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ awk < $< 'BEGIN {
**kwargs
)


def py_image_layer(name, binary, root = "/", layer_groups = {}, compress = "gzip", tar_args = ["--options", "gzip:!timestamp"], compute_unused_inputs = 1, platform = None, **kwargs):
"""Produce a separate tar output for each layer of a python app

Expand All @@ -103,7 +102,7 @@ def py_image_layer(name, binary, root = "/", layer_groups = {}, compress = "gzip
1. `layer_groups` are checked first.
2. If no match is found for `layer_groups`, the `default layer groups` are checked.
3. Any remaining files are placed into the default layer.

The default layer groups are:
```
{
Expand Down Expand Up @@ -157,7 +156,7 @@ def py_image_layer(name, binary, root = "/", layer_groups = {}, compress = "gzip
**kwargs
)
srcs.append(tar_target)

if platform:
platform_transition_filegroup(
name = name,
Expand Down
4 changes: 2 additions & 2 deletions py/private/py_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Supports "virtual" dependencies with a `virtual_deps` attribute, which lists pac
without binding them to a particular version of that package.
"""

load("@rules_python//python:defs.bzl", "PyInfo")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_python//python:defs.bzl", "PyInfo")
load("//py/private:providers.bzl", "PyVirtualInfo")

def _make_instrumented_files_info(ctx, extra_source_attributes = [], extra_dependency_attributes = []):
Expand Down
2 changes: 1 addition & 1 deletion py/private/py_semantics.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Functions to determine which Python toolchain to use"""

load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN")

_INTERPRETER_FLAGS = [
# -B Don't write .pyc files on import. See also PYTHONDONTWRITEBYTECODE.
Expand Down
4 changes: 2 additions & 2 deletions py/private/py_unpacked_wheel.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Unpacks a Python wheel into a directory and returns a PyInfo provider that represents that wheel"""

load("@rules_python//python:defs.bzl", "PyInfo")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_python//python:defs.bzl", "PyInfo")
load("//py/private:py_library.bzl", _py_library = "py_library_utils")
load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "UNPACK_TOOLCHAIN")
load("//py/private:py_semantics.bzl", _py_semantics = "semantics")
load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "UNPACK_TOOLCHAIN")

def _py_unpacked_wheel_impl(ctx):
py_toolchain = _py_semantics.resolve_toolchain(ctx)
Expand Down
2 changes: 1 addition & 1 deletion py/private/py_venv.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Using `py_venv` directly is only required for cases where those defaults do not
> As an implementation detail, this currently uses <https://github.com/prefix-dev/rip> which is a very fast Rust-based tool.
"""

load("@rules_python//python:defs.bzl", "PyInfo")
load("@aspect_bazel_lib//lib:paths.bzl", "BASH_RLOCATION_FUNCTION", "to_rlocation_path")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_python//python:defs.bzl", "PyInfo")
load("//py/private:providers.bzl", "PyVirtualInfo")
load("//py/private:py_library.bzl", _py_library = "py_library_utils")
load("//py/private:py_semantics.bzl", _py_semantics = "semantics")
Expand Down
3 changes: 1 addition & 2 deletions py/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def http_archive(name, **kwargs):
maybe(_http_archive, name = name, **kwargs)


# WARNING: any changes in this function may be BREAKING CHANGES for users
# because we'll fetch a dependency which may be different from one that
# they were previously fetching later in their WORKSPACE setup, and now
Expand Down Expand Up @@ -43,4 +42,4 @@ def rules_py_dependencies():
sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
strip_prefix = "rules_python-0.31.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz",
)
)
2 changes: 1 addition & 1 deletion py/tests/external-deps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//py:defs.bzl", "py_binary", "py_library", "py_test")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("//py:defs.bzl", "py_binary", "py_library", "py_test")
load("//py/tests/external-deps/custom-macro:macro.bzl", "click_cli_binary")

py_library(
Expand Down
2 changes: 1 addition & 1 deletion py/tests/external-deps/sibling-package/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//py/tests/external-deps/custom-macro:macro.bzl", "click_cli_binary")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("//py/tests/external-deps/custom-macro:macro.bzl", "click_cli_binary")

click_cli_binary(
name = "click_sibling_binary",
Expand Down
2 changes: 1 addition & 1 deletion py/tests/py-binary/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
load("@aspect_bazel_lib//lib:run_binary.bzl", "run_binary")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
load("//py:defs.bzl", "py_binary")

#################
Expand Down
5 changes: 2 additions & 3 deletions py/tests/py_image_layer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//py:defs.bzl", "py_image_layer", "py_binary")
load("//py:defs.bzl", "py_binary", "py_image_layer")
load("asserts.bzl", "assert_tar_listing")

platform(
Expand All @@ -9,7 +9,6 @@ platform(
],
)


# Case 1: Basic usage
py_binary(
name = "my_app_bin",
Expand All @@ -26,4 +25,4 @@ assert_tar_listing(
name = "my_app_layers_test",
actual = [":my_app_layers"],
expected = ":my_app_layers.listing",
)
)
2 changes: 1 addition & 1 deletion py/tests/py_image_layer/asserts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def assert_tar_listing(name, actual, expected):
out_file = expected,
testonly = True,
tags = ["skip-on-bazel6"],
)
)
2 changes: 1 addition & 1 deletion py/tests/virtual/django/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")
load("@django//:requirements.bzl", "all_whl_requirements_by_package", "requirement")
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")
load("//py:defs.bzl", "py_binary", "py_library", "py_unpacked_wheel", "resolutions")

django_resolutions = resolutions.from_requirements(all_whl_requirements_by_package, requirement)
Expand Down
5 changes: 2 additions & 3 deletions py/toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def rules_py_toolchains(name = DEFAULT_TOOLS_REPOSITORY, register = True, is_pre
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
"""

register_tar_toolchains(register = register)

if is_prerelease:
Expand All @@ -37,10 +37,9 @@ def rules_py_toolchains(name = DEFAULT_TOOLS_REPOSITORY, register = True, is_pre
if register:
native.register_toolchains("@{}//:all".format(name))


http_file(
name = "rules_py_pex_2_3_1",
urls = ["https://files.pythonhosted.org/packages/e7/d0/fbda2a4d41d62d86ce53f5ae4fbaaee8c34070f75bb7ca009090510ae874/pex-2.3.1-py2.py3-none-any.whl"],
sha256 = "64692a5bf6f298403aab930d22f0d836ae4736c5bc820e262e9092fe8c56f830",
downloaded_file_path = "pex-2.3.1-py2.py3-none-any.whl",
)
)
Loading