diff options
Diffstat (limited to 'examples/pip_parse/BUILD.bazel')
-rw-r--r-- | examples/pip_parse/BUILD.bazel | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/examples/pip_parse/BUILD.bazel b/examples/pip_parse/BUILD.bazel index 367a795..653f75c 100644 --- a/examples/pip_parse/BUILD.bazel +++ b/examples/pip_parse/BUILD.bazel @@ -1,6 +1,11 @@ +load( + "@pypi//:requirements.bzl", + "data_requirement", + "dist_info_requirement", + "entry_point", +) load("@rules_python//python:defs.bzl", "py_binary", "py_test") load("@rules_python//python:pip.bzl", "compile_pip_requirements") -load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary") # Toolchain setup, this is optional. # Demonstrate that we can use the same python interpreter for the toolchain and executing pip in pip install (see WORKSPACE). @@ -32,9 +37,7 @@ py_binary( name = "main", srcs = ["main.py"], deps = [ - "@pypi//requests:pkg", - "@pypi//sphinx:pkg", - "@pypi//sphinxcontrib_serializinghtml:pkg", + "@pypi_requests//:pkg", ], ) @@ -47,17 +50,17 @@ py_test( # For pip dependencies which have entry points, the `entry_point` macro can be # used from the generated `pip_parse` repository to access a runnable binary. -py_console_script_binary( +alias( name = "yamllint", - pkg = "@pypi//yamllint", + actual = entry_point("yamllint"), ) # This rule adds a convenient way to update the requirements file. compile_pip_requirements( name = "requirements", - src = "requirements.in", + extra_args = ["--allow-unsafe"], + requirements_in = "requirements.in", requirements_txt = "requirements_lock.txt", - requirements_windows = "requirements_windows.txt", ) # Test the use of all pip_parse utilities in a single py_test @@ -66,13 +69,13 @@ py_test( srcs = ["pip_parse_test.py"], data = [ ":yamllint", - "@pypi//requests:dist_info", - "@pypi//s3cmd:data", + data_requirement("s3cmd"), + dist_info_requirement("requests"), ], env = { - "WHEEL_DATA_CONTENTS": "$(rootpaths @pypi//s3cmd:data)", - "WHEEL_DIST_INFO_CONTENTS": "$(rootpaths @pypi//requests:dist_info)", - "YAMLLINT_ENTRY_POINT": "$(rlocationpath :yamllint)", + "WHEEL_DATA_CONTENTS": "$(rootpaths {})".format(data_requirement("s3cmd")), + "WHEEL_DIST_INFO_CONTENTS": "$(rootpaths {})".format(dist_info_requirement("requests")), + "YAMLLINT_ENTRY_POINT": "$(rootpath :yamllint)", }, deps = ["@rules_python//python/runfiles"], ) |