From baac5db62d0834da1be12691d9718011624ad877 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 21 Nov 2022 15:47:06 +0100 Subject: [PATCH 1/2] [python] fix platform specific wheel to be spec compliant The current build approach causes bdist_wheel to store the shared library in the purelib folder. However, a platform specific wheel should have shared libraries in the platform specific folder, not in the purelib folder. This has been discovered using `auditwheel check`: ``` RuntimeError: Invalid binary wheel, found the following shared library/libraries in purelib folder: _ChipDeviceCtrl.so The wheel has to be platlib compliant in order to be repaired by auditwheel. ``` This makes the wheel pass `auditwheel check`. --- src/controller/python/build-chip-wheel.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/controller/python/build-chip-wheel.py b/src/controller/python/build-chip-wheel.py index e3ab5312cadc16..20e74cf061d6d3 100644 --- a/src/controller/python/build-chip-wheel.py +++ b/src/controller/python/build-chip-wheel.py @@ -23,7 +23,7 @@ from __future__ import absolute_import from datetime import datetime -from setuptools import setup +from setuptools import setup, Distribution from wheel.bdist_wheel import bdist_wheel import argparse @@ -56,6 +56,12 @@ def __init__(self, name): self.name = name self.installName = os.path.splitext(name)[0] +# Make sure wheel is not considered pure and avoid shared libraries in purelib +# folder. +class BinaryDistribution(Distribution): + def has_ext_modules(foo): + return True + packageName = args.package_name libName = args.lib_name @@ -103,13 +109,6 @@ def __init__(self, name): os.rename(os.path.join(tmpDir, script.name), os.path.join(tmpDir, script.installName)) - # Define a custom version of the bdist_wheel command that configures the - # resultant wheel as platform-specific (i.e. not "pure"). - class bdist_wheel_override(bdist_wheel): - def finalize_options(self): - bdist_wheel.finalize_options(self) - self.root_is_pure = False - requiredPackages = manifest['package_reqs'] # @@ -164,9 +163,7 @@ def finalize_options(self): 'egg_base': tmpDir } }, - cmdclass={ - 'bdist_wheel': bdist_wheel_override - } if libName else {}, + distclass=BinaryDistribution if libName else None, script_args=['clean', '--all', 'bdist_wheel'] ) From 7863895bdaa523af36ef7222e8ce28b123bb1975 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 21 Nov 2022 14:51:12 +0000 Subject: [PATCH 2/2] Restyled by autopep8 --- src/controller/python/build-chip-wheel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controller/python/build-chip-wheel.py b/src/controller/python/build-chip-wheel.py index 20e74cf061d6d3..70949c3556b77c 100644 --- a/src/controller/python/build-chip-wheel.py +++ b/src/controller/python/build-chip-wheel.py @@ -58,6 +58,8 @@ def __init__(self, name): # Make sure wheel is not considered pure and avoid shared libraries in purelib # folder. + + class BinaryDistribution(Distribution): def has_ext_modules(foo): return True