Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame^] | 1 | def _pip_configure_impl(repository_ctx): |
| 2 | """Runs tools/python/pip_configure.py.""" |
| 3 | script_path = repository_ctx.path(repository_ctx.attr._script).realpath |
| 4 | interpreter_path = repository_ctx.path(repository_ctx.attr._interpreter).realpath |
| 5 | requirements_path = repository_ctx.path(repository_ctx.attr._requirements).realpath |
| 6 | |
| 7 | script_result = repository_ctx.execute([ |
| 8 | interpreter_path, |
| 9 | "-BSs", |
| 10 | script_path, |
| 11 | requirements_path, |
| 12 | ]) |
| 13 | if script_result.return_code != 0: |
| 14 | fail("{} failed: {} ({})".format( |
| 15 | script_path, |
| 16 | script_result.stdout, |
| 17 | script_result.stderr, |
| 18 | )) |
| 19 | |
| 20 | pip_configure = repository_rule( |
| 21 | implementation = _pip_configure_impl, |
| 22 | attrs = { |
| 23 | "_interpreter": attr.label( |
| 24 | default = "@python3_9_x86_64-unknown-linux-gnu//:bin/python3", |
| 25 | ), |
| 26 | "_script": attr.label( |
| 27 | default = "@//tools/python:pip_configure.py", |
| 28 | ), |
| 29 | "_requirements": attr.label( |
| 30 | default = "@//tools/python:requirements.txt", |
| 31 | ), |
| 32 | }, |
| 33 | ) |