2021-01-11 18:55:59 +00:00
|
|
|
import os
|
2021-09-19 15:19:16 +00:00
|
|
|
import platform
|
|
|
|
import shutil
|
2021-01-11 18:55:59 +00:00
|
|
|
|
2021-09-19 15:19:16 +00:00
|
|
|
from glob import glob
|
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
pyver = platform.python_version_tuple()[0] + '.' + platform.python_version_tuple()[1]
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
# Clean resources
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
PATH = 'dist/Syncplay.app/Contents/Resources/'
|
2021-01-11 18:55:59 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
to_be_kept = []
|
|
|
|
to_be_deleted = []
|
2021-01-11 18:55:59 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
for f in glob(f'{PATH}/qt*'):
|
|
|
|
if not any({k in f for k in to_be_kept}):
|
|
|
|
to_be_deleted.append(f)
|
2021-01-11 18:55:59 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
for p in to_be_deleted:
|
|
|
|
if os.path.exists(p):
|
|
|
|
if os.path.isdir(p):
|
|
|
|
shutil.rmtree(p, ignore_errors=True)
|
|
|
|
else:
|
|
|
|
os.remove(p)
|
2021-01-11 18:55:59 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
# Clean PySide6 folder
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
PATH = f'dist/Syncplay.app/Contents/Resources/lib/python{pyver}/PySide6'
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
shutil.rmtree(f'{PATH}/examples', ignore_errors=True)
|
|
|
|
shutil.rmtree(f'{PATH}/include', ignore_errors=True)
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
to_be_kept = ['QtCore', 'QtGui', 'QtWidgets']
|
2021-09-19 15:19:16 +00:00
|
|
|
to_be_deleted = []
|
|
|
|
|
|
|
|
for f in glob(f'{PATH}/Qt*'):
|
|
|
|
if not any({k in f for k in to_be_kept}):
|
|
|
|
to_be_deleted.append(f)
|
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
for a in glob(f'{PATH}/*.app'):
|
|
|
|
to_be_deleted.append(a)
|
|
|
|
|
|
|
|
to_be_deleted.remove(f'{PATH}/Qt')
|
|
|
|
to_be_deleted.extend([f'{PATH}/lupdate', f'{PATH}/qmllint', f'{PATH}/lrelease'])
|
|
|
|
|
2021-09-19 15:19:16 +00:00
|
|
|
for p in to_be_deleted:
|
2022-11-05 22:40:30 +00:00
|
|
|
if os.path.exists(p):
|
|
|
|
if os.path.isdir(p):
|
|
|
|
shutil.rmtree(p, ignore_errors=True)
|
|
|
|
else:
|
|
|
|
os.remove(p)
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
# Clean PySide6/Qt folder
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
PATH = f'dist/Syncplay.app/Contents/Resources/lib/python{pyver}/PySide6/Qt'
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
to_be_deleted.extend([f'{PATH}/qml', f'{PATH}/translations'])
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
for p in to_be_deleted:
|
|
|
|
if os.path.exists(p):
|
|
|
|
if os.path.isdir(p):
|
|
|
|
shutil.rmtree(p, ignore_errors=True)
|
|
|
|
else:
|
|
|
|
os.remove(p)
|
|
|
|
|
|
|
|
# Clean PySide6/Qt/lib folder
|
|
|
|
|
|
|
|
PATH = f'dist/Syncplay.app/Contents/Resources/lib/python{pyver}/PySide6/Qt/lib'
|
|
|
|
|
|
|
|
to_be_kept = ['QtCore', 'QtDBus', 'QtGui', 'QtWidgets']
|
|
|
|
to_be_deleted = [f'{PATH}/metatypes']
|
2021-09-19 15:19:16 +00:00
|
|
|
|
|
|
|
for f in glob(f'{PATH}/Qt*'):
|
|
|
|
if not any({k in f for k in to_be_kept}):
|
|
|
|
to_be_deleted.append(f)
|
|
|
|
|
|
|
|
for p in to_be_deleted:
|
2022-11-05 22:40:30 +00:00
|
|
|
if os.path.exists(p):
|
|
|
|
if os.path.isdir(p):
|
|
|
|
shutil.rmtree(p, ignore_errors=True)
|
|
|
|
else:
|
|
|
|
os.remove(p)
|
|
|
|
|
|
|
|
# Clean PySide6/Qt/plugins folder
|
|
|
|
|
|
|
|
PATH = f'dist/Syncplay.app/Contents/Resources/lib/python{pyver}/PySide6/Qt/plugins'
|
|
|
|
|
|
|
|
to_be_kept = ['platforms', 'styles']
|
|
|
|
to_be_deleted = []
|
|
|
|
|
|
|
|
for f in glob(f'{PATH}/*'):
|
|
|
|
if not any({k in f for k in to_be_kept}):
|
|
|
|
to_be_deleted.append(f)
|
|
|
|
|
|
|
|
for p in to_be_deleted:
|
|
|
|
if os.path.exists(p):
|
|
|
|
if os.path.isdir(p):
|
|
|
|
shutil.rmtree(p, ignore_errors=True)
|
|
|
|
else:
|
|
|
|
os.remove(p)
|
|
|
|
|
|
|
|
# symlink .so from shiboken6 to PySide6 folder
|
|
|
|
|
|
|
|
cwd = os.getcwd()
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
FROM = f'dist/Syncplay.app/Contents/Resources/lib/python{pyver}/shiboken6'
|
|
|
|
TO = f'dist/Syncplay.app/Contents/Resources/lib/python{pyver}/PySide6'
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
fn = os.path.basename(glob(f'{FROM}/libshiboken6*.dylib')[0])
|
2021-09-19 15:19:16 +00:00
|
|
|
|
2022-11-05 22:40:30 +00:00
|
|
|
os.chdir(TO)
|
|
|
|
os.symlink(f'../shiboken6/{fn}', f'./{fn}')
|
|
|
|
os.chdir(cwd)
|