Skip to content

Commit a83aa9b

Browse files
Add extra_pip_args to pip_repository (bazel-contrib#41)
1 parent c6a29a0 commit a83aa9b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

defs.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def _pip_repository_impl(rctx):
3434
"@%s" % rctx.attr.name,
3535
]
3636

37+
if rctx.attr.extra_pip_args:
38+
args += [
39+
"--extra_pip_args",
40+
"\"" + " ".join(rctx.attr.extra_pip_args) + "\"",
41+
]
42+
3743
result = rctx.execute(
3844
args,
3945
environment = {
@@ -62,6 +68,9 @@ python_interpreter.
6268
# 600 is documented as default here: https://docs.bazel.build/versions/master/skylark/lib/repository_ctx.html#execute
6369
"timeout": attr.int(default = 600),
6470
"quiet": attr.bool(default = True),
71+
"extra_pip_args": attr.string_list(
72+
doc = "Extra arguments to pass on to pip. Must not contain spaces.",
73+
),
6574
},
6675
implementation = _pip_repository_impl,
6776
)

extract_wheels/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ def main() -> None:
6363
required=True,
6464
help="The external repo name to install dependencies. In the format '@{REPO_NAME}'",
6565
)
66+
parser.add_argument('--extra_pip_args', action='store',
67+
help=('Extra arguments to pass down to pip.'))
6668
args = parser.parse_args()
6769

6870
pip_args = [sys.executable, "-m", "pip", "wheel", "-r", args.requirements]
71+
if args.extra_pip_args:
72+
pip_args += args.extra_pip_args.strip("\"").split()
6973
# Assumes any errors are logged by pip so do nothing. This command will fail if pip fails
7074
subprocess.run(pip_args, check=True)
7175

0 commit comments

Comments
 (0)