Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion experimental/examples/wheel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ py_wheel(
],
)

py_wheel(
name = "python_abi3_binary_wheel",
abi = "abi3",
distribution = "example_python_abi3_binary_wheel",
platform = "manylinux2014_x86_64",
python_requires = ">=3.8",
python_tag = "cp38",
version = "0.0.1",
)

py_test(
name = "wheel_test",
srcs = ["wheel_test.py"],
Expand All @@ -156,6 +166,7 @@ py_test(
":customized",
":minimal_with_py_library",
":minimal_with_py_package",
":python_requires_in_a_package"
":python_abi3_binary_wheel",
":python_requires_in_a_package",
],
)
38 changes: 38 additions & 0 deletions experimental/examples/wheel/wheel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,44 @@ def test_python_requires_wheel(self):
UNKNOWN
""")

def test_python_abi3_binary_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"experimental",
"examples",
"wheel",
"example_python_abi3_binary_wheel-0.0.1-cp38-abi3-manylinux2014_x86_64.whl",
)
with zipfile.ZipFile(filename) as zf:
metadata_contents = zf.read(
"example_python_abi3_binary_wheel-0.0.1.dist-info/METADATA"
)
# The entries are guaranteed to be sorted.
self.assertEqual(
metadata_contents,
b"""\
Metadata-Version: 2.1
Name: example_python_abi3_binary_wheel
Version: 0.0.1
Requires-Python: >=3.8

UNKNOWN
""",
)
wheel_contents = zf.read(
"example_python_abi3_binary_wheel-0.0.1.dist-info/WHEEL"
)
self.assertEqual(
wheel_contents,
b"""\
Wheel-Version: 1.0
Generator: bazel-wheelmaker 1.0
Root-Is-Purelib: false
Tag: cp38-abi3-manylinux2014_x86_64
""",
)


if __name__ == '__main__':
unittest.main()
20 changes: 16 additions & 4 deletions experimental/python/wheel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,27 @@ This should match the project name onm PyPI. It's also the name that is used to
refer to the package in other packages' dependencies.
""",
),
# TODO(pstradomski): Support non-pure wheels
"platform": attr.string(
default = "any",
doc = "Supported platforms. 'any' for pure-Python wheel.",
doc = """\
Supported platform. Use 'any' for pure-Python wheel.

If you have included platform-specific data, such as a .pyd or .so
extension module, you will need to specify the platform in standard
pip format. If you support multiple platforms, you can define
platform constraints, then use a select() to specify the appropriate
specifier, eg:

platform = select({
"//platforms:windows_x86_64": "win_amd64",
"//platforms:macos_x86_64": "macosx_10_7_x86_64",
"//platforms:linux_x86_64": "manylinux2014_x86_64",
})
""",
),
"python_tag": attr.string(
default = "py3",
doc = "Supported Python major version. 'py2' or 'py3'",
values = ["py2", "py3"],
doc = "Supported Python version(s), eg 'py3', 'cp35.cp36', etc",
),
"version": attr.string(
mandatory = True,
Expand Down
7 changes: 2 additions & 5 deletions experimental/tools/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def add_wheelfile(self):
wheel_contents = """\
Wheel-Version: 1.0
Generator: bazel-wheelmaker 1.0
Root-Is-Purelib: true
"""
Root-Is-Purelib: {}
""".format("true" if self._platform == "any" else "false")
for tag in self.disttags():
wheel_contents += "Tag: %s\n" % tag
self.add_string(self.distinfo_path('WHEEL'), wheel_contents)
Expand Down Expand Up @@ -255,9 +255,6 @@ def main():
"Can be supplied multiple times.")
arguments = parser.parse_args(sys.argv[1:])

# add_wheelfile and add_metadata currently assume pure-Python.
assert arguments.platform == 'any', "Only pure-Python wheels are supported"

if arguments.input_file:
input_files = [i.split(';') for i in arguments.input_file]
else:
Expand Down