Make build-windows.py not use special characters, and make it detect 32-bit or 64-bit python

This commit is contained in:
Micah Lee 2022-03-30 08:55:04 -07:00
parent c5e73076a4
commit 8d14f53a67
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 42 additions and 32 deletions

View File

@ -81,7 +81,6 @@ jobs:
choco install 7zip choco install 7zip
choco install go choco install go
choco install dotnet3.5 choco install dotnet3.5
choco install wixtoolset
- run: - run:
name: Install poetry name: Install poetry
command: (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python - command: (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
@ -90,8 +89,23 @@ jobs:
command: | command: |
cd ~\project\desktop cd ~\project\desktop
poetry install poetry install
- run:
name: Get tor
command: |
cd ~\project\desktop
poetry run python .\scripts\get-tor-windows.py
- run:
name: Build meek
command: |
cd ~\project\desktop
python .\scripts\build-meek-client.py
- run: - run:
name: Build name: Build
command: | command: |
cd ~\project\desktop cd ~\project\desktop
poetry run python .\package\build-windows.py --ci-build poetry run python .\package\build-windows.py --ci-build
- run:
name: Compress
command: Compress-Archive -LiteralPath ~\project\desktop\build\exe.win-amd64-3.9 -DestinationPath ~\win64-build.zip
- store_artifacts:
path: ~\win64-build.zip

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import sys
import inspect import inspect
import subprocess import subprocess
import shutil import shutil
@ -74,7 +75,7 @@ def wix_build_data(dirname, dir_prefix, id_, name):
id_prefix = id_ id_prefix = id_
# Skip lib/Pyside2/Examples folder # Skip lib/Pyside2/Examples folder
if "\\build\\exe.win32-3.9\\lib\\PySide2\\examples" in dirname: if "\\lib\\PySide2\\examples" in dirname:
continue continue
id_value = f"{id_prefix}{basename.capitalize().replace('-', '_')}" id_value = f"{id_prefix}{basename.capitalize().replace('-', '_')}"
@ -175,13 +176,13 @@ def main():
desktop_dir = os.path.join(root, "desktop") desktop_dir = os.path.join(root, "desktop")
print(" Clean up from last build") print("> Clean up from last build")
if os.path.exists(os.path.join(desktop_dir, "build")): if os.path.exists(os.path.join(desktop_dir, "build")):
shutil.rmtree(os.path.join(desktop_dir, "build")) shutil.rmtree(os.path.join(desktop_dir, "build"))
if os.path.exists(os.path.join(desktop_dir, "dist")): if os.path.exists(os.path.join(desktop_dir, "dist")):
shutil.rmtree(os.path.join(desktop_dir, "dist")) shutil.rmtree(os.path.join(desktop_dir, "dist"))
print(" Building binaries") print("> Building binaries")
run( run(
[ [
shutil.which("python"), shutil.which("python"),
@ -190,15 +191,18 @@ def main():
], ],
desktop_dir, desktop_dir,
) )
before_size = get_size(os.path.join(desktop_dir, "build", "exe.win32-3.9"))
print("○ Delete unused PySide2 stuff to save space") if "64 bit" in sys.version:
python_arch = "win-amd64"
else:
python_arch = "win32"
build_path = os.path.join(desktop_dir, "build", f"exe.{python_arch}-3.9")
before_size = get_size(build_path)
print("> Delete unused PySide2 stuff to save space")
for dirname in ["examples", "qml"]: for dirname in ["examples", "qml"]:
shutil.rmtree( shutil.rmtree(os.path.join(build_path, "lib", "PySide2", dirname))
os.path.join(
desktop_dir, "build", "exe.win32-3.9", "lib", "PySide2", dirname
)
)
for filename in [ for filename in [
"lconvert.exe", "lconvert.exe",
"linguist.exe", "linguist.exe",
@ -425,43 +429,36 @@ def main():
]: ]:
os.remove( os.remove(
os.path.join( os.path.join(
desktop_dir, build_path,
"build",
"exe.win32-3.9",
"lib", "lib",
"PySide2", "PySide2",
filename.replace("/", "\\"), filename.replace("/", "\\"),
) )
) )
after_size = get_size(os.path.join(desktop_dir, "build", "exe.win32-3.9")) after_size = get_size(build_path)
freed_bytes = before_size - after_size freed_bytes = before_size - after_size
freed_mb = int(freed_bytes / 1024 / 1024) freed_mb = int(freed_bytes / 1024 / 1024)
print(f" Freed {freed_mb} mb") print(f"> Freed {freed_mb} mb")
if ci_build: if ci_build:
print("Doing a CI build, skipping code signing and msi packaging") print("Doing a CI build, skipping code signing and msi packaging")
else: else:
print(f" Signing onionshare.exe") print(f"> Signing onionshare.exe")
sign(os.path.join("build", "exe.win32-3.9", "onionshare.exe"), desktop_dir) sign(os.path.join(build_path, "onionshare.exe"), desktop_dir)
print(f" Signing onionshare-cli.exe") print(f"> Signing onionshare-cli.exe")
sign(os.path.join("build", "exe.win32-3.9", "onionshare-cli.exe"), desktop_dir) sign(os.path.join(build_path, "onionshare-cli.exe"), desktop_dir)
print(f" Build the WiX file") print(f"> Build the WiX file")
version_filename = os.path.join( version_filename = os.path.join(
root, "cli", "onionshare_cli", "resources", "version.txt" root, "cli", "onionshare_cli", "resources", "version.txt"
) )
with open(version_filename) as f: with open(version_filename) as f:
version = f.read().strip() version = f.read().strip()
dist_dir = os.path.join( dist_dir = os.path.join(root, build_path)
root,
"desktop",
"build",
"exe.win32-3.9",
)
data = { data = {
"id": "TARGETDIR", "id": "TARGETDIR",
@ -480,8 +477,7 @@ def main():
data["dirs"][0]["dirs"].append( data["dirs"][0]["dirs"].append(
wix_build_data( wix_build_data(
dist_dir, build_path,
"exe.win32-3.9",
"INSTALLDIR", "INSTALLDIR",
"OnionShare", "OnionShare",
) )
@ -574,7 +570,7 @@ def main():
ET.indent(root_el) ET.indent(root_el)
f.write(ET.tostring(root_el).decode()) f.write(ET.tostring(root_el).decode())
print(f" Build the MSI") print(f"> Build the MSI")
run( run(
[shutil.which("candle.exe"), "OnionShare.wxs"], [shutil.which("candle.exe"), "OnionShare.wxs"],
os.path.join(desktop_dir, "build"), os.path.join(desktop_dir, "build"),
@ -584,7 +580,7 @@ def main():
os.path.join(desktop_dir, "build"), os.path.join(desktop_dir, "build"),
) )
print(f" Prepare OnionShare.msi for signing") print(f"> Prepare OnionShare.msi for signing")
run( run(
[ [
shutil.which("insignia.exe"), shutil.which("insignia.exe"),
@ -598,7 +594,7 @@ def main():
final_msi_filename = os.path.join( final_msi_filename = os.path.join(
desktop_dir, "dist", f"OnionShare-{version}.msi" desktop_dir, "dist", f"OnionShare-{version}.msi"
) )
print(f" Final MSI: {final_msi_filename}") print(f"> Final MSI: {final_msi_filename}")
os.makedirs(os.path.join(desktop_dir, "dist"), exist_ok=True) os.makedirs(os.path.join(desktop_dir, "dist"), exist_ok=True)
os.rename( os.rename(
os.path.join(desktop_dir, "build", "OnionShare.msi"), os.path.join(desktop_dir, "build", "OnionShare.msi"),