Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 1cfc34f

Browse files
committed
Icon
1 parent 84148b3 commit 1cfc34f

File tree

3 files changed

+127
-1
lines changed

3 files changed

+127
-1
lines changed

.ci/create-spec.py

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# The MIT License (MIT)
2+
3+
# Copyright (c) 2021-2024 Krux contributors
4+
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
build.py
24+
"""
25+
from re import findall
26+
from os import listdir
27+
from os.path import join, isfile
28+
from pathlib import Path
29+
from platform import system
30+
import argparse
31+
import PyInstaller.building.makespec
32+
33+
if __name__ == "__main__":
34+
p = argparse.ArgumentParser()
35+
PyInstaller.building.makespec.__add_options(p)
36+
PyInstaller.log.__add_options(p)
37+
38+
SYSTEM = system()
39+
40+
# build executable for following systems
41+
if SYSTEM not in ("Linux", "Windows", "Darwin"):
42+
raise OSError(f"OS '{system()}' not implemented")
43+
44+
# Get root path to properly setup
45+
DIR = Path(__file__).parents
46+
ROOT_PATH = Path(__file__).parent.parent.absolute()
47+
PYNAME = "seedqreader"
48+
PYFILE = f"{PYNAME}.py"
49+
KFILE = str(ROOT_PATH / PYFILE)
50+
ASSETS = str(ROOT_PATH / "assets")
51+
ICON = join(ASSETS, "icon.png")
52+
# I18NS = str(ROOT_PATH / "src" / "i18n")
53+
54+
BUILDER_ARGS = [ ]
55+
56+
# The app name
57+
BUILDER_ARGS.append(f"--name={PYNAME}")
58+
59+
# The application has window
60+
BUILDER_ARGS.append("--windowed")
61+
62+
# Icon
63+
BUILDER_ARGS.append(f"--icon={ICON}")
64+
65+
# Specifics about operational system
66+
# on how will behave as file or bundled app
67+
if SYSTEM == "Linux":
68+
# Tha application is a GUI
69+
BUILDER_ARGS.append("--onefile")
70+
71+
elif SYSTEM == "Windows":
72+
# Tha application is a GUI with a hidden console
73+
# to keep `sys` module enabled (necessary for Kboot)
74+
BUILDER_ARGS.append("--onefile")
75+
BUILDER_ARGS.append("--console")
76+
BUILDER_ARGS.append("--hidden-import=win32timezone")
77+
BUILDER_ARGS.append("--hide-console=minimize-early")
78+
79+
elif SYSTEM == "Darwin":
80+
# Tha application is a GUI in a bundled .app
81+
BUILDER_ARGS.append("--onefile")
82+
BUILDER_ARGS.append("--noconsole")
83+
84+
# For darwin system, will be necessary
85+
# to add a hidden import for ssl
86+
# (necessary for request module)
87+
BUILDER_ARGS.append("--hidden-import=ssl")
88+
BUILDER_ARGS.append("--hidden-import=pillow")
89+
BUILDER_ARGS.append("--optimize=2")
90+
91+
# Necessary for get version and
92+
# another infos in application
93+
# BUILDER_ARGS.append("--add-data=pyproject.toml:.")
94+
BUILDER_ARGS.append("--add-data=form.ui:.")
95+
96+
# some assets
97+
for f in listdir(ASSETS):
98+
asset = join(ASSETS, f)
99+
if isfile(asset):
100+
if asset.endswith("png") or asset.endswith("gif") or asset.endswith("ttf"):
101+
BUILDER_ARGS.append(f"--add-data={asset}:assets")
102+
103+
# Add i18n translations
104+
# for f in listdir(I18NS):
105+
# i18n_abs = join(I18NS, f)
106+
# i18n_rel = join("src", "i18n")
107+
# if isfile(i18n_abs):
108+
# if findall(r"^[a-z]+\_[A-Z]+\.UTF-8\.json$", f):
109+
# BUILDER_ARGS.append(f"--add-data={i18n_abs}:{i18n_rel}")
110+
111+
112+
args = p.parse_args(BUILDER_ARGS)
113+
114+
# Now generate spec
115+
print("============================")
116+
print("create-spec.py")
117+
print("============================")
118+
print()
119+
for k, v in vars(args).items():
120+
print(f"{k}: {v}")
121+
122+
print()
123+
PyInstaller.building.makespec.main(["seedqreader.py"], **vars(args))

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ venv/
44
config
55
.seedqrenv/
66
.venv/
7-
.env/
7+
.env/
8+
build/
9+
*.spec
10+
dist/

assets/icon.png

98.6 KB
Loading

0 commit comments

Comments
 (0)