bazel-contrib / bazel-contrib/buildtools
Buildifier doesn't sort requirements from rules_python
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 471
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 13
Description
Buildifier is happy with a build file like this:
```
load("@rules_python//python:defs.bzl", "py_library")
load("@pypi//:requirements.bzl", "requirement")
py_library(
name = "a",
srcs = ["a.py"],
)
py_library(
name = "b",
srcs = ["b.py"],
)
py_library(
name = "c",
srcs = ["c.py"],
deps = [
":a",
requirement("requests"),
":b",
],
)
```
I'd like it to sort the requirement somewhere (not too picky on where, but not splicing the `":a"` and `":b"`). (Sorry if I'm missing a knob with `-add_tables` that would fix this problem.)
The workspace file is
```
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz",
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
)
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
name = "pypi",
requirements = "//:requirements.txt",
)
```
i.e. the `requirement` function comes from an external workspace generated by `rules_python`.
Contributor guide
Research direction
Start by reproducing the example in a BUILD file with the shown workspace file and rules_python setup. Inspect Buildifier's dependency-sorting behavior for deps entries involving requirement("requests"). Done means the requirement is placed consistently without splitting the ":a" and ":b" entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100