aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md12
-rw-r--r--WORKSPACE2
-rw-r--r--experimental/examples/wheel/wheel_test.py12
-rw-r--r--python/pip.bzl34
-rw-r--r--rules_python/piptool.py2
-rwxr-xr-xtools/piptool.parbin5889192 -> 5889066 bytes
-rwxr-xr-xtools/whltool.parbin1396156 -> 1396066 bytes
7 files changed, 46 insertions, 16 deletions
diff --git a/README.md b/README.md
index 9c44f40..f222f39 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,10 @@ Status: This is **ALPHA** software.
[![Build status](https://badge.buildkite.com/0bcfe58b6f5741aacb09b12485969ba7a1205955a45b53e854.svg)](https://buildkite.com/bazel/python-rules-python-postsubmit)
+## Recent updates
+
+* 2019-07-26: The canonical name of this repo has been changed from `@io_bazel_rules_python` to just `@rules_python`, in accordance with [convention](https://docs.bazel.build/versions/master/skylark/deploying.html#workspace). Please update your WORKSPACE file and labels that reference this repo accordingly.
+
## Rules
* [pip_import](docs/python/pip.md#pip_import)
@@ -26,14 +30,14 @@ Add the following to your `WORKSPACE` file to add the external repositories:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
- name = "io_bazel_rules_python",
+ name = "rules_python",
remote = "https://github.com/bazelbuild/rules_python.git",
# NOT VALID! Replace this with a Git commit SHA.
commit = "{HEAD}",
)
# Only needed for PIP support:
-load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories")
+load("@rules_python//python:pip.bzl", "pip_repositories")
pip_repositories()
```
@@ -42,7 +46,7 @@ Then in your `BUILD` files load the python rules with:
``` python
load(
- "@io_bazel_rules_python//python:python.bzl",
+ "@rules_python//python:python.bzl",
"py_binary", "py_library", "py_test",
)
@@ -60,7 +64,7 @@ are imported into the Bazel dependency graph via a two-phased process in
`WORKSPACE`:
```python
-load("@io_bazel_rules_python//python:pip.bzl", "pip_import")
+load("@rules_python//python:pip.bzl", "pip_import")
# This rule translates the specified requirements.txt into
# @my_deps//:requirements.bzl, which itself exposes a pip_install method.
diff --git a/WORKSPACE b/WORKSPACE
index 296055f..abf1a47 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-workspace(name = "io_bazel_rules_python")
+workspace(name = "rules_python")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
diff --git a/experimental/examples/wheel/wheel_test.py b/experimental/examples/wheel/wheel_test.py
index d7bb8b6..ea535de 100644
--- a/experimental/examples/wheel/wheel_test.py
+++ b/experimental/examples/wheel/wheel_test.py
@@ -20,7 +20,7 @@ import zipfile
class WheelTest(unittest.TestCase):
def test_py_library_wheel(self):
filename = os.path.join(os.environ['TEST_SRCDIR'],
- 'io_bazel_rules_python', 'experimental',
+ 'rules_python', 'experimental',
'examples', 'wheel',
'example_minimal_library-0.0.1-py3-none-any.whl')
with zipfile.ZipFile(filename) as zf:
@@ -34,7 +34,7 @@ class WheelTest(unittest.TestCase):
def test_py_package_wheel(self):
filename = os.path.join(os.environ['TEST_SRCDIR'],
- 'io_bazel_rules_python', 'experimental',
+ 'rules_python', 'experimental',
'examples', 'wheel',
'example_minimal_package-0.0.1-py3-none-any.whl')
with zipfile.ZipFile(filename) as zf:
@@ -50,7 +50,7 @@ class WheelTest(unittest.TestCase):
def test_customized_wheel(self):
filename = os.path.join(os.environ['TEST_SRCDIR'],
- 'io_bazel_rules_python', 'experimental',
+ 'rules_python', 'experimental',
'examples', 'wheel',
'example_customized-0.0.1-py3-none-any.whl')
with zipfile.ZipFile(filename) as zf:
@@ -104,7 +104,7 @@ This is a sample description of a wheel.
def test_custom_package_root_wheel(self):
filename = os.path.join(os.environ['TEST_SRCDIR'],
- 'io_bazel_rules_python', 'experimental',
+ 'rules_python', 'experimental',
'examples', 'wheel',
'example_custom_package_root-0.0.1-py3-none-any.whl')
@@ -121,7 +121,7 @@ This is a sample description of a wheel.
def test_custom_package_root_multi_prefix_wheel(self):
filename = os.path.join(os.environ['TEST_SRCDIR'],
- 'io_bazel_rules_python', 'experimental',
+ 'rules_python', 'experimental',
'examples', 'wheel',
'example_custom_package_root_multi_prefix-0.0.1-py3-none-any.whl')
@@ -138,7 +138,7 @@ This is a sample description of a wheel.
def test_custom_package_root_multi_prefix_reverse_order_wheel(self):
filename = os.path.join(os.environ['TEST_SRCDIR'],
- 'io_bazel_rules_python', 'experimental',
+ 'rules_python', 'experimental',
'examples', 'wheel',
'example_custom_package_root_multi_prefix_reverse_order-0.0.1-py3-none-any.whl')
diff --git a/python/pip.bzl b/python/pip.bzl
index 9d27794..2449ee7 100644
--- a/python/pip.bzl
+++ b/python/pip.bzl
@@ -97,9 +97,35 @@ Args:
"""
def pip_repositories():
- """Pull in dependencies needed for pulling in pip dependencies.
+ """Pull in dependencies needed to use the pip rules.
- A placeholder method that will eventually pull in any dependencies
- needed to install pip dependencies.
+ At the moment this is a placeholder, in that it does not actually pull in
+ any dependencies. However, it does do some validation checking.
"""
- pass
+ # As a side effect of migrating our canonical workspace name from
+ # "@io_bazel_rules_python" to "@rules_python" (#203), users who still
+ # imported us by the old name would get a confusing error about a
+ # repository dependency cycle in their workspace. (The cycle is likely
+ # related to the fact that our repo name is hardcoded into the template
+ # in piptool.py.)
+ #
+ # To produce a more informative error message in this situation, we
+ # fail-fast here if we detect that we're not being imported by the new
+ # name. (I believe we have always had the requirement that we're imported
+ # by the canonical name, because of the aforementioned hardcoding.)
+ #
+ # Users who, against best practice, do not call pip_repositories() in their
+ # workspace will not benefit from this check.
+ if "rules_python" not in native.existing_rules():
+ message = "=" * 79 + """\n\
+It appears that you are trying to import rules_python without using its
+canonical name, "@rules_python". This does not work. Please change your
+WORKSPACE file to import this repo with `name = "rules_python"` instead.
+"""
+ if "io_bazel_rules_python" in native.existing_rules():
+ message += """\n\
+Note that the previous name of "@io_bazel_rules_python" is no longer used.
+See https://github.com/bazelbuild/rules_python/issues/203 for context.
+"""
+ message += "=" * 79
+ fail(message)
diff --git a/rules_python/piptool.py b/rules_python/piptool.py
index f5d504a..5bc4dfd 100644
--- a/rules_python/piptool.py
+++ b/rules_python/piptool.py
@@ -203,7 +203,7 @@ def main():
#
# Generated from {input}
-load("@io_bazel_rules_python//python:whl.bzl", "whl_library")
+load("@rules_python//python:whl.bzl", "whl_library")
def pip_install():
{whl_libraries}
diff --git a/tools/piptool.par b/tools/piptool.par
index 53df7d8..5503d18 100755
--- a/tools/piptool.par
+++ b/tools/piptool.par
Binary files differ
diff --git a/tools/whltool.par b/tools/whltool.par
index 25f85e7..8db7f14 100755
--- a/tools/whltool.par
+++ b/tools/whltool.par
Binary files differ