From 90168c160b6fed3431fe80cea739bd4fc6d75ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Ple=C5=A1a?= Date: Tue, 8 Apr 2025 12:39:13 +0200 Subject: [PATCH 1/2] Build folder versions for release --- .github/workflows/release.yml | 3 +++ mapillary_tools_folder.spec | 38 +++++++++++++++++++++++++++++++++++ script/build_linux_folder | 34 +++++++++++++++++++++++++++++++ script/build_osx_folder | 34 +++++++++++++++++++++++++++++++ script/build_win_folder.ps1 | 35 ++++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 mapillary_tools_folder.spec create mode 100755 script/build_linux_folder create mode 100755 script/build_osx_folder create mode 100644 script/build_win_folder.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 085a413c5..42118a14a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -108,6 +108,7 @@ jobs: if: startsWith(matrix.platform, 'macos') run: | ./script/build_osx + ./script/build_osx_folder # Could run full integration tests with the binary (it might be slow) pytest tests/integration env: @@ -118,6 +119,7 @@ jobs: if: contains(matrix.platform, 'ubuntu') run: | ./script/build_linux + ./script/build_linux_folder # Could run full integration tests with the binary (it might be slow) pytest tests/integration env: @@ -129,6 +131,7 @@ jobs: run: | ./script/build_bootloader.ps1 ./script/build_win.ps1 + ./script/build_win_folder.ps1 # Could run full integration tests with the binary (it might be slow) cp ./dist/win/mapillary_tools.exe mapillary_tools_WINDOWS_VERY_HARD_TO_FIND_YOU_IN_ANOTHER_DIR_SO_I_MOVE_YOU_HERE.exe pytest tests/integration diff --git a/mapillary_tools_folder.spec b/mapillary_tools_folder.spec new file mode 100644 index 000000000..af210cfdc --- /dev/null +++ b/mapillary_tools_folder.spec @@ -0,0 +1,38 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(["./pyinstaller/main.py"], + pathex=[SPECPATH], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + [], + exclude_binaries=True, + name='mapillary_tools', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='mapillary_tools') diff --git a/script/build_linux_folder b/script/build_linux_folder new file mode 100755 index 000000000..3e045efc4 --- /dev/null +++ b/script/build_linux_folder @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +OS=linux + +# build +mkdir -p dist +rm -rf dist/${OS} +pyinstaller --version +pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools_folder.spec + +# check +FOLDER=dist/${OS}/mapillary_tools +SOURCE=dist/${OS}/mapillary_tools/mapillary_tools +$SOURCE --version +VERSION=$($SOURCE --version | awk '{print $3}') +ARCH=$(uname -m) +TARGET=dist/releases/mapillary_tools-folder-${VERSION}-${OS}-${ARCH} + +# package +mkdir -p dist/releases +cd dist/${OS}/ +zip -r ../../"$TARGET" mapillary_tools +cd ../../ + +# sha256 +TARGET_BASENAME=$(basename "$TARGET") +# to produce "HASH mapillary_tools" instead of "HASH dist/releases/mapillary_tools" +cd dist/releases +shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" +cd ../../ + +# summary +ls -l dist/releases diff --git a/script/build_osx_folder b/script/build_osx_folder new file mode 100755 index 000000000..f45e49076 --- /dev/null +++ b/script/build_osx_folder @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +OS=osx + +# build +mkdir -p dist +rm -rf dist/${OS} +pyinstaller --version +pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools_folder.spec + +# check +FOLDER=dist/${OS}/mapillary_tools +SOURCE=dist/${OS}/mapillary_tools/mapillary_tools +$SOURCE --version +VERSION=$($SOURCE --version | awk '{print $3}') +ARCH=$(uname -m) +TARGET=dist/releases/mapillary_tools-folder-${VERSION}-${OS}-${ARCH}.zip + +# package +mkdir -p dist/releases +cd dist/${OS}/ +zip -r ../../"$TARGET" mapillary_tools +cd ../../ + +# sha256 +TARGET_BASENAME=$(basename "$TARGET") +# to produce "HASH mapillary_tools" instead of "HASH dist/releases/mapillary_tools" +cd dist/releases +shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" +cd ../../ + +# summary +ls -l dist/releases diff --git a/script/build_win_folder.ps1 b/script/build_win_folder.ps1 new file mode 100644 index 000000000..eb4f5eaeb --- /dev/null +++ b/script/build_win_folder.ps1 @@ -0,0 +1,35 @@ +$OS="win" +# this is OS arch +# $ARCH=(wmic OS get OSArchitecture)[2] +$MAXSIZE32=python3 -c "import sys; print(sys.maxsize <= 2**32)" +# -ceq case-sensitive equality https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-if +if ($MAXSIZE32 -ceq "True") { + $ARCH="32bit" +} else { + $ARCH="64bit" +} + +# build +mkdir -Force dist +pyinstaller --version +pyinstaller --noconfirm --distpath dist\win mapillary_tools_folder.spec + +# check +$FOLDER="dist\win\mapillary_tools" +$SOURCE="dist\win\mapillary_tools\mapillary_tools.exe" +dist\win\mapillary_tools\mapillary_tools.exe --version +$VERSION_OUTPUT=dist\win\mapillary_tools\mapillary_tools.exe --version +$VERSION=$VERSION_OUTPUT.split(' ')[2] +$TARGET="dist\releases\mapillary_tools-folder-$VERSION-$OS-$ARCH.zip" + +# package +mkdir -Force dist\releases +cd dist\win +Compress-Archive -Path mapillary_tools -DestinationPath ..\..\"$TARGET" +cd ..\..\ + +# sha256 +Get-FileHash $TARGET -Algorithm SHA256 | Select-Object Hash > "$TARGET.sha256.txt" + +# summary +Get-ChildItem dist\releases From f511e7b5db056a4823634718060421268879a6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Ple=C5=A1a?= Date: Tue, 8 Apr 2025 17:24:26 +0200 Subject: [PATCH 2/2] Combine build scripts per platform --- .github/workflows/release.yml | 3 --- mapillary_tools_folder.spec | 2 +- script/build_linux | 22 ++++++++++++++++++++++ script/build_linux_folder | 34 ---------------------------------- script/build_osx | 22 ++++++++++++++++++++++ script/build_osx_folder | 34 ---------------------------------- script/build_win.ps1 | 18 ++++++++++++++++++ script/build_win_folder.ps1 | 35 ----------------------------------- 8 files changed, 63 insertions(+), 107 deletions(-) delete mode 100755 script/build_linux_folder delete mode 100755 script/build_osx_folder delete mode 100644 script/build_win_folder.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42118a14a..085a413c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -108,7 +108,6 @@ jobs: if: startsWith(matrix.platform, 'macos') run: | ./script/build_osx - ./script/build_osx_folder # Could run full integration tests with the binary (it might be slow) pytest tests/integration env: @@ -119,7 +118,6 @@ jobs: if: contains(matrix.platform, 'ubuntu') run: | ./script/build_linux - ./script/build_linux_folder # Could run full integration tests with the binary (it might be slow) pytest tests/integration env: @@ -131,7 +129,6 @@ jobs: run: | ./script/build_bootloader.ps1 ./script/build_win.ps1 - ./script/build_win_folder.ps1 # Could run full integration tests with the binary (it might be slow) cp ./dist/win/mapillary_tools.exe mapillary_tools_WINDOWS_VERY_HARD_TO_FIND_YOU_IN_ANOTHER_DIR_SO_I_MOVE_YOU_HERE.exe pytest tests/integration diff --git a/mapillary_tools_folder.spec b/mapillary_tools_folder.spec index af210cfdc..3c7e48beb 100644 --- a/mapillary_tools_folder.spec +++ b/mapillary_tools_folder.spec @@ -35,4 +35,4 @@ coll = COLLECT(exe, strip=False, upx=True, upx_exclude=[], - name='mapillary_tools') + name='mapillary_tools_folder') diff --git a/script/build_linux b/script/build_linux index 50c117994..ac1d75dc4 100755 --- a/script/build_linux +++ b/script/build_linux @@ -8,6 +8,7 @@ mkdir -p dist rm -rf dist/${OS} pyinstaller --version pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools.spec +pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools_folder.spec # check SOURCE=dist/${OS}/mapillary_tools @@ -28,5 +29,26 @@ cd dist/releases shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" cd ../../ +# check +FOLDER=dist/${OS}/mapillary_tools_folder +SOURCE=dist/${OS}/mapillary_tools_folder/mapillary_tools +$SOURCE --version +VERSION=$($SOURCE --version | awk '{print $3}') +ARCH=$(uname -m) +TARGET=dist/releases/mapillary_tools-folder-${VERSION}-${OS}-${ARCH} + +# package +mkdir -p dist/releases +cd dist/${OS}/ +zip -r ../../"$TARGET" mapillary_tools_folder +cd ../../ + +# sha256 +TARGET_BASENAME=$(basename "$TARGET") +# to produce "HASH mapillary_tools" instead of "HASH dist/releases/mapillary_tools" +cd dist/releases +shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" +cd ../../ + # summary ls -l dist/releases diff --git a/script/build_linux_folder b/script/build_linux_folder deleted file mode 100755 index 3e045efc4..000000000 --- a/script/build_linux_folder +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -e - -OS=linux - -# build -mkdir -p dist -rm -rf dist/${OS} -pyinstaller --version -pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools_folder.spec - -# check -FOLDER=dist/${OS}/mapillary_tools -SOURCE=dist/${OS}/mapillary_tools/mapillary_tools -$SOURCE --version -VERSION=$($SOURCE --version | awk '{print $3}') -ARCH=$(uname -m) -TARGET=dist/releases/mapillary_tools-folder-${VERSION}-${OS}-${ARCH} - -# package -mkdir -p dist/releases -cd dist/${OS}/ -zip -r ../../"$TARGET" mapillary_tools -cd ../../ - -# sha256 -TARGET_BASENAME=$(basename "$TARGET") -# to produce "HASH mapillary_tools" instead of "HASH dist/releases/mapillary_tools" -cd dist/releases -shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" -cd ../../ - -# summary -ls -l dist/releases diff --git a/script/build_osx b/script/build_osx index 81c670a79..258b23181 100755 --- a/script/build_osx +++ b/script/build_osx @@ -8,6 +8,7 @@ mkdir -p dist rm -rf dist/${OS} pyinstaller --version pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools.spec +pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools_folder.spec # check SOURCE=dist/${OS}/mapillary_tools.app/Contents/MacOS/mapillary_tools @@ -28,5 +29,26 @@ cd dist/releases shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" cd ../../ +# check +FOLDER=dist/${OS}/mapillary_tools_folder +SOURCE=dist/${OS}/mapillary_tools_folder/mapillary_tools +$SOURCE --version +VERSION=$($SOURCE --version | awk '{print $3}') +ARCH=$(uname -m) +TARGET=dist/releases/mapillary_tools-folder-${VERSION}-${OS}-${ARCH}.zip + +# package +mkdir -p dist/releases +cd dist/${OS}/ +zip -r ../../"$TARGET" mapillary_tools_folder +cd ../../ + +# sha256 +TARGET_BASENAME=$(basename "$TARGET") +# to produce "HASH mapillary_tools" instead of "HASH dist/releases/mapillary_tools" +cd dist/releases +shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" +cd ../../ + # summary ls -l dist/releases diff --git a/script/build_osx_folder b/script/build_osx_folder deleted file mode 100755 index f45e49076..000000000 --- a/script/build_osx_folder +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -e - -OS=osx - -# build -mkdir -p dist -rm -rf dist/${OS} -pyinstaller --version -pyinstaller --noconfirm --distpath dist/${OS} mapillary_tools_folder.spec - -# check -FOLDER=dist/${OS}/mapillary_tools -SOURCE=dist/${OS}/mapillary_tools/mapillary_tools -$SOURCE --version -VERSION=$($SOURCE --version | awk '{print $3}') -ARCH=$(uname -m) -TARGET=dist/releases/mapillary_tools-folder-${VERSION}-${OS}-${ARCH}.zip - -# package -mkdir -p dist/releases -cd dist/${OS}/ -zip -r ../../"$TARGET" mapillary_tools -cd ../../ - -# sha256 -TARGET_BASENAME=$(basename "$TARGET") -# to produce "HASH mapillary_tools" instead of "HASH dist/releases/mapillary_tools" -cd dist/releases -shasum -a256 "$TARGET_BASENAME" | tee "${TARGET_BASENAME}.sha256.txt" -cd ../../ - -# summary -ls -l dist/releases diff --git a/script/build_win.ps1 b/script/build_win.ps1 index 1194d17e5..3eb1cdf13 100644 --- a/script/build_win.ps1 +++ b/script/build_win.ps1 @@ -13,6 +13,7 @@ if ($MAXSIZE32 -ceq "True") { mkdir -Force dist pyinstaller --version pyinstaller --noconfirm --distpath dist\win mapillary_tools.spec +pyinstaller --noconfirm --distpath dist\win mapillary_tools_folder.spec # check $SOURCE="dist\win\mapillary_tools.exe" @@ -29,5 +30,22 @@ Copy-Item "$SOURCE" "$TARGET" # sha256 Get-FileHash $TARGET -Algorithm SHA256 | Select-Object Hash > "$TARGET.sha256.txt" +# check +$FOLDER="dist\win\mapillary_tools_folder" +$SOURCE="dist\win\mapillary_tools_folder\mapillary_tools.exe" +dist\win\mapillary_tools_folder\mapillary_tools.exe --version +$VERSION_OUTPUT=dist\win\mapillary_tools_folder\mapillary_tools.exe --version +$VERSION=$VERSION_OUTPUT.split(' ')[2] +$TARGET="dist\releases\mapillary_tools-folder-$VERSION-$OS-$ARCH.zip" + +# package +mkdir -Force dist\releases +cd dist\win +Compress-Archive -Path mapillary_tools_folder -DestinationPath ..\..\"$TARGET" +cd ..\..\ + +# sha256 +Get-FileHash $TARGET -Algorithm SHA256 | Select-Object Hash > "$TARGET.sha256.txt" + # summary Get-ChildItem dist\releases diff --git a/script/build_win_folder.ps1 b/script/build_win_folder.ps1 deleted file mode 100644 index eb4f5eaeb..000000000 --- a/script/build_win_folder.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -$OS="win" -# this is OS arch -# $ARCH=(wmic OS get OSArchitecture)[2] -$MAXSIZE32=python3 -c "import sys; print(sys.maxsize <= 2**32)" -# -ceq case-sensitive equality https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-if -if ($MAXSIZE32 -ceq "True") { - $ARCH="32bit" -} else { - $ARCH="64bit" -} - -# build -mkdir -Force dist -pyinstaller --version -pyinstaller --noconfirm --distpath dist\win mapillary_tools_folder.spec - -# check -$FOLDER="dist\win\mapillary_tools" -$SOURCE="dist\win\mapillary_tools\mapillary_tools.exe" -dist\win\mapillary_tools\mapillary_tools.exe --version -$VERSION_OUTPUT=dist\win\mapillary_tools\mapillary_tools.exe --version -$VERSION=$VERSION_OUTPUT.split(' ')[2] -$TARGET="dist\releases\mapillary_tools-folder-$VERSION-$OS-$ARCH.zip" - -# package -mkdir -Force dist\releases -cd dist\win -Compress-Archive -Path mapillary_tools -DestinationPath ..\..\"$TARGET" -cd ..\..\ - -# sha256 -Get-FileHash $TARGET -Algorithm SHA256 | Select-Object Hash > "$TARGET.sha256.txt" - -# summary -Get-ChildItem dist\releases