diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 72e49f3..d3869da 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -12,7 +12,7 @@ jobs: - name: Install Dependencies run: pip install -r requirements.txt - name: Build Package - run: pyinstaller builder.py modules/*.py -n StaticGalleryBuilder -F --add-data files:files --add-data templates:templates --add-data .version:. + run: pyinstaller builder.py modules/*.py -n StaticGalleryBuilder-$(cat .version)-linux -F --add-data files:files --add-data templates:templates --add-data .version:. - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') diff --git a/.version b/.version index e703481..45674f1 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.3.2 \ No newline at end of file +2.3.3 \ No newline at end of file diff --git a/StaticGalleryBuilder.code-workspace b/StaticGalleryBuilder.code-workspace index 556ef2e..f2e98b3 100644 --- a/StaticGalleryBuilder.code-workspace +++ b/StaticGalleryBuilder.code-workspace @@ -157,6 +157,14 @@ "label": "Delete Lockfile", "problemMatcher": [], "type": "shell", + "presentation": { + "echo": false, + "reveal": "never", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + } }, { "command": "rm -f /home/user/woek/Pictures/.lock", @@ -164,7 +172,53 @@ "label": "Delete Lockfile 2", "problemMatcher": [], "type": "shell", + "presentation": { + "echo": false, + "reveal": "never", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + } }, + { + "command": "pyinstaller builder.py modules/*.py -n StaticGalleryBuilder-$(cat .version)-linux -F --add-data files:files --add-data templates:templates --add-data .version:.", + "isBackground": false, + "label": "Build", + "problemMatcher": [], + "type": "shell", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": false + }, + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": [ + "Clean" + ] + }, + { + "command": "rm -rf build dist", + "isBackground": true, + "label": "Clean", + "problemMatcher": [], + "type": "shell", + "presentation": { + "echo": true, + "reveal": "never", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "group": "build" + } ], }, } \ No newline at end of file diff --git a/modules/svg_handling.py b/modules/svg_handling.py index 2165040..c207507 100644 --- a/modules/svg_handling.py +++ b/modules/svg_handling.py @@ -1,6 +1,7 @@ import os import shutil from typing import List, Dict +from subprocess import Popen, PIPE from PIL import Image from jinja2 import Environment, FileSystemLoader @@ -92,10 +93,23 @@ def generate_favicon(iconspath: str, root_directory: str) -> None: """ favicon = os.path.join(root_directory, ".static", "favicon.ico") logger.info("generating favicon with imagemagick", extra={"iconspath": iconspath, "favicon": favicon}) - command = f'magick {os.path.join(iconspath, "icon.png")} -define icon:auto-resize=16,32,48,64,72,96,144,192 {favicon}' + _env = dict(os.environ) + lp_key = "LD_LIBRARY_PATH" + lp_orig = _env.get(lp_key + "_ORIG") + if lp_orig is not None: + _env[lp_key] = lp_orig + else: + _env.pop(lp_key, None) if not shutil.which("magick"): - command = f'convert {os.path.join(iconspath, "icon.png")} -define icon:auto-resize=16,32,48,64,72,96,144,192 {favicon}' - os.system(command) + magick = shutil.which("convert") + else: + magick = shutil.which("magick") + command = [magick, os.path.join(iconspath, "icon.png"), "-define", "icon:auto-resize=16,32,48,64,72,96,144,192", favicon] + with Popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=_env, errors="ignore") as p: + out, err = p.communicate() + if p.returncode != 0: + logger.error("error generating favicon: %s", err, extra={"command": command, "out": out, "err": err}) + logger.info("favicon generated successfully", extra={"command": command, "out": out, "err": err}) def icons(_args: Args) -> None: