Update icon builds
This commit is contained in:
+10
-6
@@ -171,11 +171,15 @@ if __name__ == "__main__":
|
|||||||
# =================
|
# =================
|
||||||
|
|
||||||
# Build Icons
|
# Build Icons
|
||||||
|
styles = ", ".join([
|
||||||
|
"all", "default", "optional", "free", "non_free",
|
||||||
|
*utils.icon_themes.ICON_SOURCES.keys()
|
||||||
|
])
|
||||||
cmdIcons = parsers.add_parser(
|
cmdIcons = parsers.add_parser(
|
||||||
"icons", help="Build icon theme files from source."
|
"icons", help="Build icon theme files from upstream sources."
|
||||||
)
|
)
|
||||||
cmdIcons.add_argument("sources", help="Working directory for sources.")
|
cmdIcons.add_argument("style", help=f"What icon style to build: {styles}")
|
||||||
cmdIcons.add_argument("style", help="What icon style to build.")
|
cmdIcons.add_argument("--work-dir", help="Working directory.", default="build_icons")
|
||||||
cmdIcons.set_defaults(func=utils.icon_themes.main)
|
cmdIcons.set_defaults(func=utils.icon_themes.main)
|
||||||
|
|
||||||
# Import Translations
|
# Import Translations
|
||||||
@@ -275,9 +279,9 @@ if __name__ == "__main__":
|
|||||||
# See https://github.com/pypa/manylinux
|
# See https://github.com/pypa/manylinux
|
||||||
# See https://python-appimage.readthedocs.io/en/latest/#available-python-appimages
|
# See https://python-appimage.readthedocs.io/en/latest/#available-python-appimages
|
||||||
cmdBuildAppImage = parsers.add_parser("build-appimage", help="Build an AppImage.")
|
cmdBuildAppImage = parsers.add_parser("build-appimage", help="Build an AppImage.")
|
||||||
cmdBuildAppImage.add_argument("linux", help="Manylinux version, e.g. manylinux_2_28.")
|
cmdBuildAppImage.add_argument("linux", help="Manylinux version, e.g. manylinux_2_28")
|
||||||
cmdBuildAppImage.add_argument("arch", help="Architecture, e.g. x86_64.")
|
cmdBuildAppImage.add_argument("arch", help="Architecture, e.g. x86_64")
|
||||||
cmdBuildAppImage.add_argument("python", help="Python version, e.g. 3.13.")
|
cmdBuildAppImage.add_argument("python", help="Python version, e.g. 3.13")
|
||||||
cmdBuildAppImage.set_defaults(func=utils.build_appimage.appImage)
|
cmdBuildAppImage.set_defaults(func=utils.build_appimage.appImage)
|
||||||
|
|
||||||
# Build Windows Inno Setup Installer
|
# Build Windows Inno Setup Installer
|
||||||
|
|||||||
+56
-33
@@ -23,7 +23,8 @@ from __future__ import annotations
|
|||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import urllib.request
|
||||||
|
import zipfile
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
@@ -32,6 +33,17 @@ from utils.common import ROOT_DIR
|
|||||||
|
|
||||||
UTILS = Path(__file__).parent
|
UTILS = Path(__file__).parent
|
||||||
ET.register_namespace("", "http://www.w3.org/2000/svg")
|
ET.register_namespace("", "http://www.w3.org/2000/svg")
|
||||||
|
|
||||||
|
ICON_SOURCES = {
|
||||||
|
"material": "https://github.com/google/material-design-icons.git",
|
||||||
|
"font_awesome": "https://github.com/FortAwesome/Font-Awesome/archive/refs/tags/6.7.2.zip",
|
||||||
|
"remix": "https://github.com/Remix-Design/RemixIcon/archive/refs/tags/v4.6.0.zip",
|
||||||
|
}
|
||||||
|
ICON_EXTRACT = {
|
||||||
|
"material": "material-design-icons",
|
||||||
|
"font_awesome": "Font-Awesome-6.7.2",
|
||||||
|
"remix": "RemixIcon-4.6.0",
|
||||||
|
}
|
||||||
ICONS = [
|
ICONS = [
|
||||||
"alert_error",
|
"alert_error",
|
||||||
"alert_info",
|
"alert_info",
|
||||||
@@ -183,21 +195,33 @@ def _writeThemeFile(
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def _cloneRepo(repoPath: Path, repoUrl: str) -> None:
|
def _updateRepo(path: Path, name: str) -> None:
|
||||||
"""Clone or update a local repo of icons."""
|
"""Clone or update a local repo of icons."""
|
||||||
print(f"Updating: {repoUrl}")
|
print(f"Updating: {ICON_SOURCES[name]}")
|
||||||
if not repoPath.is_dir():
|
if not path.is_dir():
|
||||||
subprocess.call(["git", "clone", repoUrl, "--depth", "50"], cwd=repoPath.parent)
|
subprocess.call(["git", "clone", ICON_SOURCES[name], "--depth", "1"], cwd=path.parent)
|
||||||
else:
|
else:
|
||||||
subprocess.call(["git", "pull"], cwd=repoPath)
|
subprocess.call(["git", "pull"], cwd=path)
|
||||||
|
print("")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def _downloadIconPack(path: Path, name: str) -> None:
|
||||||
|
"""Download and extract icon pack releases."""
|
||||||
|
print(f"Downloading: {ICON_SOURCES[name]}")
|
||||||
|
zipFile = path / f"{name}.zip"
|
||||||
|
urllib.request.urlretrieve(ICON_SOURCES[name], zipFile)
|
||||||
|
print(f"Extracting: {zipFile.name}")
|
||||||
|
with zipfile.ZipFile(zipFile, "r") as inFile:
|
||||||
|
inFile.extractall(path)
|
||||||
print("")
|
print("")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||||
"""Process material icons of a given spec and write output file."""
|
"""Process material icons of a given spec and write output file."""
|
||||||
srcRepo = workDir / "material-design-icons"
|
srcRepo = workDir / ICON_EXTRACT["material"]
|
||||||
_cloneRepo(srcRepo, "https://github.com/google/material-design-icons.git")
|
_updateRepo(srcRepo, "material")
|
||||||
|
|
||||||
for file, job in jobs.items():
|
for file, job in jobs.items():
|
||||||
name: str = job["name"]
|
name: str = job["name"]
|
||||||
@@ -233,8 +257,9 @@ def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
|||||||
|
|
||||||
def processFontAwesome(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
def processFontAwesome(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||||
"""Process Font Awesome icons of a given spec and write output file."""
|
"""Process Font Awesome icons of a given spec and write output file."""
|
||||||
srcRepo = workDir / "Font-Awesome"
|
srcRepo = workDir / ICON_EXTRACT["font_awesome"]
|
||||||
_cloneRepo(srcRepo, "https://github.com/FortAwesome/Font-Awesome.git")
|
if not srcRepo.is_dir():
|
||||||
|
_downloadIconPack(workDir, "font_awesome")
|
||||||
|
|
||||||
for file, job in jobs.items():
|
for file, job in jobs.items():
|
||||||
name: str = job["name"]
|
name: str = job["name"]
|
||||||
@@ -278,8 +303,9 @@ def processFontAwesome(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
|||||||
|
|
||||||
def processRemix(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
def processRemix(workDir: Path, iconsDir: Path, jobs: dict) -> None:
|
||||||
"""Process Remix icons of a given spec and write output file."""
|
"""Process Remix icons of a given spec and write output file."""
|
||||||
srcRepo = workDir / "RemixIcon"
|
srcRepo = workDir / ICON_EXTRACT["remix"]
|
||||||
_cloneRepo(srcRepo, "https://github.com/Remix-Design/RemixIcon.git")
|
if not srcRepo.is_dir():
|
||||||
|
_downloadIconPack(workDir, "remix")
|
||||||
|
|
||||||
for file, job in jobs.items():
|
for file, job in jobs.items():
|
||||||
name: str = job["name"]
|
name: str = job["name"]
|
||||||
@@ -326,15 +352,12 @@ def main(args: argparse.Namespace) -> None:
|
|||||||
print("=================")
|
print("=================")
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
workDir = Path(args.sources).absolute()
|
workDir = Path(args.work_dir).absolute()
|
||||||
if not workDir.is_dir():
|
workDir.mkdir(exist_ok=True)
|
||||||
print(f"Source directory not found: {workDir}")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
iconsDir = ROOT_DIR / "novelwriter" / "assets" / "icons"
|
iconsDir = ROOT_DIR / "novelwriter" / "assets" / "icons"
|
||||||
|
|
||||||
style = args.style
|
style = args.style
|
||||||
if style in ("all", "material"):
|
if style in ("all", "default", "material"):
|
||||||
processMaterialIcons(workDir, iconsDir, {
|
processMaterialIcons(workDir, iconsDir, {
|
||||||
"material_rounded_thin": {
|
"material_rounded_thin": {
|
||||||
"name": "Material Symbols - Rounded Thin",
|
"name": "Material Symbols - Rounded Thin",
|
||||||
@@ -343,17 +366,11 @@ def main(args: argparse.Namespace) -> None:
|
|||||||
"weight": 200,
|
"weight": 200,
|
||||||
},
|
},
|
||||||
"material_rounded_normal": {
|
"material_rounded_normal": {
|
||||||
"name": "Material Symbols - Rounded Medium",
|
"name": "Material Symbols - Rounded",
|
||||||
"style": "rounded",
|
"style": "rounded",
|
||||||
"filled": False,
|
"filled": False,
|
||||||
"weight": 400,
|
"weight": 400,
|
||||||
},
|
},
|
||||||
"material_rounded_bold": {
|
|
||||||
"name": "Material Symbols - Rounded Bold",
|
|
||||||
"style": "rounded",
|
|
||||||
"filled": False,
|
|
||||||
"weight": 600,
|
|
||||||
},
|
|
||||||
"material_filled_thin": {
|
"material_filled_thin": {
|
||||||
"name": "Material Symbols - Filled Thin",
|
"name": "Material Symbols - Filled Thin",
|
||||||
"style": "rounded",
|
"style": "rounded",
|
||||||
@@ -361,27 +378,33 @@ def main(args: argparse.Namespace) -> None:
|
|||||||
"weight": 200,
|
"weight": 200,
|
||||||
},
|
},
|
||||||
"material_filled_normal": {
|
"material_filled_normal": {
|
||||||
"name": "Material Symbols - Filled Medium",
|
"name": "Material Symbols - Filled",
|
||||||
"style": "rounded",
|
"style": "rounded",
|
||||||
"filled": True,
|
"filled": True,
|
||||||
"weight": 400,
|
"weight": 400,
|
||||||
},
|
},
|
||||||
"material_filled_bold": {
|
"material_sharp_thin": {
|
||||||
"name": "Material Symbols - Filled Bold",
|
"name": "Material Symbols - Sharp Thin",
|
||||||
"style": "rounded",
|
"style": "sharp",
|
||||||
"filled": True,
|
"filled": False,
|
||||||
"weight": 600,
|
"weight": 200,
|
||||||
|
},
|
||||||
|
"material_sharp_normal": {
|
||||||
|
"name": "Material Symbols - Sharp",
|
||||||
|
"style": "sharp",
|
||||||
|
"filled": False,
|
||||||
|
"weight": 400,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if style in ("all", "fa"):
|
if style in ("all", "optional", "free", "font_awesome"):
|
||||||
processFontAwesome(workDir, iconsDir, {
|
processFontAwesome(workDir, iconsDir, {
|
||||||
"font_awesome": {
|
"font_awesome": {
|
||||||
"name": "Font Awesome 6",
|
"name": "Font Awesome 6",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if style in ("all", "remix"):
|
if style in ("all", "optional", "non_free", "remix"):
|
||||||
processRemix(workDir, iconsDir, {
|
processRemix(workDir, iconsDir, {
|
||||||
"remix_outline": {
|
"remix_outline": {
|
||||||
"name": "Remix Icon - Outline",
|
"name": "Remix Icon - Outline",
|
||||||
|
|||||||
Reference in New Issue
Block a user