Skip to content

Commit 173290e

Browse files
laurentlbbrandjon
authored andcommitted
Run buildifier --lint=fix (bazel-contrib#138)
This reformats the files and applies some automated fixes. This should help get the repository forward-compatible with Bazel incompatible changes. Progress towards bazel-contrib#134
1 parent 9835856 commit 173290e

File tree

3 files changed

+60
-55
lines changed

3 files changed

+60
-55
lines changed

python/pip.bzl

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,36 @@
1414
"""Import pip requirements into Bazel."""
1515

1616
def _pip_import_impl(repository_ctx):
17-
"""Core implementation of pip_import."""
17+
"""Core implementation of pip_import."""
1818

19-
# Add an empty top-level BUILD file.
20-
# This is because Bazel requires BUILD files along all paths accessed
21-
# via //this/sort/of:path and we wouldn't be able to load our generated
22-
# requirements.bzl without it.
23-
repository_ctx.file("BUILD", "")
19+
# Add an empty top-level BUILD file.
20+
# This is because Bazel requires BUILD files along all paths accessed
21+
# via //this/sort/of:path and we wouldn't be able to load our generated
22+
# requirements.bzl without it.
23+
repository_ctx.file("BUILD", "")
2424

25-
# To see the output, pass: quiet=False
26-
result = repository_ctx.execute([
27-
"python", repository_ctx.path(repository_ctx.attr._script),
28-
"--name", repository_ctx.attr.name,
29-
"--input", repository_ctx.path(repository_ctx.attr.requirements),
30-
"--output", repository_ctx.path("requirements.bzl"),
31-
"--directory", repository_ctx.path(""),
32-
])
25+
# To see the output, pass: quiet=False
26+
result = repository_ctx.execute([
27+
"python",
28+
repository_ctx.path(repository_ctx.attr._script),
29+
"--name",
30+
repository_ctx.attr.name,
31+
"--input",
32+
repository_ctx.path(repository_ctx.attr.requirements),
33+
"--output",
34+
repository_ctx.path("requirements.bzl"),
35+
"--directory",
36+
repository_ctx.path(""),
37+
])
3338

34-
if result.return_code:
35-
fail("pip_import failed: %s (%s)" % (result.stdout, result.stderr))
39+
if result.return_code:
40+
fail("pip_import failed: %s (%s)" % (result.stdout, result.stderr))
3641

3742
pip_import = repository_rule(
3843
attrs = {
3944
"requirements": attr.label(
40-
allow_files = True,
4145
mandatory = True,
42-
single_file = True,
46+
allow_single_file = True,
4347
),
4448
"_script": attr.label(
4549
executable = True,
@@ -93,9 +97,9 @@ Args:
9397
"""
9498

9599
def pip_repositories():
96-
"""Pull in dependencies needed for pulling in pip dependencies.
100+
"""Pull in dependencies needed for pulling in pip dependencies.
97101
98-
A placeholder method that will eventually pull in any dependencies
99-
needed to install pip dependencies.
100-
"""
101-
pass
102+
A placeholder method that will eventually pull in any dependencies
103+
needed to install pip dependencies.
104+
"""
105+
pass

python/python.bzl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
# limitations under the License.
1414

1515
def py_library(*args, **kwargs):
16-
"""See the Bazel core py_library documentation.
16+
"""See the Bazel core py_library documentation.
1717
18-
[available here](
19-
https://docs.bazel.build/versions/master/be/python.html#py_library).
20-
"""
21-
native.py_library(*args, **kwargs)
18+
[available here](
19+
https://docs.bazel.build/versions/master/be/python.html#py_library).
20+
"""
21+
native.py_library(*args, **kwargs)
2222

2323
def py_binary(*args, **kwargs):
24-
"""See the Bazel core py_binary documentation.
24+
"""See the Bazel core py_binary documentation.
2525
26-
[available here](
27-
https://docs.bazel.build/versions/master/be/python.html#py_binary).
28-
"""
29-
native.py_binary(*args, **kwargs)
26+
[available here](
27+
https://docs.bazel.build/versions/master/be/python.html#py_binary).
28+
"""
29+
native.py_binary(*args, **kwargs)
3030

3131
def py_test(*args, **kwargs):
32-
"""See the Bazel core py_test documentation.
32+
"""See the Bazel core py_test documentation.
3333
34-
[available here](
35-
https://docs.bazel.build/versions/master/be/python.html#py_test).
36-
"""
37-
native.py_test(*args, **kwargs)
34+
[available here](
35+
https://docs.bazel.build/versions/master/be/python.html#py_test).
36+
"""
37+
native.py_test(*args, **kwargs)

python/whl.bzl

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,32 @@
1414
"""Import .whl files into Bazel."""
1515

1616
def _whl_impl(repository_ctx):
17-
"""Core implementation of whl_library."""
17+
"""Core implementation of whl_library."""
1818

19-
args = [
20-
"python",
21-
repository_ctx.path(repository_ctx.attr._script),
22-
"--whl", repository_ctx.path(repository_ctx.attr.whl),
23-
"--requirements", repository_ctx.attr.requirements,
24-
]
25-
26-
if repository_ctx.attr.extras:
27-
args += [
28-
"--extras=%s" % extra
29-
for extra in repository_ctx.attr.extras
19+
args = [
20+
"python",
21+
repository_ctx.path(repository_ctx.attr._script),
22+
"--whl",
23+
repository_ctx.path(repository_ctx.attr.whl),
24+
"--requirements",
25+
repository_ctx.attr.requirements,
3026
]
3127

32-
result = repository_ctx.execute(args)
33-
if result.return_code:
34-
fail("whl_library failed: %s (%s)" % (result.stdout, result.stderr))
28+
if repository_ctx.attr.extras:
29+
args += [
30+
"--extras=%s" % extra
31+
for extra in repository_ctx.attr.extras
32+
]
33+
34+
result = repository_ctx.execute(args)
35+
if result.return_code:
36+
fail("whl_library failed: %s (%s)" % (result.stdout, result.stderr))
3537

3638
whl_library = repository_rule(
3739
attrs = {
3840
"whl": attr.label(
39-
allow_files = True,
4041
mandatory = True,
41-
single_file = True,
42+
allow_single_file = True,
4243
),
4344
"requirements": attr.string(),
4445
"extras": attr.string_list(),

0 commit comments

Comments
 (0)