diff --git a/rules/repository.bzl b/rules/repository.bzl index d5b8eea..1cc12f3 100644 --- a/rules/repository.bzl +++ b/rules/repository.bzl @@ -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" @@ -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 = { @@ -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, diff --git a/tools/pytest/main_template.py b/tools/pytest/main_template.py index d2e0c12..7fdf59f 100644 --- a/tools/pytest/main_template.py +++ b/tools/pytest/main_template.py @@ -5,7 +5,6 @@ def main(): args = sys.argv[1:] - print(args) sys.exit(pytest.main(args)) diff --git a/tools/pytest/rules.bzl b/tools/pytest/rules.bzl index 9beaaa6..011165b 100644 --- a/tools/pytest/rules.bzl +++ b/tools/pytest/rules.bzl @@ -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 )