Skip to content

Commit 38f86fb

Browse files
jamiesnapeoquenchil
authored andcommitted
Fix immutable frozen set bug in defs.bzl (bazel-contrib#262)
When adding tags to a native py_library rule that is created through a macro we were not properly considering the case where the tags came from a different file and therefore were frozen. This caused an error. Analog of bazelbuild/rules_cc@cfe68f6 Co-authored-by: Googler <plf@google.com>
1 parent 9467740 commit 38f86fb

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

.bazelci/presubmit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ all_targets: &all_targets
1313
- "//experimental/..."
1414
- "//packaging/..."
1515
- "//python/..."
16+
- "//tests/..."
1617
- "//tools/..."
1718
# As a regression test for #225, check that wheel targets still build when
1819
# their package path is qualified with the repo name.

python/defs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _MIGRATION_TAG = "__PYTHON_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
3636

3737
def _add_tags(attrs):
3838
if "tags" in attrs and attrs["tags"] != None:
39-
attrs["tags"] += [_MIGRATION_TAG]
39+
attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG]
4040
else:
4141
attrs["tags"] = [_MIGRATION_TAG]
4242
return attrs

tests/load_from_macro/BUILD

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2019 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("//python:defs.bzl", "py_library")
16+
load(":tags.bzl", "TAGS")
17+
18+
licenses(["notice"])
19+
20+
py_library(
21+
name = "foo",
22+
srcs = ["foo.py"],
23+
tags = TAGS,
24+
)

tests/load_from_macro/foo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2019 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

tests/load_from_macro/tags.bzl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2019 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Example tags defined in a separate file.
17+
"""
18+
TAGS = ["first_tag", "second_tag"]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy