Skip to content

Commit

Permalink
Added patch support.
Browse files Browse the repository at this point in the history
  • Loading branch information
globegitter committed May 17, 2019
1 parent 99f5916 commit adce162
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
25 changes: 25 additions & 0 deletions rules/repository.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
load(
"@bazel_tools//tools/build_defs/repo:utils.bzl",
"patch",
)

def _get_platform(repo_ctx):
if "mac" in repo_ctx.os.name:
return "osx"
Expand Down Expand Up @@ -58,6 +63,8 @@ def _pip_repository_impl(repo_ctx):
if r.return_code:
fail(r.stderr)

patch(repo_ctx)

pip_repository = repository_rule(
implementation = _pip_repository_impl,
attrs = {
Expand All @@ -74,6 +81,24 @@ pip_repository = repository_rule(
"wheel_cache": attr.string(),
"environment": attr.string_dict(),
"quiet": attr.bool(default = True),
"patches": attr.label_list(
default = [],
doc =
"A list of files that are to be applied as patches afer " +
"extracting the archive.",
),
"patch_tool": attr.string(
default = "patch",
doc = "The patch(1) utility to use.",
),
"patch_args": attr.string_list(
default = ["-p0"],
doc = "The arguments given to the patch tool",
),
"patch_cmds": attr.string_list(
default = [],
doc = "Sequence of commands to be applied after patches are applied.",
),
"_create_repo_exe": attr.label(
default = "//tools:create_pip_repository.par",
executable = True,
Expand Down
1 change: 0 additions & 1 deletion tools/pytest/main_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

def main():
args = sys.argv[1:]
print(args)

sys.exit(pytest.main(args))

Expand Down
21 changes: 5 additions & 16 deletions tools/pytest/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,16 @@ def pytest_test(name, srcs, python_version = "PY3", **kwargs):
fail("Python version must be 2 or 3")

main_name = "%s_main" % name
main_output = ":%s.py" % main_name
main_output = "%s.py" % main_name

native.py_binary(
name = main_name,
srcs = [src],
main
)

_pytest_main(
name = main_name,
src = src,
interpreter = interpreter,
)

deps = kwargs.pop("deps", []) + [pytest_dep]
deps = kwargs.pop("deps", [])# + [pytest_dep]

native.py_test(
name = name,
srcs = [main_output] + srcs,
main = main_output,
srcs = ["@pip3//pytest:py.test"] + srcs,
main = "py.test.py",
deps = deps,
python_version = python_version,
args = ["$(location " + srcs[0] + ")"],
**kwargs
)

0 comments on commit adce162

Please sign in to comment.