From 24c48c4d9d44fc3b68026906fbfa3fb83ba410d5 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Wed, 8 Nov 2023 13:26:33 +0100 Subject: [PATCH 1/4] Improve executable output name --- .gitignore | 1 + builder/pyinstaller_build_macos.py | 32 +++++++++++++++---------- builder/pyinstaller_build_ubuntu.py | 33 +++++++++++++++---------- builder/pyinstaller_build_windows.py | 36 ++++++++++++++++------------ 4 files changed, 62 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index 1b119c3d..a9ed43b7 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,4 @@ docs/misc/licenses.md docs/misc/dependencies.md QGISDeploymentToolbelt_*Ubuntu* tests/fixtures/tmp/* +build_environment_report.txt diff --git a/builder/pyinstaller_build_macos.py b/builder/pyinstaller_build_macos.py index 94bdbe3f..92070264 100644 --- a/builder/pyinstaller_build_macos.py +++ b/builder/pyinstaller_build_macos.py @@ -11,6 +11,7 @@ # Standard library import platform import sys +from datetime import datetime from os import getenv from pathlib import Path @@ -24,8 +25,23 @@ # ############################################################################# # ########### MAIN ################# # ################################## +# write build report +build_report = ( + f"datetime: {datetime.now().astimezone().isoformat()}" + f"\nprog_name: {__about__.__title__}" + f"\nprog_version: {__about__.__version__}" + f"\noperating_system: {platform.system()}" + f"\noperating_system_version: {platform.release()}_{platform.version()}" + f"\narchitecture: {platform.architecture()[0]}" + f"\npython_version: {platform.python_version()}" +) +Path("build_environment_report.txt").write_text(data=build_report, encoding="UTF-8") + +# variables +output_filename = f"{__about__.__title_clean__}_{__about__.__version__}" package_folder = Path("qgis_deployment_toolbelt") + mac_os_version, _, _ = platform.mac_ver() mac_os_version = "-".join(mac_os_version.split(".")[:2]) @@ -33,19 +49,11 @@ [ "--add-data=LICENSE:.", "--add-data=README.md:.", - "--add-data={}:profiles/".format( - (package_folder / "profiles/shortcut_freedesktop.template/").resolve() - ), - "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), - "--name={}_{}_MacOS{}_Python{}-{}".format( - __about__.__title_clean__, - __about__.__version__.replace(".", "-"), - mac_os_version, - platform.python_version_tuple()[0], - platform.python_version_tuple()[1], - ), + f"--add-data={package_folder.joinpath('profiles/shortcut_freedesktop.template/').resolve()}:profiles/", + f"--log-level={getenv('PYINSTALLER_LOG_LEVEL', 'WARN')}", + f"--name={output_filename}", "--noconfirm", - "--noupx", + # "--noupx", "--onefile", "--console", str(package_folder / "cli.py"), diff --git a/builder/pyinstaller_build_ubuntu.py b/builder/pyinstaller_build_ubuntu.py index dcd3af2a..dcbbe44a 100644 --- a/builder/pyinstaller_build_ubuntu.py +++ b/builder/pyinstaller_build_ubuntu.py @@ -11,6 +11,7 @@ # Standard library import platform import sys +from datetime import datetime from os import getenv from pathlib import Path @@ -25,26 +26,32 @@ # ############################################################################# # ########### MAIN ################# # ################################## + +# write build report +build_report = ( + f"datetime: {datetime.now().astimezone().isoformat()}" + f"\nprog_name: {__about__.__title__}" + f"\nprog_version: {__about__.__version__}" + f"\ndistribution: {distro.name()}" + f"\ndistribution_version: {distro.version()}" + f"\narchitecture: {platform.architecture()[0]}" + f"\npython_version: {platform.python_version()}" +) +Path("build_environment_report.txt").write_text(data=build_report, encoding="UTF-8") + + +# variables +output_filename = f"{__about__.__title_clean__}_{__about__.__version__}" package_folder = Path("qgis_deployment_toolbelt") PyInstaller.__main__.run( [ "--add-data=LICENSE:.", "--add-data=README.md:.", - "--add-data={}:profiles/".format( - (package_folder / "profiles/shortcut_freedesktop.template/").resolve() - ), - "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), - "--name={}_{}_{}{}_{}_Python{}".format( - __about__.__title_clean__, - __about__.__version__, - distro.name(), - distro.version(), - platform.architecture()[0], - platform.python_version(), - ).replace(".", "-"), + f"--add-data={package_folder.joinpath('profiles/shortcut_freedesktop.template/').resolve()}:profiles/", + f"--log-level={getenv('PYINSTALLER_LOG_LEVEL', 'WARN')}", + f"--name={output_filename}", "--noconfirm", - "--noupx", "--onefile", "--console", str(package_folder / "cli.py"), diff --git a/builder/pyinstaller_build_windows.py b/builder/pyinstaller_build_windows.py index 7255b0b2..29aca28f 100644 --- a/builder/pyinstaller_build_windows.py +++ b/builder/pyinstaller_build_windows.py @@ -11,6 +11,7 @@ # Standard library import platform import sys +from datetime import datetime from os import getenv from pathlib import Path @@ -24,31 +25,36 @@ # ############################################################################# # ########### MAIN ################# # ################################## + +# write build report +build_report = ( + f"datetime: {datetime.now().astimezone().isoformat()}" + f"\nprog_name: {__about__.__title__}" + f"\nprog_version: {__about__.__version__}" + f"\noperating_system: {platform.system()}" + f"\noperating_system_version: {platform.release()}_{platform.version()}" + f"\narchitecture: {platform.architecture()[0]}" + f"\npython_version: {platform.python_version()}" +) +Path("build_environment_report.txt").write_text(data=build_report, encoding="UTF-8") + +# variables +output_filename = f"{__about__.__title_clean__}_{__about__.__version__}" package_folder = Path("qgis_deployment_toolbelt") PyInstaller.__main__.run( [ "--add-data=LICENSE:.", "--add-data=README.md:.", - "--add-data={}:profiles/".format( - (package_folder / "profiles/shortcut_freedesktop.template/").resolve() - ), # "--clean", f"--icon={package_folder.parent.resolve()}/docs/static/logo_qdt.ico", - "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), - "--manifest={}".format((package_folder / "../builder/manifest.xml").resolve()), - "--name={}_{}_{}{}_Python{}-{}".format( - __about__.__title_clean__, - __about__.__version__.replace(".", "-"), - platform.system(), - platform.architecture()[0], - platform.python_version_tuple()[0], - platform.python_version_tuple()[1], - ), + f"--log-level={getenv('PYINSTALLER_LOG_LEVEL', 'WARN')}", + f"--manifest={Path(__file__).parent.joinpath('manifest.xml')}", + f"--name={output_filename}", "--noconfirm", - "--noupx", + # "--noupx", "--onefile", - "--version-file={}".format("version_info.txt"), + "--version-file=version_info.txt", "--console", str(package_folder / "cli.py"), ] From 57abfc4ceba3470f2e84e443793ffacbf218d0cb Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Wed, 8 Nov 2023 13:27:23 +0100 Subject: [PATCH 2/4] Adapt with new package name --- docs/development/packaging.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/development/packaging.md b/docs/development/packaging.md index f5f96f9e..5a293ce6 100644 --- a/docs/development/packaging.md +++ b/docs/development/packaging.md @@ -4,11 +4,11 @@ The project takes advantage of [PyInstaller](https://pyinstaller.readthedocs.io/) to package the application into an executable. -The output binary and all embedded dependencies is located into a subfolder named: `dist/qgis_deployment_toolbelt_{version}_{operating-system}_Python{python-version}`. +The output binary and all embedded dependencies is located into a subfolder named: `dist/QGISDeploymentToolbelt_{version}`. A file named `build_environment_report.txt` containing build environment information is generated at the project's root. ### Windows -> Comply with [Windows development requirements](windows) before to run. +> Comply with [Windows development requirements](../development/windows.md) before to run. ```powershell # Generates MS Version Info @@ -18,24 +18,25 @@ python .\builder\version_info_templater.py python -O .\builder\pyinstaller_build_windows.py ``` -![QGIS Deployment Toolbelt - Executable properties](/static/executable_windows_properties_details.png) +![QGIS Deployment Toolbelt - Executable properties](../static/executable_windows_properties_details.png) To run it, double-click on the executable file (*.exe). ### Ubuntu -> Comply with [Ubuntu development requirements](ubuntu) before to run. +> Comply with [Ubuntu development requirements](../development/ubuntu.md) before to run. -```bash +```sh # Generates binary executable python -O ./builder/pyinstaller_build_ubuntu.py +# make it runnable +chmod +x dist/QGISDeploymentToolbelt_* ``` To run it, for example: -```bash -cd dist/qgis_deployment_toolbelt_3-0-0_Ubuntu20-04_64bit_Python3-8-5/ -./qgis_deployment_toolbelt_3-0-0_Ubuntu20-04_64bit_Python3-8-5 +```sh +./dist/QGISDeploymentToolbelt_0-26-0 ``` ---- From 1d2adf16c97d2520637c34e831e4729ee150ad42 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Wed, 8 Nov 2023 13:30:25 +0100 Subject: [PATCH 3/4] Replace dots by hyphens --- builder/pyinstaller_build_macos.py | 4 +++- builder/pyinstaller_build_ubuntu.py | 4 +++- builder/pyinstaller_build_windows.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/builder/pyinstaller_build_macos.py b/builder/pyinstaller_build_macos.py index 92070264..903f674d 100644 --- a/builder/pyinstaller_build_macos.py +++ b/builder/pyinstaller_build_macos.py @@ -38,7 +38,9 @@ Path("build_environment_report.txt").write_text(data=build_report, encoding="UTF-8") # variables -output_filename = f"{__about__.__title_clean__}_{__about__.__version__}" +output_filename = ( + f"{__about__.__title_clean__}_{__about__.__version__.replace('.', '-')}" +) package_folder = Path("qgis_deployment_toolbelt") diff --git a/builder/pyinstaller_build_ubuntu.py b/builder/pyinstaller_build_ubuntu.py index dcbbe44a..eace7fec 100644 --- a/builder/pyinstaller_build_ubuntu.py +++ b/builder/pyinstaller_build_ubuntu.py @@ -41,7 +41,9 @@ # variables -output_filename = f"{__about__.__title_clean__}_{__about__.__version__}" +output_filename = ( + f"{__about__.__title_clean__}_{__about__.__version__.replace('.', '-')}" +) package_folder = Path("qgis_deployment_toolbelt") PyInstaller.__main__.run( diff --git a/builder/pyinstaller_build_windows.py b/builder/pyinstaller_build_windows.py index 29aca28f..3482832d 100644 --- a/builder/pyinstaller_build_windows.py +++ b/builder/pyinstaller_build_windows.py @@ -39,7 +39,9 @@ Path("build_environment_report.txt").write_text(data=build_report, encoding="UTF-8") # variables -output_filename = f"{__about__.__title_clean__}_{__about__.__version__}" +output_filename = ( + f"{__about__.__title_clean__}_{__about__.__version__.replace('.', '-')}" +) package_folder = Path("qgis_deployment_toolbelt") PyInstaller.__main__.run( From 56087a725088d82201d2cea4877211bd94723bc1 Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Wed, 8 Nov 2023 13:39:16 +0100 Subject: [PATCH 4/4] Upload build environment report --- .github/workflows/build_release.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 8b43dc52..b83dc7d9 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -98,7 +98,9 @@ jobs: - uses: actions/upload-artifact@v3 with: name: macos_executable - path: dist/* + path: | + dist/* + build_environment_report.txt if-no-files-found: error build-ubuntu: @@ -131,7 +133,9 @@ jobs: - uses: actions/upload-artifact@v3 with: name: ubuntu_executable - path: dist/* + path: | + dist/* + build_environment_report.txt if-no-files-found: error build-windows: @@ -168,7 +172,9 @@ jobs: uses: actions/upload-artifact@v3 with: name: windows_executable - path: dist/* + path: | + dist/* + build_environment_report.txt if-no-files-found: error release: