Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderVocke committed Aug 1, 2024
1 parent d65f163 commit ad0d17d
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/actions/build_toplevel/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/post_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inputs:
build_dir:
required: true
type: string
python:
required: true
type: string

runs:
using: "composite"
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion .github/actions/post_build_linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ inputs:
wheel:
required: true
type: string
python:
required: true
type: string

runs:
using: "composite"
steps:
- name: Auditwheel repair
shell: wrap-shell {0}
run: |
auditwheel repair --plat manylinux_2_31_${{ matrix.manylinux_arch }} --only-plat -w final_wheel ${{ inputs.wheel }}
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 }}
91 changes: 91 additions & 0 deletions scripts/generate_auditwheel_excludes.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit ad0d17d

Please sign in to comment.