Skip to content

Commit 6135186

Browse files
authored
Graduate wheel-building code out of //experimental (bazel-contrib#418)
* Move wheelmaker from //experimental/tools into //tools. * Move wheel-building rules from //experimental/python to //python. Rename from wheel.bzl to packaging.bzl to avoid confusion with existing whl.bzl Keep a stub wheel.bzl file in the old location for backwards compatibility. * Move wheel building examples out of experimental.
1 parent c7e068d commit 6135186

17 files changed

Lines changed: 407 additions & 398 deletions

File tree

.bazelci/presubmit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ all_targets: &all_targets
1717
- "//tools/..."
1818
# As a regression test for #225, check that wheel targets still build when
1919
# their package path is qualified with the repo name.
20-
- "@rules_python//experimental/examples/..."
20+
- "@rules_python//examples/wheel/..."
2121
# We control Bazel version in integration tests, so we don't need USE_BAZEL_VERSION for tests.
2222
skip_use_bazel_version_for_test: true
2323
test_targets:
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("//experimental/python:wheel.bzl", "py_package", "py_wheel")
1615
load("//python:defs.bzl", "py_library", "py_test")
16+
load("//python:packaging.bzl", "py_package", "py_wheel")
1717

1818
package(default_visibility = ["//visibility:public"])
1919

@@ -23,8 +23,8 @@ py_library(
2323
name = "main",
2424
srcs = ["main.py"],
2525
deps = [
26-
"//experimental/examples/wheel/lib:simple_module",
27-
"//experimental/examples/wheel/lib:module_with_data",
26+
"//examples/wheel/lib:simple_module",
27+
"//examples/wheel/lib:module_with_data",
2828
# Example dependency which is not packaged in the wheel
2929
# due to "packages" filter on py_package rule.
3030
"//tests/load_from_macro:foo",
@@ -53,8 +53,8 @@ py_wheel(
5353
python_tag = "py3",
5454
version = "0.0.1",
5555
deps = [
56-
"//experimental/examples/wheel/lib:module_with_data",
57-
"//experimental/examples/wheel/lib:simple_module",
56+
"//examples/wheel/lib:module_with_data",
57+
"//examples/wheel/lib:simple_module",
5858
],
5959
)
6060

@@ -63,13 +63,13 @@ py_wheel(
6363
py_package(
6464
name = "example_pkg",
6565
# Only include these Python packages.
66-
packages = ["experimental.examples.wheel"],
66+
packages = ["examples.wheel"],
6767
deps = [":main"],
6868
)
6969

7070
py_package(
7171
name = "example_pkg_with_data",
72-
packages = ["experimental.examples.wheel"],
72+
packages = ["examples.wheel"],
7373
deps = [":main_with_gen_data"]
7474
)
7575

@@ -92,7 +92,7 @@ py_wheel(
9292
"Intended Audience :: Developers",
9393
],
9494
console_scripts = {
95-
"customized_wheel": "experimental.examples.wheel.main:main",
95+
"customized_wheel": "examples.wheel.main:main",
9696
},
9797
description_file = "README.md",
9898
# Package data. We're building "example_customized-0.0.1-py3-none-any.whl"
@@ -117,7 +117,7 @@ py_wheel(
117117
distribution = "example_custom_package_root",
118118
python_tag = "py3",
119119
strip_path_prefixes = [
120-
"experimental",
120+
"examples",
121121
],
122122
version = "0.0.1",
123123
deps = [
@@ -131,8 +131,8 @@ py_wheel(
131131
distribution = "example_custom_package_root_multi_prefix",
132132
python_tag = "py3",
133133
strip_path_prefixes = [
134-
"experimental/examples/wheel/lib",
135-
"experimental/examples/wheel",
134+
"examples/wheel/lib",
135+
"examples/wheel",
136136
],
137137
version = "0.0.1",
138138
deps = [
@@ -146,8 +146,8 @@ py_wheel(
146146
distribution = "example_custom_package_root_multi_prefix_reverse_order",
147147
python_tag = "py3",
148148
strip_path_prefixes = [
149-
"experimental/examples/wheel",
150-
"experimental/examples/wheel/lib", # this is not effective, because the first prefix takes priority
149+
"examples/wheel",
150+
"examples/wheel/lib", # this is not effective, because the first prefix takes priority
151151
],
152152
version = "0.0.1",
153153
deps = [
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import experimental.examples.wheel.lib.module_with_data as module_with_data
16-
import experimental.examples.wheel.lib.simple_module as simple_module
15+
import examples.wheel.lib.module_with_data as module_with_data
16+
import examples.wheel.lib.simple_module as simple_module
1717

1818

1919
def function():
Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,46 @@
2020
class WheelTest(unittest.TestCase):
2121
def test_py_library_wheel(self):
2222
filename = os.path.join(os.environ['TEST_SRCDIR'],
23-
'rules_python', 'experimental',
23+
'rules_python',
2424
'examples', 'wheel',
2525
'example_minimal_library-0.0.1-py3-none-any.whl')
2626
with zipfile.ZipFile(filename) as zf:
2727
self.assertEquals(
2828
zf.namelist(),
29-
['experimental/examples/wheel/lib/module_with_data.py',
30-
'experimental/examples/wheel/lib/simple_module.py',
29+
['examples/wheel/lib/module_with_data.py',
30+
'examples/wheel/lib/simple_module.py',
3131
'example_minimal_library-0.0.1.dist-info/WHEEL',
3232
'example_minimal_library-0.0.1.dist-info/METADATA',
3333
'example_minimal_library-0.0.1.dist-info/RECORD'])
3434

3535
def test_py_package_wheel(self):
3636
filename = os.path.join(os.environ['TEST_SRCDIR'],
37-
'rules_python', 'experimental',
37+
'rules_python',
3838
'examples', 'wheel',
3939
'example_minimal_package-0.0.1-py3-none-any.whl')
4040
with zipfile.ZipFile(filename) as zf:
4141
self.assertEquals(
4242
zf.namelist(),
43-
['experimental/examples/wheel/lib/data.txt',
44-
'experimental/examples/wheel/lib/module_with_data.py',
45-
'experimental/examples/wheel/lib/simple_module.py',
46-
'experimental/examples/wheel/main.py',
43+
['examples/wheel/lib/data.txt',
44+
'examples/wheel/lib/module_with_data.py',
45+
'examples/wheel/lib/simple_module.py',
46+
'examples/wheel/main.py',
4747
'example_minimal_package-0.0.1.dist-info/WHEEL',
4848
'example_minimal_package-0.0.1.dist-info/METADATA',
4949
'example_minimal_package-0.0.1.dist-info/RECORD'])
5050

5151
def test_customized_wheel(self):
5252
filename = os.path.join(os.environ['TEST_SRCDIR'],
53-
'rules_python', 'experimental',
53+
'rules_python',
5454
'examples', 'wheel',
5555
'example_customized-0.0.1-py3-none-any.whl')
5656
with zipfile.ZipFile(filename) as zf:
5757
self.assertEquals(
5858
zf.namelist(),
59-
['experimental/examples/wheel/lib/data.txt',
60-
'experimental/examples/wheel/lib/module_with_data.py',
61-
'experimental/examples/wheel/lib/simple_module.py',
62-
'experimental/examples/wheel/main.py',
59+
['examples/wheel/lib/data.txt',
60+
'examples/wheel/lib/module_with_data.py',
61+
'examples/wheel/lib/simple_module.py',
62+
'examples/wheel/main.py',
6363
'example_customized-0.0.1.dist-info/WHEEL',
6464
'example_customized-0.0.1.dist-info/METADATA',
6565
'example_customized-0.0.1.dist-info/entry_points.txt',
@@ -77,11 +77,11 @@ def test_customized_wheel(self):
7777
example_customized-0.0.1.dist-info/METADATA,sha256=TeeEmokHE2NWjkaMcVJuSAq4_AXUoIad2-SLuquRmbg,372
7878
example_customized-0.0.1.dist-info/RECORD,,
7979
example_customized-0.0.1.dist-info/WHEEL,sha256=sobxWSyDDkdg_rinUth-jxhXHqoNqlmNMJY3aTZn2Us,91
80-
example_customized-0.0.1.dist-info/entry_points.txt,sha256=mEWsq4sMoyqR807QV8Z3KPocGfKvtgTo1lBFTRb6b78,150
81-
experimental/examples/wheel/lib/data.txt,sha256=9vJKEdfLu8bZRArKLroPZJh1XKkK3qFMXiM79MBL2Sg,12
82-
experimental/examples/wheel/lib/module_with_data.py,sha256=K_IGAq_CHcZX0HUyINpD1hqSKIEdCn58d9E9nhWF2EA,636
83-
experimental/examples/wheel/lib/simple_module.py,sha256=72-91Dm6NB_jw-7wYQt7shzdwvk5RB0LujIah8g7kr8,636
84-
experimental/examples/wheel/main.py,sha256=E0xCyiPg6fCo4IrFmqo_tqpNGtk1iCewobqD0_KlFd0,935
80+
example_customized-0.0.1.dist-info/entry_points.txt,sha256=pqzpbQ8MMorrJ3Jp0ntmpZcuvfByyqzMXXi2UujuXD0,137
81+
examples/wheel/lib/data.txt,sha256=9vJKEdfLu8bZRArKLroPZJh1XKkK3qFMXiM79MBL2Sg,12
82+
examples/wheel/lib/module_with_data.py,sha256=K_IGAq_CHcZX0HUyINpD1hqSKIEdCn58d9E9nhWF2EA,636
83+
examples/wheel/lib/simple_module.py,sha256=72-91Dm6NB_jw-7wYQt7shzdwvk5RB0LujIah8g7kr8,636
84+
examples/wheel/main.py,sha256=xnha0jPnVBJt3LUQRbLf7rFA5njczSdd3gm3kSyQJZw,909
8585
""")
8686
self.assertEquals(wheel_contents, b"""\
8787
Wheel-Version: 1.0
@@ -106,32 +106,32 @@ def test_customized_wheel(self):
106106
self.assertEquals(entry_point_contents, b"""\
107107
[console_scripts]
108108
another = foo.bar:baz
109-
customized_wheel = experimental.examples.wheel.main:main
109+
customized_wheel = examples.wheel.main:main
110110
111111
[group2]
112112
first = first.main:f
113113
second = second.main:s""")
114114

115115
def test_custom_package_root_wheel(self):
116116
filename = os.path.join(os.environ['TEST_SRCDIR'],
117-
'rules_python', 'experimental',
117+
'rules_python',
118118
'examples', 'wheel',
119119
'example_custom_package_root-0.0.1-py3-none-any.whl')
120120

121121
with zipfile.ZipFile(filename) as zf:
122122
self.assertEquals(
123123
zf.namelist(),
124-
['examples/wheel/lib/data.txt',
125-
'examples/wheel/lib/module_with_data.py',
126-
'examples/wheel/lib/simple_module.py',
127-
'examples/wheel/main.py',
124+
['wheel/lib/data.txt',
125+
'wheel/lib/module_with_data.py',
126+
'wheel/lib/simple_module.py',
127+
'wheel/main.py',
128128
'example_custom_package_root-0.0.1.dist-info/WHEEL',
129129
'example_custom_package_root-0.0.1.dist-info/METADATA',
130130
'example_custom_package_root-0.0.1.dist-info/RECORD'])
131131

132132
def test_custom_package_root_multi_prefix_wheel(self):
133133
filename = os.path.join(os.environ['TEST_SRCDIR'],
134-
'rules_python', 'experimental',
134+
'rules_python',
135135
'examples', 'wheel',
136136
'example_custom_package_root_multi_prefix-0.0.1-py3-none-any.whl')
137137

@@ -148,7 +148,7 @@ def test_custom_package_root_multi_prefix_wheel(self):
148148

149149
def test_custom_package_root_multi_prefix_reverse_order_wheel(self):
150150
filename = os.path.join(os.environ['TEST_SRCDIR'],
151-
'rules_python', 'experimental',
151+
'rules_python',
152152
'examples', 'wheel',
153153
'example_custom_package_root_multi_prefix_reverse_order-0.0.1-py3-none-any.whl')
154154

@@ -165,7 +165,7 @@ def test_custom_package_root_multi_prefix_reverse_order_wheel(self):
165165

166166
def test_python_requires_wheel(self):
167167
filename = os.path.join(os.environ['TEST_SRCDIR'],
168-
'rules_python', 'experimental',
168+
'rules_python',
169169
'examples', 'wheel',
170170
'example_python_requires_in_a_package-0.0.1-py3-none-any.whl')
171171
with zipfile.ZipFile(filename) as zf:
@@ -185,7 +185,6 @@ def test_python_abi3_binary_wheel(self):
185185
filename = os.path.join(
186186
os.environ["TEST_SRCDIR"],
187187
"rules_python",
188-
"experimental",
189188
"examples",
190189
"wheel",
191190
"example_python_abi3_binary_wheel-0.0.1-cp38-abi3-manylinux2014_x86_64.whl",
@@ -221,15 +220,15 @@ def test_python_abi3_binary_wheel(self):
221220

222221
def test_genrule_creates_directory_and_is_included_in_wheel(self):
223222
filename = os.path.join(os.environ['TEST_SRCDIR'],
224-
'rules_python', 'experimental',
223+
'rules_python',
225224
'examples', 'wheel',
226225
'use_genrule_with_dir_in_outs-0.0.1-py3-none-any.whl')
227226

228227
with zipfile.ZipFile(filename) as zf:
229228
self.assertEquals(
230229
zf.namelist(),
231-
['experimental/examples/wheel/main.py',
232-
'experimental/examples/wheel/someDir/foo.py',
230+
['examples/wheel/main.py',
231+
'examples/wheel/someDir/foo.py',
233232
'use_genrule_with_dir_in_outs-0.0.1.dist-info/WHEEL',
234233
'use_genrule_with_dir_in_outs-0.0.1.dist-info/METADATA',
235234
'use_genrule_with_dir_in_outs-0.0.1.dist-info/RECORD'])

0 commit comments

Comments
 (0)