macOS build: upgrade to Python 3.9 and PySide2 5.15.2

This commit is contained in:
Alberto Sottile 2021-09-19 17:19:16 +02:00
parent 16168effc4
commit 8f44c28c73
4 changed files with 76 additions and 12 deletions

View File

@ -71,7 +71,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.9'
- name: Check Python install
run: |
@ -84,8 +84,20 @@ jobs:
run: |
pip3 install -U setuptools wheel pip
pip3 install twisted[tls] appnope requests certifi
pip3 install shiboken2==5.13.1 pyside2==5.13.1
pip3 install py2app
pip3 install shiboken2==5.15.2 pyside2==5.15.2
pip3 install altgraph modulegraph macholib
- name: Install py2app
run: |
git clone https://github.com/albertosottile/py2app.git
cd py2app
git checkout stubs
cd py2app/apptemplate
python3 setup.py build
cd ../..
python3 setup.py build
python3 setup.py install
cd ..
- name: Check Python dependencies
run: |
@ -96,13 +108,13 @@ jobs:
python3 -c "from py2app.recipes import pyside2"
echo $DYLD_LIBRARY_PATH
echo $DYLD_FRAMEWORK_PATH
python3 -c 'from distutils.sysconfig import get_config_var; print(get_config_var("LDLIBRARY"))'
# python3 -c 'from distutils.sysconfig import get_config_var; print(get_config_var("LDLIBRARY"))'
- name: Build
run: |
python3 ci/pyside2_linker.py
export LIBPYTHON_FOLDER="$(python3 -c 'from distutils.sysconfig import get_config_var; print(get_config_var("LIBDIR"))')"
ln -s $LIBPYTHON_FOLDER/libpython3.7m.dylib $LIBPYTHON_FOLDER/libpython3.7.dylib
# export LIBPYTHON_FOLDER="$(python3 -c 'from distutils.sysconfig import get_config_var; print(get_config_var("LIBDIR"))')"
# ln -s $LIBPYTHON_FOLDER/libpython3.9m.dylib $LIBPYTHON_FOLDER/libpython3.9.dylib
export DYLD_FRAMEWORK_PATH="$(python3 -c 'from PySide2.QtCore import QLibraryInfo; print(QLibraryInfo.location(QLibraryInfo.LibrariesPath))')"
export DYLD_LIBRARY_PATH="$(python3 -c 'import os.path, PySide2; print(os.path.dirname(PySide2.__file__))'):$(python3 -c 'import os.path, shiboken2; print(os.path.dirname(shiboken2.__file__))')"
python3 buildPy2app.py py2app

View File

@ -31,7 +31,6 @@ OPTIONS = {
'CFBundleIdentifier': 'pl.syncplay.Syncplay',
'LSMinimumSystemVersion': '10.12.0',
'NSHumanReadableCopyright': 'Copyright © 2019 Syncplay All Rights Reserved',
'NSRequiresAquaSystemAppearance': False,
}
}

View File

@ -17,4 +17,4 @@ mkdir dist/Syncplay.app/Contents/Resources/es_419.lproj
pip3 install dmgbuild
mv syncplay/resources/macOS_readme.pdf syncplay/resources/.macOS_readme.pdf
dmgbuild -s appdmg.py "Syncplay" dist_actions/Syncplay_${VER}.dmg
python3 -m dmgbuild -s appdmg.py "Syncplay" dist_actions/Syncplay_${VER}.dmg

View File

@ -1,12 +1,20 @@
import os
import platform
import shutil
import zipfile
from glob import glob
pyver = platform.python_version_tuple()[0] + platform.python_version_tuple()[1]
# clean Python library zip archive
PATH = 'dist/Syncplay.app/Contents/Resources/lib'
zin = zipfile.ZipFile(f'{PATH}/python37.zip', 'r')
zin = zipfile.ZipFile(f'{PATH}/python{pyver}.zip', 'r')
tbd = [path for path in zin.namelist() if 'PySide2/Qt/' in path]
zout = zipfile.ZipFile(f'{PATH}/python37_new.zip', 'w', zipfile.ZIP_DEFLATED)
zout = zipfile.ZipFile(f'{PATH}/python{pyver}_new.zip', 'w', zipfile.ZIP_DEFLATED)
for item in zin.namelist():
buffer = zin.read(item)
@ -16,5 +24,50 @@ for item in zin.namelist():
zout.close()
zin.close()
os.remove(f'{PATH}/python37.zip')
os.rename(f'{PATH}/python37_new.zip', f'{PATH}/python37.zip')
os.remove(f'{PATH}/python{pyver}.zip')
os.rename(f'{PATH}/python{pyver}_new.zip', f'{PATH}/python{pyver}.zip')
# clean Frameworks folder
PATH = 'dist/Syncplay.app/Contents/Frameworks'
to_be_kept = ['QtCore', 'QtDBus', 'QtGui', 'QtNetwork', 'QtPrintSupport', 'QtQml', 'QtWidgets']
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)
for p in to_be_deleted:
if os.path.isdir(p):
shutil.rmtree(p, ignore_errors=True)
else:
os.remove(p)
# Clean PySide2 folder
PATH = 'dist/Syncplay.app/Contents/Resources/lib/python3.9/PySide2'
shutil.rmtree(f'{PATH}/examples', ignore_errors=True)
to_be_kept = ['QtCore', 'QtDBus', 'QtGui', 'QtNetwork', 'QtPrintSupport', 'QtQml', 'QtWidgets']
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)
for p in to_be_deleted:
if os.path.isdir(p):
shutil.rmtree(p, ignore_errors=True)
else:
os.remove(p)
# move .so from Framework to PySide2 folder
FROM = 'dist/Syncplay.app/Contents/Frameworks'
TO = 'dist/Syncplay.app/Contents/Resources/lib/python3.9/PySide2'
for f in glob(f'{FROM}/Qt*.so'):
fn = os.path.basename(f)
shutil.move(f, f'{TO}/{fn}')