diff --git a/.github/actions/build_toplevel/action.yml b/.github/actions/build_toplevel/action.yml index 5b842fa084..f72cec9923 100644 --- a/.github/actions/build_toplevel/action.yml +++ b/.github/actions/build_toplevel/action.yml @@ -86,6 +86,7 @@ runs: variant: ${{ inputs.prepare_kind }} wheel: ${{ steps.buildwheel.outputs.wheel_filename }} build_dir: ${{ steps.buildwheel.outputs.build_dir }} + python: ${{ inputs.python }} - name: Find wheel shell: wrap-shell {0} id: find diff --git a/.github/actions/post_build/action.yml b/.github/actions/post_build/action.yml index 3cb551c834..b51de4c823 100644 --- a/.github/actions/post_build/action.yml +++ b/.github/actions/post_build/action.yml @@ -12,6 +12,9 @@ inputs: build_dir: required: true type: string + python: + required: true + type: string runs: using: "composite" @@ -21,6 +24,7 @@ runs: uses: ./.github/actions/post_build_linux with: wheel: ${{ inputs.wheel }} + python: ${{ inputs.python }} - name: Post-build MacOS if: ${{ inputs.variant == 'macos' }} uses: ./.github/actions/post_build_macos diff --git a/.github/actions/post_build_linux/action.yml b/.github/actions/post_build_linux/action.yml index 6c15776619..1e17069de0 100644 --- a/.github/actions/post_build_linux/action.yml +++ b/.github/actions/post_build_linux/action.yml @@ -5,6 +5,9 @@ inputs: wheel: required: true type: string + python: + required: true + type: string runs: using: "composite" @@ -12,4 +15,8 @@ runs: - name: Auditwheel repair shell: wrap-shell {0} run: | - auditwheel repair --plat manylinux_2_31_${{ matrix.manylinux_arch }} --only-plat -w final_wheel ${{ inputs.wheel }} \ No newline at end of file + unzip -d /tmp/analyze_wheel ${{ inputs.wheel }} + ELF_FILES=$(find /tmp/analyze_wheel -type f -exec file {} \; | grep ELF | awk -F: '{print $1}' | tr '\n' ' ') + EXCLUDE_QT_DEPENDENCIES=$(${{ inputs.python }} scripts/generate_auditwheel_excludes.py ".*Qt6.*" $ELF_FILES) + echo "Excluding: $EXCLUDE_QT_DEPENDENCIES" + auditwheel repair --exclude $EXCLUDE_QT_DEPENDENCIES --plat manylinux_2_31_${{ matrix.manylinux_arch }} --only-plat -w final_wheel ${{ inputs.wheel }} \ No newline at end of file diff --git a/scripts/generate_auditwheel_excludes.py b/scripts/generate_auditwheel_excludes.py new file mode 100644 index 0000000000..31bdbaaa02 --- /dev/null +++ b/scripts/generate_auditwheel_excludes.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +import sys +import os +import subprocess +import json +import re +import copy + +ignore_regex = sys.argv[1] + +all_ignores = set() +for file in sys.argv[2:]: + tree_text = subprocess.check_output(['lddtree', '-a', file]).decode('utf-8') + + # Represent the lines with their depth + tree_items = [] + for line in tree_text.split('\n')[1:]: + if not line: + continue + depth = int((len(line) - len(line.lstrip()))/4) + stripped = re.sub(r'[\s]*=>.*', '', line).strip() + tree_items.append((depth, stripped)) + + tree = { + 'name': 'root', + 'children': [], + 'parent': None, + 'depth': 0, + 'ignored': False + } + cur_parent = tree + for depth, item in tree_items: + while depth <= cur_parent['depth']: + if cur_parent["parent"] is None: + raise Exception('Unexpected depth decrease') + cur_parent = cur_parent['parent'] + if depth > cur_parent['depth']+1: + if depth > cur_parent['depth']+2: + raise Exception('Unexpected depth increase') + new_node = { + 'name': item, + 'children': [], + 'parent': cur_parent, + 'depth': cur_parent['depth']+2, + 'ignored': False + } + cur_parent = cur_parent['children'][-1] + cur_parent['children'].append(new_node) + continue + + new_node = { + 'name': item, + 'children': [], + 'parent': cur_parent, + 'depth': depth, + 'ignored': False + } + cur_parent['children'].append(new_node) + + def update_ignore(node): + ignore_based_on_regex = bool(re.match(ignore_regex, node['name'])) + if (node['parent'] and node['parent']['ignored']) or ignore_based_on_regex: + node['ignored'] = True + for child in node['children']: + update_ignore(child) + + update_ignore(tree) + + def print_node(node, depth=0): + print(' '*depth + node['name'] + (' (ignored)' if node['ignored'] else '')) + for child in node['children']: + print_node(child, depth+1) + # print_node(tree) + + def flatten(node, into, condition=lambda x: True): + if condition(node): + into.add(node['name']) + for child in node['children']: + flatten(child, into, condition) + + non_ignore_set = set() + flatten(tree, non_ignore_set, lambda node: not node['ignored']) + non_ignore_set.remove('root') + + ignore_set = set() + flatten(tree, ignore_set, lambda node: node['ignored']) + + final_ignore_set = {i for i in ignore_set if i not in non_ignore_set} + all_ignores = all_ignores.union(final_ignore_set) + +print(','.join(all_ignores)) \ No newline at end of file