-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bazelbuild:main' into support-data-files-in-pywheel
- Loading branch information
Showing
73 changed files
with
847 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
gazelle/python/testdata/directive_python_default_visibility/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Directive: `python_default_visibility` | ||
|
||
This test case asserts that the `# gazelle:python_default_visibility` directive | ||
correctly: | ||
|
||
1. Uses the default value when `python_default_visibility` is not set. | ||
2. Uses the correct default value when `python_root` is set and | ||
`python_default_visibility` is not set. | ||
3. Supports injecting `python_root` | ||
4. Supports multiple labels | ||
5. Setting the label to "NONE" removes all visibility attibutes. | ||
6. Setting the label to "DEFAULT" reverts to using the default. | ||
7. Adding `python_visibility` directive with `python_default_visibility NONE` | ||
only adds the items listed by `python_visibility`. | ||
8. Multiple `python_root` dirs [GH #1682][gh-1682] uses correct value when | ||
injecting `python_root`. | ||
9. Setting both `python_default_visibility` and `python_visibility` and how | ||
they interact with sub-packages. | ||
|
||
|
||
[gh-1682]: https://github.com/bazelbuild/rules_python/issues/1682 |
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_default_visibility/WORKSPACE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# This is a Bazel workspace for the Gazelle test data. |
17 changes: 17 additions & 0 deletions
17
gazelle/python/testdata/directive_python_default_visibility/test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
expect: | ||
exit_code: 0 |
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# python_default_visibility is not set. |
9 changes: 9 additions & 0 deletions
9
gazelle/python/testdata/directive_python_default_visibility/test1_default/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# python_default_visibility is not set. | ||
|
||
py_library( | ||
name = "test1_default", | ||
srcs = ["test1.py"], | ||
visibility = ["//:__subpackages__"], | ||
) |
2 changes: 2 additions & 0 deletions
2
gazelle/python/testdata/directive_python_default_visibility/test1_default/test1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
1 change: 1 addition & 0 deletions
1
...thon/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:python_root |
12 changes: 12 additions & 0 deletions
12
...hon/testdata/directive_python_default_visibility/test2_default_with_python_root/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# gazelle:python_root | ||
|
||
py_library( | ||
name = "test2_default_with_python_root", | ||
srcs = [ | ||
"__init__.py", | ||
"test2.py", | ||
], | ||
visibility = ["//test2_default_with_python_root:__subpackages__"], | ||
) |
Empty file.
2 changes: 2 additions & 0 deletions
2
...thon/testdata/directive_python_default_visibility/test2_default_with_python_root/test2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
2 changes: 2 additions & 0 deletions
2
gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# gazelle:python_root | ||
# gazelle:python_default_visibility //foo/$python_root/bar:__pkg__ |
13 changes: 13 additions & 0 deletions
13
gazelle/python/testdata/directive_python_default_visibility/test3_injection/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# gazelle:python_root | ||
# gazelle:python_default_visibility //foo/$python_root/bar:__pkg__ | ||
|
||
py_library( | ||
name = "test3_injection", | ||
srcs = [ | ||
"__init__.py", | ||
"test3.py", | ||
], | ||
visibility = ["//foo/test3_injection/bar:__pkg__"], | ||
) |
Empty file.
2 changes: 2 additions & 0 deletions
2
gazelle/python/testdata/directive_python_default_visibility/test3_injection/test3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:python_default_visibility //foo/bar:__pkg__,//tests:__subpackages__,//a:b |
13 changes: 13 additions & 0 deletions
13
gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# gazelle:python_default_visibility //foo/bar:__pkg__,//tests:__subpackages__,//a:b | ||
|
||
py_library( | ||
name = "test4_multiple_labels", | ||
srcs = ["test4.py"], | ||
visibility = [ | ||
"//a:b", | ||
"//foo/bar:__pkg__", | ||
"//tests:__subpackages__", | ||
], | ||
) |
2 changes: 2 additions & 0 deletions
2
gazelle/python/testdata/directive_python_default_visibility/test4_multiple_labels/test4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:python_default_visibility NONE |
8 changes: 8 additions & 0 deletions
8
gazelle/python/testdata/directive_python_default_visibility/test5_none_label/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# gazelle:python_default_visibility NONE | ||
|
||
py_library( | ||
name = "test5_none_label", | ||
srcs = ["test5.py"], | ||
) |
2 changes: 2 additions & 0 deletions
2
gazelle/python/testdata/directive_python_default_visibility/test5_none_label/test5.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
1 change: 1 addition & 0 deletions
1
gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:python_default_visibility //foo:bar |
9 changes: 9 additions & 0 deletions
9
gazelle/python/testdata/directive_python_default_visibility/test6_default_label/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# gazelle:python_default_visibility //foo:bar | ||
|
||
py_library( | ||
name = "test6_default_label", | ||
srcs = ["test6.py"], | ||
visibility = ["//foo:bar"], | ||
) |
2 changes: 2 additions & 0 deletions
2
...e/python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Reset the default visibility to the default for all child packages. | ||
# gazelle:python_default_visibility DEFAULT |
10 changes: 10 additions & 0 deletions
10
.../python/testdata/directive_python_default_visibility/test6_default_label/subpkg/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# Reset the default visibility to the default for all child packages. | ||
# gazelle:python_default_visibility DEFAULT | ||
|
||
py_library( | ||
name = "subpkg", | ||
srcs = ["test6_sub.py"], | ||
visibility = ["//:__subpackages__"], | ||
) |
2 changes: 2 additions & 0 deletions
2
...thon/testdata/directive_python_default_visibility/test6_default_label/subpkg/test6_sub.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
2 changes: 2 additions & 0 deletions
2
gazelle/python/testdata/directive_python_default_visibility/test6_default_label/test6.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
5 changes: 5 additions & 0 deletions
5
...hon/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# python_visibility directives that happen either before _or_ after the | ||
# NONE reset both get applied. | ||
# gazelle:python_visibility //foo:bar | ||
# gazelle:python_default_visibility NONE | ||
# gazelle:python_visibility //bar:baz |
16 changes: 16 additions & 0 deletions
16
...on/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# python_visibility directives that happen either before _or_ after the | ||
# NONE reset both get applied. | ||
# gazelle:python_visibility //foo:bar | ||
# gazelle:python_default_visibility NONE | ||
# gazelle:python_visibility //bar:baz | ||
|
||
py_library( | ||
name = "test7_none_label_with_extra_vis", | ||
srcs = ["test7.py"], | ||
visibility = [ | ||
"//bar:baz", | ||
"//foo:bar", | ||
], | ||
) |
2 changes: 2 additions & 0 deletions
2
...hon/testdata/directive_python_default_visibility/test7_none_label_with_extra_vis/test7.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def func(): | ||
print("library_func") |
2 changes: 2 additions & 0 deletions
2
...hon/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# For funzies, also throw in some additional visibility. | ||
# gazelle:python_visibility //tests:__pkg__ |
2 changes: 2 additions & 0 deletions
2
...on/testdata/directive_python_default_visibility/test8_multiple_python_root_dirs/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# For funzies, also throw in some additional visibility. | ||
# gazelle:python_visibility //tests:__pkg__ |
1 change: 1 addition & 0 deletions
1
...ta/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:python_root |
1 change: 1 addition & 0 deletions
1
...a/directive_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:python_root |
2 changes: 2 additions & 0 deletions
2
...rective_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# proj1 depends on proj2 | ||
# We can leave the default visibility. |
14 changes: 14 additions & 0 deletions
14
...ective_python_default_visibility/test8_multiple_python_root_dirs/proj1/src/pkg1/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
load("@rules_python//python:defs.bzl", "py_library") | ||
|
||
# proj1 depends on proj2 | ||
# We can leave the default visibility. | ||
|
||
py_library( | ||
name = "pkg1", | ||
srcs = ["file1.py"], | ||
imports = [".."], | ||
visibility = [ | ||
"//test8_multiple_python_root_dirs/proj1/src:__subpackages__", | ||
"//tests:__pkg__", | ||
], | ||
) |
Empty file.
Oops, something went wrong.