Skip to content

Commit

Permalink
Fix buildifier warnings in rules_python_external
Browse files Browse the repository at this point in the history
Just enough to get CI green for now
Also ignore the merge commit in git blame and the subdirectory when expanding //... pattern
  • Loading branch information
Alex Eagle committed Aug 26, 2020
1 parent b381dcb commit 1d5d724
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
experimental/rules_python_external

2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aedcef6a8f039a06c87ea33cdb722779e3170ea3
b381dcb8880358a6aa63b44560f43377f8bffaf3
42 changes: 21 additions & 21 deletions experimental/rules_python_external/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
""

load("//:repositories.bzl", "all_requirements")

DEFAULT_REPOSITORY_NAME = "pip"
Expand Down Expand Up @@ -48,9 +50,7 @@ def _pip_repository_impl(rctx):
]

if rctx.attr.enable_implicit_namespace_pkgs:
args += [
"--enable_implicit_namespace_pkgs"
]
args.append("--enable_implicit_namespace_pkgs")

result = rctx.execute(
args,
Expand All @@ -68,24 +68,6 @@ def _pip_repository_impl(rctx):

pip_repository = repository_rule(
attrs = {
"requirements": attr.label(allow_single_file = True, mandatory = True),
"wheel_env": attr.string_dict(),
"python_interpreter": attr.string(default = "python3"),
"python_interpreter_target": attr.label(allow_single_file = True, doc = """
If you are using a custom python interpreter built by another repository rule,
use this attribute to specify its BUILD target. This allows pip_repository to invoke
pip using the same interpreter as your toolchain. If set, takes precedence over
python_interpreter.
"""),
# 600 is documented as default here: https://docs.bazel.build/versions/master/skylark/lib/repository_ctx.html#execute
"timeout": attr.int(default = 600),
"quiet": attr.bool(default = True),
"extra_pip_args": attr.string_list(
doc = "Extra arguments to pass on to pip. Must not contain spaces.",
),
"pip_data_exclude": attr.string_list(
doc = "Additional data exclusion parameters to add to the pip packages BUILD file.",
),
"enable_implicit_namespace_pkgs": attr.bool(
default = False,
doc = """
Expand All @@ -96,6 +78,24 @@ and py_test targets must specify either `legacy_create_init=False` or the global
This option is required to support some packages which cannot handle the conversion to pkg-util style.
""",
),
"extra_pip_args": attr.string_list(
doc = "Extra arguments to pass on to pip. Must not contain spaces.",
),
"pip_data_exclude": attr.string_list(
doc = "Additional data exclusion parameters to add to the pip packages BUILD file.",
),
"python_interpreter": attr.string(default = "python3"),
"python_interpreter_target": attr.label(allow_single_file = True, doc = """
If you are using a custom python interpreter built by another repository rule,
use this attribute to specify its BUILD target. This allows pip_repository to invoke
pip using the same interpreter as your toolchain. If set, takes precedence over
python_interpreter.
"""),
"quiet": attr.bool(default = True),
"requirements": attr.label(allow_single_file = True, mandatory = True),
# 600 is documented as default here: https://docs.bazel.build/versions/master/skylark/lib/repository_ctx.html#execute
"timeout": attr.int(default = 600),
"wheel_env": attr.string_dict(),
},
implementation = _pip_repository_impl,
)
Expand Down
1 change: 1 addition & 0 deletions experimental/rules_python_external/example/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@pip//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_binary")

# Toolchain setup, this is optional.
# Demonstrate that we can use the same python interpreter for the toolchain and executing pip in pip install (see WORKSPACE).
Expand Down
2 changes: 1 addition & 1 deletion experimental/rules_python_external/extract_wheels/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//:repositories.bzl", "all_requirements")
load("@rules_python//python:defs.bzl", "py_binary")

py_binary(
name = "extract_wheels",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("//:repositories.bzl", "requirement")

py_library(
Expand Down
2 changes: 2 additions & 0 deletions experimental/rules_python_external/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

Expand Down

0 comments on commit 1d5d724

Please sign in to comment.