Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ed1fe5

Browse filesBrowse files
authored
Make rules_python_external functional (bazel-contrib#354)
- Clean up files that aren't needed now that it's a subdirectory of rules_python - Move the example into the top-level examples From the checklist in bazel-contrib#352 this is the third item.
1 parent a8d133a commit 6ed1fe5
Copy full SHA for 6ed1fe5

32 files changed

+156
-300
lines changed

‎.bazelignore

Copy file name to clipboard
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
experimental/rules_python_external
2-

‎.bazelrc

Copy file name to clipboardExpand all lines: .bazelrc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This lets us glob() up all the files inside the examples to make them inputs to tests
44
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
55
# To update these lines, run tools/bazel_integration_test/update_deleted_packages.sh
6-
build --deleted_packages=examples/pip/boto,examples/pip/extras,examples/pip/helloworld
7-
query --deleted_packages=examples/pip/boto,examples/pip/extras,examples/pip/helloworld
6+
build --deleted_packages=examples/pip/boto,examples/pip/extras,examples/pip/helloworld,examples/rules_python_external
7+
query --deleted_packages=examples/pip/boto,examples/pip/extras,examples/pip/helloworld,examples/rules_python_external
88

99
test --test_output=errors

‎BUILD

Copy file name to clipboardExpand all lines: BUILD
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ filegroup(
2727
"LICENSE",
2828
"internal_deps.bzl",
2929
"internal_setup.bzl",
30+
"//experimental/rules_python_external:distribution",
3031
"//python:distribution",
3132
"//tools:distribution",
3233
],

‎WORKSPACE

Copy file name to clipboardExpand all lines: WORKSPACE
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ rules_python_internal_deps()
2828
load("//:internal_setup.bzl", "rules_python_internal_setup")
2929

3030
rules_python_internal_setup()
31+
32+
# TODO(alexeagle): vendor these dependencies so we don't expose new ones to users
33+
load("//experimental/rules_python_external:repositories.bzl", "rules_python_external_dependencies")
34+
35+
rules_python_external_dependencies()

‎distro/BUILD

Copy file name to clipboardExpand all lines: distro/BUILD
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pkg_tar(
1919
owner = "0.0",
2020
package_dir = ".",
2121
strip_prefix = ".",
22+
visibility = ["//examples:__pkg__"],
2223
)
2324

2425
# TODO(brandjon): print_rel_notes doesn't appear to handle our use case of

‎examples/BUILD

Copy file name to clipboardExpand all lines: examples/BUILD
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ bazel_integration_test(
2121
name = "pip_example",
2222
timeout = "long",
2323
)
24+
25+
bazel_integration_test(
26+
name = "rules_python_external_example",
27+
timeout = "long",
28+
)

‎experimental/rules_python_external/example/BUILD renamed to ‎examples/rules_python_external/BUILD

Copy file name to clipboardExpand all lines: examples/rules_python_external/BUILD
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@pip//:requirements.bzl", "requirement")
2-
load("@rules_python//python:defs.bzl", "py_binary")
2+
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
33

44
# Toolchain setup, this is optional.
55
# Demonstrate that we can use the same python interpreter for the toolchain and executing pip in pip install (see WORKSPACE).
@@ -34,3 +34,9 @@ py_binary(
3434
requirement("boto3"),
3535
],
3636
)
37+
38+
py_test(
39+
name = "test",
40+
srcs = ["test.py"],
41+
deps = [":main"],
42+
)
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# rules_python_external example
2+
3+
This example shows how to use rules_python_external which was developed as an alternative
4+
to packaging rules in rules_python.
5+
6+
We will soon migrate this example to be the canonical one for rules_python.
7+
See https://github.com/bazelbuild/rules_python/pull/352 for the longer plan.

‎experimental/rules_python_external/example/WORKSPACE renamed to ‎examples/rules_python_external/WORKSPACE

Copy file name to clipboardExpand all lines: examples/rules_python_external/WORKSPACE
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44

55
http_archive(
66
name = "rules_python",
7+
# NB: this doesn't work with 0.0.2 but will work in the next release
8+
# TODO(alexeagle): ensure the example/*/WORKSPACE files get bumped as a release step
79
url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.2/rules_python-0.0.2.tar.gz",
810
strip_prefix = "rules_python-0.0.2",
911
sha256 = "b5668cde8bb6e3515057ef465a35ad712214962f0b3a314e551204266c7be90c",
@@ -13,16 +15,11 @@ load("@rules_python//python:repositories.bzl", "py_repositories")
1315

1416
py_repositories()
1517

16-
local_repository(
17-
name = "rules_python_external",
18-
path = "../",
19-
)
20-
21-
load("@rules_python_external//:repositories.bzl", "rules_python_external_dependencies")
18+
load("@rules_python//experimental/rules_python_external:repositories.bzl", "rules_python_external_dependencies")
2219

2320
rules_python_external_dependencies()
2421

25-
load("@rules_python_external//:defs.bzl", "pip_install")
22+
load("@rules_python//experimental/rules_python_external:defs.bzl", "pip_install")
2623

2724
pip_install(
2825
# (Optional) You can provide extra parameters to pip.
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import boto3
2+
3+
def the_dir():
4+
return dir(boto3)
5+
6+
if __name__ == "__main__":
7+
print(the_dir())
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
boto3==1.14.51
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import unittest
2+
import main
3+
4+
class ExampleTest(unittest.TestCase):
5+
def test_main(self):
6+
self.assertIn("set_stream_logger", main.the_dir())
7+
8+
if __name__ == '__main__':
9+
unittest.main()

‎experimental/rules_python_external/.bazelignore

Copy file name to clipboardExpand all lines: experimental/rules_python_external/.bazelignore
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎experimental/rules_python_external/.gitattributes

Copy file name to clipboardExpand all lines: experimental/rules_python_external/.gitattributes
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎experimental/rules_python_external/.github/workflows/continuous-integration.yml

Copy file name to clipboardExpand all lines: experimental/rules_python_external/.github/workflows/continuous-integration.yml
-24Lines changed: 0 additions & 24 deletions
This file was deleted.
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
filegroup(
2+
name = "distribution",
3+
srcs = glob(["*.bzl"]) + [
4+
"BUILD",
5+
"//experimental/rules_python_external/extract_wheels:distribution",
6+
],
7+
visibility = ["//:__pkg__"],
8+
)

‎experimental/rules_python_external/LICENSE

Copy file name to clipboardExpand all lines: experimental/rules_python_external/LICENSE
-201Lines changed: 0 additions & 201 deletions
This file was deleted.

‎experimental/rules_python_external/WORKSPACE

Copy file name to clipboardExpand all lines: experimental/rules_python_external/WORKSPACE
-16Lines changed: 0 additions & 16 deletions
This file was deleted.

‎experimental/rules_python_external/defs.bzl

Copy file name to clipboardExpand all lines: experimental/rules_python_external/defs.bzl
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""
22

3-
load("//:repositories.bzl", "all_requirements")
3+
load("//experimental/rules_python_external:repositories.bzl", "all_requirements")
44

55
DEFAULT_REPOSITORY_NAME = "pip"
66

@@ -30,7 +30,7 @@ def _pip_repository_impl(rctx):
3030
args = [
3131
python_interpreter,
3232
"-m",
33-
"extract_wheels",
33+
"experimental.rules_python_external.extract_wheels",
3434
"--requirements",
3535
rctx.path(rctx.attr.requirements),
3636
"--repo",

‎experimental/rules_python_external/example/main.py

Copy file name to clipboardExpand all lines: experimental/rules_python_external/example/main.py
-4Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.