diff --git a/.github/workflows/builder_releaser.yml b/.github/workflows/builder_releaser.yml index 1654b537..68653081 100644 --- a/.github/workflows/builder_releaser.yml +++ b/.github/workflows/builder_releaser.yml @@ -69,20 +69,27 @@ jobs: python -m pip install -e .[gdal] python -m pip install -U -r requirements/packaging.txt - - name: Generates Executable - run: python -O ./builder/pyinstaller_build_ubuntu.py + - name: Generates executable for command-line version + run: | + python -O ./builder/pyinstaller_build_ubuntu_cli.py + + - name: Save CLI binary as artifact + uses: actions/upload-artifact@v4 + with: + name: DicoGIS_executable_ubuntu_CLI + path: dist/DicoGIS-cli_* + if-no-files-found: error - - name: Compress into ZIP + - name: Generates executable for graphical version run: | - cd dist/ - zip -r9 DicoGIS_Ubuntu . DicoGIS_*/* + python -O ./builder/pyinstaller_build_ubuntu_gui.py - name: Save it as artifact uses: actions/upload-artifact@v4 with: - name: DicoGIS_executable_Ubuntu + name: DicoGIS_executable_ubuntu_GUI path: | - dist/DicoGIS_*.zip + dist/DicoGIS-gui_* if-no-files-found: error build-windows: @@ -116,20 +123,27 @@ jobs: - name: Generates MS Version Info run: python .\builder\version_info_templater.py - - name: Generates MS Executable - run: python -O .\builder\pyinstaller_build_windows.py + - name: Generates executable for command-line version + run: | + python -O ./builder/pyinstaller_build_windows_cli.py + + - name: Save CLI binary as artifact + uses: actions/upload-artifact@v4 + with: + name: DicoGIS_executable_windows_CLI + path: dist/DicoGIS-cli_* + if-no-files-found: error - - name: Compress into ZIP + - name: Generates executable for graphical version run: | - cd dist/ - 7z a DicoGIS_Windows.zip ./DicoGIS_*/* + python -O ./builder/pyinstaller_build_windows_gui.py - name: Save it as artifact uses: actions/upload-artifact@v4 with: - name: DicoGIS_executable_Windows + name: DicoGIS_executable_windows_GUI path: | - dist/DicoGIS_*.zip + dist/DicoGIS-gui_* if-no-files-found: error release: @@ -145,17 +159,29 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - - name: Download built package for Linux (Ubuntu) + - name: Download built package for Linux (Ubuntu) - GUI + uses: actions/download-artifact@v4 + with: + name: DicoGIS_executable_ubuntu_GUI + path: builds/ubuntu/gui/ + + - name: Download built package for Linux (Ubuntu) - CLI + uses: actions/download-artifact@v4 + with: + name: DicoGIS_executable_ubuntu_CLI + path: builds/ubuntu/cli/ + + - name: Download built package for Windows - GUI uses: actions/download-artifact@v4 with: - name: DicoGIS_executable_Ubuntu - path: builds/ubuntu/ + name: DicoGIS_executable_windows_GUI + path: builds/windows/gui - - name: Download built package for Windows + - name: Download built package for Windows - CLI uses: actions/download-artifact@v4 with: - name: DicoGIS_executable_Windows - path: builds/windows/ + name: DicoGIS_executable_windows_CLI + path: builds/windows/cli - name: Release uses: softprops/action-gh-release@v1 diff --git a/builder/pyinstaller_build_ubuntu_cli.py b/builder/pyinstaller_build_ubuntu_cli.py new file mode 100644 index 00000000..1c69541e --- /dev/null +++ b/builder/pyinstaller_build_ubuntu_cli.py @@ -0,0 +1,53 @@ +#! python3 # noqa: E265 + +""" + Launch PyInstaller using a Python script. +""" + +# ############################################################################# +# ########## Libraries ############# +# ################################## + +import platform +import sys + +# Standard library +from os import getenv +from pathlib import Path + +# 3rd party +import distro +import PyInstaller.__main__ + +# package +sys.path.insert(0, str(Path(".").resolve())) +from dicogis import __about__ # noqa: E402 + +# ############################################################################# +# ########### MAIN ################# +# ################################## +package_folder = Path("dicogis") + +PyInstaller.__main__.run( + [ + "--add-binary={}:bin/img/".format((package_folder / "bin/img/").resolve()), + "--add-data={}:locale/".format((package_folder / "locale/").resolve()), + "--add-data=options_TPL.ini:.", + "--add-data=LICENSE:.", + "--add-data=README.md:.", + "--collect-submodules=shellingham", + "--console", + "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), + "--name={}-cli_{}_{}{}_{}_Python{}".format( + __about__.__title_clean__, + __about__.__version__, + distro.id(), + distro.version(), + platform.architecture()[0], + platform.python_version(), + ).replace(".", "-"), + "--noconfirm", + "--onefile", + str(package_folder.joinpath("cli/main.py")), + ] +) diff --git a/builder/pyinstaller_build_ubuntu.py b/builder/pyinstaller_build_ubuntu_gui.py similarity index 96% rename from builder/pyinstaller_build_ubuntu.py rename to builder/pyinstaller_build_ubuntu_gui.py index 809d8866..7e5c1ba4 100644 --- a/builder/pyinstaller_build_ubuntu.py +++ b/builder/pyinstaller_build_ubuntu_gui.py @@ -36,7 +36,7 @@ "--add-data=LICENSE:.", "--add-data=README.md:.", "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), - "--name={}_{}_{}{}_{}_Python{}".format( + "--name={}-gui_{}_{}{}_{}_Python{}".format( __about__.__title_clean__, __about__.__version__, distro.id(), diff --git a/builder/pyinstaller_build_windows_cli.py b/builder/pyinstaller_build_windows_cli.py new file mode 100644 index 00000000..bdabd843 --- /dev/null +++ b/builder/pyinstaller_build_windows_cli.py @@ -0,0 +1,56 @@ +#! python3 # noqa: E265 + +""" + Launch PyInstaller using a Python script. +""" + +# ############################################################################# +# ########## Libraries ############# +# ################################## + +import platform +import sys + +# Standard library +from os import getenv +from pathlib import Path + +# 3rd party +import PyInstaller.__main__ + +# package +sys.path.insert(0, str(Path(".").resolve())) +from dicogis import __about__ # noqa: E402 + +# ############################################################################# +# ########### MAIN ################# +# ################################## +package_folder = Path("dicogis") + +PyInstaller.__main__.run( + [ + "--add-binary={};bin/img/".format((package_folder / "bin/img/").resolve()), + "--add-data={};locale/".format((package_folder / "locale/").resolve()), + "--add-data=options_TPL.ini;.", + "--add-data=LICENSE;.", + "--add-data=README.md;.", + "--collect-submodules=shellingham", + "--console", + "--icon={}".format((package_folder / "bin/img/DicoGIS.ico").resolve()), + "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), + "--manifest={}".format((package_folder / "../builder/manifest.xml").resolve()), + "--name={}-cli_{}_{}{}_Python{}-{}".format( + __about__.__title_clean__, + __about__.__version__.replace(".", "-"), + platform.system(), + platform.architecture()[0], + platform.python_version_tuple()[0], + platform.python_version_tuple()[1], + ), + "--noconfirm", + "--noupx", + "--onefile", + "--version-file={}".format("version_info.txt"), + str(package_folder.joinpath("cli/main.py")), + ] +) diff --git a/builder/pyinstaller_build_windows.py b/builder/pyinstaller_build_windows_gui.py similarity index 93% rename from builder/pyinstaller_build_windows.py rename to builder/pyinstaller_build_windows_gui.py index 08928ea7..501af4e2 100644 --- a/builder/pyinstaller_build_windows.py +++ b/builder/pyinstaller_build_windows_gui.py @@ -34,12 +34,10 @@ "--add-data=options_TPL.ini;.", "--add-data=LICENSE;.", "--add-data=README.md;.", - "--clean", - # "--debug=all", "--icon={}".format((package_folder / "bin/img/DicoGIS.ico").resolve()), "--log-level={}".format(getenv("PYINSTALLER_LOG_LEVEL", "WARN")), "--manifest={}".format((package_folder / "../builder/manifest.xml").resolve()), - "--name={}_{}_{}{}_Python{}-{}".format( + "--name={}-gui_{}_{}{}_Python{}-{}".format( __about__.__title_clean__, __about__.__version__.replace(".", "-"), platform.system(), @@ -49,7 +47,6 @@ ), "--noconfirm", "--noupx", - # "--onedir", "--onefile", "--version-file={}".format("version_info.txt"), "--windowed",