Update Windows build script to support PySide6

This commit is contained in:
Micah Lee 2023-02-08 15:28:20 -08:00
parent a14c3fcffc
commit 600780292a
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
4 changed files with 92 additions and 309 deletions

View File

@ -127,20 +127,19 @@ From https://snapcraft.io/onionshare/releases (you must be logged in), promote t
Set up the packaging environment:
- Install the Windows SDK from here: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ and add `C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool` to the path (you'll need it for `signtool.exe`)
- Install the Windows SDK from here: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ and add `C:\Program Files (x86)\Windows Kits\10\App Certification Kit` to the path (you'll need it for `signtool.exe`)
- Go to https://dotnet.microsoft.com/download/dotnet-framework and download and install .NET Framework 3.5 SP1 Runtime. I downloaded `dotnetfx35.exe`.
- Go to https://wixtoolset.org/releases/ and download and install WiX toolset. I downloaded `wix311.exe`. Add `C:\Program Files (x86)\WiX Toolset v3.11\bin` to the path.
Github Actions will build the binaries. Find the Github Actions `build` workflow, switch to the summary tab, and download:
- `build-win32`
- `build-win64`
Extract these files, change to the `desktop` folder, and run:
```
poetry run python .\scripts\build-windows.py codesign [onionshare_win32_path] [onionshare_win64_path]
poetry run python .\scripts\build-windows.py package [onionshare_win32_path] [onionshare_win64_path]
poetry run python .\scripts\build-windows.py codesign [onionshare_win64_path]
poetry run python .\scripts\build-windows.py package [onionshare_win64_path]
```
This will create:

View File

@ -29,9 +29,9 @@ poetry install
**Linux users:** In Ubuntu 20.04 you need the `libxcb-xinerama0` package installed.
**Windows users:** Download and install 7-Zip from https://7-zip.org/download.html. [Add](https://medium.com/@kevinmarkvi/how-to-add-executables-to-your-path-in-windows-5ffa4ce61a53) `C:\Program Files (x86)\7-Zip` to your path.
**Windows users:** Download and install 7-Zip (x64) from https://7-zip.org/download.html. [Add](https://medium.com/@kevinmarkvi/how-to-add-executables-to-your-path-in-windows-5ffa4ce61a53) `C:\Program Files\7-Zip` to your path.
Download Tor Browser and extract the binaries for your platform. The platform must be `win32`, `win64`, `macos`, or `linux64`.
Download Tor Browser and extract the binaries for your platform. The platform must be `win64`, `macos`, or `linux64`.
```sh
poetry run python ./scripts/get-tor.py [platform]

View File

@ -8,6 +8,7 @@ import shutil
import subprocess
import uuid
import xml.etree.ElementTree as ET
from glob import glob
root = os.path.dirname(
os.path.dirname(
@ -17,14 +18,6 @@ root = os.path.dirname(
desktop_dir = os.path.join(root, "desktop")
def get_build_path():
if "64 bit" in sys.version:
python_arch = "win-amd64"
else:
python_arch = "win32"
return os.path.join(desktop_dir, "build", f"exe.{python_arch}-3.10")
def get_size(dir):
size = 0
for path, dirs, files in os.walk(dir):
@ -327,244 +320,58 @@ def main():
@main.command()
def cleanup_build():
"""Delete unused PySide2 stuff to save space"""
build_path = get_build_path()
"""Delete unused PySide6 stuff to save space"""
build_path = os.path.join(desktop_dir, "build", "exe.win-amd64-3.10")
before_size = get_size(build_path)
for dirname in ["examples", "qml"]:
shutil.rmtree(os.path.join(build_path, "lib", "PySide2", dirname))
for filename in [
"lconvert.exe",
"linguist.exe",
"lrelease.exe",
"lupdate.exe",
"plugins/assetimporters/assimp.dll",
"plugins/assetimporters/uip.dll",
"plugins/audio/qtaudio_wasapi.dll",
"plugins/audio/qtaudio_windows.dll",
"plugins/bearer/qgenericbearer.dll",
"plugins/canbus/qtpassthrucanbus.dll",
"plugins/canbus/qtpeakcanbus.dll",
"plugins/canbus/qtsysteccanbus.dll",
"plugins/canbus/qttinycanbus.dll",
"plugins/canbus/qtvectorcanbus.dll",
"plugins/canbus/qtvirtualcanbus.dll",
"plugins/gamepads/xinputgamepad.dll",
"plugins/generic/qtuiotouchplugin.dll",
"plugins/geometryloaders/defaultgeometryloader.dll",
"plugins/geometryloaders/gltfgeometryloader.dll",
"plugins/geoservices/qtgeoservices_esri.dll",
"plugins/geoservices/qtgeoservices_itemsoverlay.dll",
"plugins/geoservices/qtgeoservices_mapbox.dll",
"plugins/geoservices/qtgeoservices_nokia.dll",
"plugins/geoservices/qtgeoservices_osm.dll",
"plugins/mediaservice/dsengine.dll",
"plugins/mediaservice/qtmedia_audioengine.dll",
"plugins/mediaservice/wmfengine.dll",
"plugins/platforminputcontexts/qtvirtualkeyboardplugin.dll",
"plugins/platforms/qdirect2d.dll",
"plugins/platforms/qoffscreen.dll",
"plugins/platforms/qwebgl.dll",
"plugins/platformthemes/qxdgdesktopportal.dll",
"plugins/playlistformats/qtmultimedia_m3u.dll",
"plugins/position/qtposition_positionpoll.dll",
"plugins/position/qtposition_serialnmea.dll",
"plugins/position/qtposition_winrt.dll",
"plugins/printsupport/windowsprintersupport.dll",
"plugins/qmltooling/qmldbg_debugger.dll",
"plugins/qmltooling/qmldbg_inspector.dll",
"plugins/qmltooling/qmldbg_local.dll",
"plugins/qmltooling/qmldbg_messages.dll",
"plugins/qmltooling/qmldbg_native.dll",
"plugins/qmltooling/qmldbg_nativedebugger.dll",
"plugins/qmltooling/qmldbg_preview.dll",
"plugins/qmltooling/qmldbg_profiler.dll",
"plugins/qmltooling/qmldbg_quickprofiler.dll",
"plugins/qmltooling/qmldbg_server.dll",
"plugins/qmltooling/qmldbg_tcp.dll",
"plugins/renderers/openglrenderer.dll",
"plugins/renderplugins/scene2d.dll",
"plugins/scenegraph/qsgd3d12backend.dll",
"plugins/sceneparsers/gltfsceneexport.dll",
"plugins/sceneparsers/gltfsceneimport.dll",
"plugins/sensorgestures/qtsensorgestures_plugin.dll",
"plugins/sensorgestures/qtsensorgestures_shakeplugin.dll",
"plugins/sensors/qtsensors_generic.dll",
"plugins/sqldrivers/qsqlite.dll",
"plugins/sqldrivers/qsqlodbc.dll",
"plugins/sqldrivers/qsqlpsql.dll",
"plugins/styles/qwindowsvistastyle.dll",
"plugins/texttospeech/qtexttospeech_sapi.dll",
"plugins/virtualkeyboard/qtvirtualkeyboard_hangul.dll",
"plugins/virtualkeyboard/qtvirtualkeyboard_openwnn.dll",
"plugins/virtualkeyboard/qtvirtualkeyboard_pinyin.dll",
"plugins/virtualkeyboard/qtvirtualkeyboard_tcime.dll",
"plugins/virtualkeyboard/qtvirtualkeyboard_thai.dll",
"plugins/webview/qtwebview_webengine.dll",
"pyside2-lupdate.exe",
"Qt3DAnimation.pyd",
"Qt3DAnimation.pyi",
"Qt3DCore.pyd",
"Qt3DCore.pyi",
"Qt3DExtras.pyd",
"Qt3DExtras.pyi",
"Qt3DInput.pyd",
"Qt3DInput.pyi",
"Qt3DLogic.pyd",
"Qt3DLogic.pyi",
"Qt3DRender.pyd",
"Qt3DRender.pyi",
"Qt53DAnimation.dll",
"Qt53DCore.dll",
"Qt53DExtras.dll",
"Qt53DInput.dll",
"Qt53DLogic.dll",
"Qt53DQuick.dll",
"Qt53DQuickAnimation.dll",
"Qt53DQuickExtras.dll",
"Qt53DQuickInput.dll",
"Qt53DQuickRender.dll",
"Qt53DQuickScene2D.dll",
"Qt53DRender.dll",
"Qt5Bluetooth.dll",
"Qt5Bodymovin.dll",
"Qt5Charts.dll",
"Qt5Concurrent.dll",
"Qt5DataVisualization.dll",
"Qt5DBus.dll",
"Qt5Designer.dll",
"Qt5DesignerComponents.dll",
"Qt5Gamepad.dll",
"Qt5Help.dll",
"Qt5Location.dll",
"Qt5Multimedia.dll",
"Qt5MultimediaQuick.dll",
"Qt5MultimediaWidgets.dll",
"Qt5Nfc.dll",
"Qt5OpenGL.dll",
"Qt5Pdf.dll",
"Qt5PdfWidgets.dll",
"Qt5Positioning.dll",
"Qt5PositioningQuick.dll",
"Qt5PrintSupport.dll",
"Qt5Purchasing.dll",
"Qt5Quick.dll",
"Qt5Quick3D.dll",
"Qt5Quick3DAssetImport.dll",
"Qt5Quick3DRender.dll",
"Qt5Quick3DRuntimeRender.dll",
"Qt5Quick3DUtils.dll",
"Qt5QuickControls2.dll",
"Qt5QuickParticles.dll",
"Qt5QuickShapes.dll",
"Qt5QuickTemplates2.dll",
"Qt5QuickTest.dll",
"Qt5QuickWidgets.dll",
"Qt5RemoteObjects.dll",
"Qt5Script.dll",
"Qt5ScriptTools.dll",
"Qt5Scxml.dll",
"Qt5Sensors.dll",
"Qt5SerialBus.dll",
"Qt5SerialPort.dll",
"Qt5Sql.dll",
"Qt5Svg.dll",
"Qt5Test.dll",
"Qt5TextToSpeech.dll",
"Qt5VirtualKeyboard.dll",
"Qt5WebChannel.dll",
"Qt5WebEngine.dll",
"Qt5WebEngineCore.dll",
"Qt5WebEngineWidgets.dll",
"Qt5WebSockets.dll",
"Qt5WebView.dll",
"Qt5Xml.dll",
"Qt5XmlPatterns.dll",
"QtAxContainer.pyd",
"QtAxContainer.pyi",
"QtCharts.pyd",
"QtCharts.pyi",
"QtConcurrent.pyd",
"QtConcurrent.pyi",
"QtDataVisualization.pyd",
"QtDataVisualization.pyi",
"qtdiag.exe",
"QtHelp.pyd",
"QtHelp.pyi",
"QtLocation.pyd",
"QtLocation.pyi",
"QtMultimedia.pyd",
"QtMultimedia.pyi",
"QtMultimediaWidgets.pyd",
"QtMultimediaWidgets.pyi",
"QtNetwork.pyd",
"QtNetwork.pyi",
"QtOpenGL.pyd",
"QtOpenGL.pyi",
"QtOpenGLFunctions.pyd",
"QtOpenGLFunctions.pyi",
"QtPositioning.pyd",
"QtPositioning.pyi",
"QtPrintSupport.pyd",
"QtPrintSupport.pyi",
"QtQml.pyd",
"QtQml.pyi",
"QtQuick.pyd",
"QtQuick.pyi",
"QtQuickControls2.pyd",
"QtQuickControls2.pyi",
"QtQuickWidgets.pyd",
"QtQuickWidgets.pyi",
"QtRemoteObjects.pyd",
"QtRemoteObjects.pyi",
"QtScript.pyd",
"QtScript.pyi",
"QtScriptTools.pyd",
"QtScriptTools.pyi",
"QtScxml.pyd",
"QtScxml.pyi",
"QtSensors.pyd",
"QtSensors.pyi",
"QtSerialPort.pyd",
"QtSerialPort.pyi",
"QtSql.pyd",
"QtSql.pyi",
"QtSvg.pyd",
"QtSvg.pyi",
"QtTest.pyd",
"QtTest.pyi",
"QtTextToSpeech.pyd",
"QtTextToSpeech.pyi",
"QtUiTools.pyd",
"QtUiTools.pyi",
"QtWebChannel.pyd",
"QtWebChannel.pyi",
"QtWebEngine.pyd",
"QtWebEngine.pyi",
"QtWebEngineCore.pyd",
"QtWebEngineCore.pyi",
"QtWebEngineProcess.exe",
"QtWebEngineWidgets.pyd",
"QtWebEngineWidgets.pyi",
"QtWebSockets.pyd",
"QtWebSockets.pyi",
"QtWinExtras.pyd",
"QtWinExtras.pyi",
"QtXml.pyd",
"QtXml.pyi",
"QtXmlPatterns.pyd",
"QtXmlPatterns.pyi",
"rcc.exe",
"uic.exe",
shutil.rmtree(os.path.join(build_path, "lib", "PySide6", dirname))
for dirname in [
"assetimporters",
"designer",
"generic",
"geometryloaders",
"platforminputcontexts",
"position",
"qmltooling",
"renderers",
"renderplugins",
"sceneparsers",
"scxmldatamodel",
"sensors",
"sqldrivers",
"styles",
]:
os.remove(
os.path.join(
build_path,
"lib",
"PySide2",
filename.replace("/", "\\"),
)
)
shutil.rmtree(os.path.join(build_path, "lib", "PySide6", "plugins", dirname))
for filename in (
glob(os.path.join(build_path, "lib", "PySide6", "*.exe"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt3D*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt63D*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Bluetooth.*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Charts*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Concurrent.*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6DataVisualization*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Bus.dll"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Designer*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Help.dll"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Labs*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Multimedia*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Nfc.dll"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6OpenGL*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Qml*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Quick*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6RemoteObjects*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Scxml*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Sensors*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6SerialPort.*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6ShaderTools.*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Sql.*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6StateMachine*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Test.*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6VirtualKeyboard.*"))
+ glob(os.path.join(build_path, "lib", "PySide6", "Qt6Web*"))
):
os.remove(filename)
after_size = get_size(build_path)
freed_bytes = before_size - after_size
@ -573,56 +380,50 @@ def cleanup_build():
@main.command()
@click.argument("win32_path")
@click.argument("win64_path")
def codesign(win32_path, win64_path):
@click.argument("path")
def codesign(path):
"""Sign Windows binaries before packaging"""
paths = [win32_path, win64_path]
if not os.path.isdir(path):
click.echo("Invalid build path")
return
for path in paths:
if not os.path.isdir(path):
click.echo("Invalid build path")
return
for path in paths:
sign(os.path.join(path, "onionshare.exe"))
sign(os.path.join(path, "onionshare-cli.exe"))
sign(
os.path.join(
path,
"lib",
"onionshare",
"resources",
"tor",
"meek-client.exe",
)
sign(os.path.join(path, "onionshare.exe"))
sign(os.path.join(path, "onionshare-cli.exe"))
sign(
os.path.join(
path,
"lib",
"onionshare",
"resources",
"tor",
"meek-client.exe",
)
sign(
os.path.join(
path,
"lib",
"onionshare",
"resources",
"tor",
"obfs4proxy.exe",
)
)
sign(
os.path.join(
path,
"lib",
"onionshare",
"resources",
"tor",
"obfs4proxy.exe",
)
sign(
os.path.join(
path,
"lib",
"onionshare",
"resources",
"tor",
"snowflake-client.exe",
)
)
sign(
os.path.join(
path,
"lib",
"onionshare",
"resources",
"tor",
"snowflake-client.exe",
)
)
@main.command()
@click.argument("win32_path")
@click.argument("win64_path")
def package(win32_path, win64_path):
@click.argument("path")
def package(path):
"""Build the MSI package"""
version_filename = os.path.join(
root, "cli", "onionshare_cli", "resources", "version.txt"
@ -631,12 +432,7 @@ def package(win32_path, win64_path):
version = f.read().strip()
msi_package(
win32_path,
os.path.join(desktop_dir, "dist", f"OnionShare-win32-{version}.msi"),
"12b9695c-965b-4be0-bc33-21274e809576",
)
msi_package(
win64_path,
path,
os.path.join(desktop_dir, "dist", f"OnionShare-win64-{version}.msi"),
"ed7f9243-3528-4b4a-b85c-9943982e75eb",
)

View File

@ -10,9 +10,6 @@ import requests
import click
torbrowser_version = "12.0.2"
expected_win32_sha256 = (
"a94d638a97e168a048ef07bd9323cb043f0e9d22f8e44f1bcba41b32e25afba5"
)
expected_win64_sha256 = (
"7f5b78bf7aafe4c94b321199316682922709544f5b897f13b6bdccb0afe9086d"
)
@ -23,10 +20,6 @@ expected_linux64_sha256 = (
"a97dae40fd635ccfc5126d500459b9437528e4a4b35cc589b08d6cc114279678"
)
win32_filename = f"torbrowser-install-{torbrowser_version}_ALL.exe"
win32_url = (
f"https://dist.torproject.org/torbrowser/{torbrowser_version}/{win32_filename}"
)
win64_filename = f"torbrowser-install-win64-{torbrowser_version}_ALL.exe"
win64_url = (
f"https://dist.torproject.org/torbrowser/{torbrowser_version}/{win64_filename}"
@ -49,12 +42,7 @@ working_path = os.path.join(root_path, "build", "tor")
def get_tor_windows(platform):
if platform == "win32":
win_url = win32_url
win_filename = win32_filename
expected_win_sha256 = expected_win32_sha256
bin_filenames = ["tor.exe"]
elif platform == "win64":
if platform == "win64":
win_url = win64_url
win_filename = win64_filename
expected_win_sha256 = expected_win64_sha256