-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add manylinux compliance check macros for Linux platforms.
Example of usage: ``` load( "@tsl//:third_party/py/py_manylinux_compliance_test.bzl", "verify_manylinux_compliance_test", ) verify_manylinux_compliance_test( name = "manylinux_compliance_test", aarch64_compliance_tag = "manylinux_2_17_aarch64", test_tags = [ "mac_excluded", "windows_excluded", ], wheel = ":wheel", x86_64_compliance_tag = "manylinux_2_17_x86_64", ) ``` The test target is executed only when specified in Bazel command line. The test passes if `auditwheel show` results have the compliance tag value (depends on the machine type). The test fails otherwise and prints the `auditwheel show` results. PiperOrigin-RevId: 705993270
- Loading branch information
1 parent
d80d15e
commit 47daf5a
Showing
7 changed files
with
114 additions
and
9 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
68 changes: 68 additions & 0 deletions
68
third_party/tsl/third_party/py/manylinux_compliance_test.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,68 @@ | ||
# Copyright 2024 The TensorFlow 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. | ||
# ============================================================================== | ||
|
||
import argparse | ||
import platform | ||
import subprocess | ||
import sys | ||
|
||
|
||
def parse_args(): | ||
"""Arguments parser.""" | ||
parser = argparse.ArgumentParser( | ||
description="Helper for auditwheel", fromfile_prefix_chars="@" | ||
) | ||
parser.add_argument( | ||
"--verify-manylinux-compliance-script", | ||
required=True, | ||
help="Path of the verify manylinux compliance script, mandatory", | ||
) | ||
parser.add_argument( | ||
"--wheel-path", required=True, help="Path of the wheel, mandatory" | ||
) | ||
parser.add_argument( | ||
"--aarch64-compliance-tag", | ||
required=True, | ||
help="ManyLinux compliance tag for aarch64", | ||
) | ||
parser.add_argument( | ||
"--x86_64-compliance-tag", | ||
required=True, | ||
help="ManyLinux compliance tag for x86_64", | ||
) | ||
return parser.parse_args() | ||
|
||
|
||
def test_manylinux_compliance(comliance_check_args): | ||
machine_type = platform.uname().machine | ||
if machine_type == "x86_64": | ||
compliance_tag = compliance_check_args.x86_64_compliance_tag | ||
else: | ||
compliance_tag = compliance_check_args.aarch64_compliance_tag | ||
subprocess.run( | ||
[ | ||
sys.executable, | ||
comliance_check_args.verify_manylinux_compliance_script, | ||
"--wheel-path={}".format(comliance_check_args.wheel_path), | ||
"--compliance-tag={}".format(compliance_tag), | ||
"--auditwheel-show-log-path=auditwheel_show.log", | ||
], | ||
check=True, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
compliance_check_args = parse_args() | ||
test_manylinux_compliance(compliance_check_args) |
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
27 changes: 27 additions & 0 deletions
27
third_party/tsl/third_party/py/py_manylinux_compliance_test.bzl
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,27 @@ | ||
""" Macros for manylinux compliance verification test. """ | ||
|
||
load("@rules_python//python:py_test.bzl", "py_test") | ||
|
||
def verify_manylinux_compliance_test( | ||
name, | ||
wheel, | ||
aarch64_compliance_tag, | ||
x86_64_compliance_tag, | ||
test_tags = []): | ||
verify_manylinux_compliance_target = Label("//third_party/py:verify_manylinux_compliance") | ||
py_test( | ||
name = name, | ||
srcs = [Label("//third_party/py:manylinux_compliance_test")], | ||
data = [ | ||
wheel, | ||
verify_manylinux_compliance_target, | ||
], | ||
args = [ | ||
"--verify-manylinux-compliance-script=$(location {})".format(verify_manylinux_compliance_target), | ||
"--wheel-path=$(location {})".format(wheel), | ||
"--aarch64-compliance-tag={}".format(aarch64_compliance_tag), | ||
"--x86_64-compliance-tag={}".format(x86_64_compliance_tag), | ||
], | ||
main = "manylinux_compliance_test.py", | ||
tags = ["manual"] + test_tags, | ||
) |
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