|
97 | 97 | """
|
98 | 98 |
|
99 | 99 | def pip_repositories():
|
100 |
| - """Pull in dependencies needed for pulling in pip dependencies. |
| 100 | + """Pull in dependencies needed to use the pip rules. |
101 | 101 |
|
102 |
| - A placeholder method that will eventually pull in any dependencies |
103 |
| - needed to install pip dependencies. |
| 102 | + At the moment this is a placeholder, in that it does not actually pull in |
| 103 | + any dependencies. However, it does do some validation checking. |
104 | 104 | """
|
105 |
| - pass |
| 105 | + # As a side effect of migrating our canonical workspace name from |
| 106 | + # "@io_bazel_rules_python" to "@rules_python" (#203), users who still |
| 107 | + # imported us by the old name would get a confusing error about a |
| 108 | + # repository dependency cycle in their workspace. (The cycle is likely |
| 109 | + # related to the fact that our repo name is hardcoded into the template |
| 110 | + # in piptool.py.) |
| 111 | + # |
| 112 | + # To produce a more informative error message in this situation, we |
| 113 | + # fail-fast here if we detect that we're not being imported by the new |
| 114 | + # name. (I believe we have always had the requirement that we're imported |
| 115 | + # by the canonical name, because of the aforementioned hardcoding.) |
| 116 | + # |
| 117 | + # Users who, against best practice, do not call pip_repositories() in their |
| 118 | + # workspace will not benefit from this check. |
| 119 | + if "rules_python" not in native.existing_rules(): |
| 120 | + message = "=" * 79 + """\n\ |
| 121 | +It appears that you are trying to import rules_python without using its |
| 122 | +canonical name, "@rules_python". This does not work. Please change your |
| 123 | +repository definition to import this repo with `name = "rules_python"`. |
| 124 | +""" |
| 125 | + if "io_bazel_rules_python" in native.existing_rules(): |
| 126 | + message += """\n\ |
| 127 | +Note that the previous name of "@io_bazel_rules_python" is no longer used. |
| 128 | +See https://github.com/bazelbuild/rules_python/issues/203 for context. |
| 129 | +""" |
| 130 | + message += "=" * 79 |
| 131 | + fail(message) |
0 commit comments