pyloid 0.18.4__tar.gz → 0.19.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyloid-0.18.4 → pyloid-0.19.1}/PKG-INFO +2 -1
- {pyloid-0.18.4 → pyloid-0.19.1}/pyproject.toml +2 -1
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/__init__.py +2 -1
- pyloid-0.19.1/src/pyloid/builder/__init__.py +249 -0
- pyloid-0.19.1/src/pyloid/builder/build_config.json +27 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/utils.py +15 -6
- {pyloid-0.18.4 → pyloid-0.19.1}/LICENSE +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/README.md +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/api.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/autostart.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/browser_window.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/custom/titlebar.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/filewatcher.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/js_api/event_api.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/js_api/window_api.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/monitor.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/pyloid.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/thread_pool.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/timer.py +0 -0
- {pyloid-0.18.4 → pyloid-0.19.1}/src/pyloid/tray.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyloid
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.19.1
|
4
4
|
Summary:
|
5
5
|
Author: aesthetics-of-record
|
6
6
|
Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
|
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.10
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
13
|
+
Requires-Dist: pyinstaller (>=6.11.1,<7.0.0)
|
13
14
|
Requires-Dist: pyside6 (>=6.8.1,<7.0.0)
|
14
15
|
Description-Content-Type: text/markdown
|
15
16
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "pyloid"
|
3
|
-
version = "0.
|
3
|
+
version = "0.19.1"
|
4
4
|
description = ""
|
5
5
|
authors = ["aesthetics-of-record <111675679+aesthetics-of-record@users.noreply.github.com>"]
|
6
6
|
readme = "README.md"
|
@@ -11,6 +11,7 @@ packages = [
|
|
11
11
|
[tool.poetry.dependencies]
|
12
12
|
python = ">=3.9,<3.14"
|
13
13
|
pyside6 = "^6.8.1"
|
14
|
+
pyinstaller = "^6.11.1"
|
14
15
|
|
15
16
|
|
16
17
|
[build-system]
|
@@ -3,5 +3,6 @@ from .api import PyloidAPI, Bridge
|
|
3
3
|
from .utils import get_production_path, is_production
|
4
4
|
from .tray import TrayEvent
|
5
5
|
from .timer import PyloidTimer
|
6
|
+
from .builder import build_from_spec, cleanup_after_build, create_spec_from_json
|
6
7
|
|
7
|
-
__all__ = ['Pyloid', 'PyloidAPI', 'Bridge', 'get_production_path', 'is_production', 'TrayEvent', 'PyloidTimer']
|
8
|
+
__all__ = ['Pyloid', 'PyloidAPI', 'Bridge', 'get_production_path', 'is_production', 'TrayEvent', 'PyloidTimer', 'build_from_spec', 'cleanup_after_build', 'create_spec_from_json']
|
@@ -0,0 +1,249 @@
|
|
1
|
+
import json
|
2
|
+
import os
|
3
|
+
import subprocess
|
4
|
+
from pathlib import Path
|
5
|
+
from pyloid.utils import get_platform
|
6
|
+
from PyInstaller.__main__ import run as pyinstaller_run
|
7
|
+
import shutil
|
8
|
+
|
9
|
+
|
10
|
+
def create_spec_from_json(json_path):
|
11
|
+
with open(json_path, 'r', encoding='utf-8') as f:
|
12
|
+
config = json.load(f)
|
13
|
+
|
14
|
+
# Create spec file for each OS
|
15
|
+
os_type = get_platform()
|
16
|
+
|
17
|
+
# Select template for each OS
|
18
|
+
if os_type == 'macos':
|
19
|
+
spec_content = _create_macos_spec(config)
|
20
|
+
elif os_type == 'linux':
|
21
|
+
spec_content = _create_linux_spec(config)
|
22
|
+
else: # windows
|
23
|
+
spec_content = _create_windows_spec(config)
|
24
|
+
|
25
|
+
# Save spec file
|
26
|
+
spec_path = Path(f"build-{os_type}.spec")
|
27
|
+
spec_path.write_text(spec_content, encoding='utf-8')
|
28
|
+
|
29
|
+
return str(spec_path)
|
30
|
+
|
31
|
+
def _create_windows_spec(config):
|
32
|
+
return f"""# -*- mode: python ; coding: utf-8 -*-
|
33
|
+
|
34
|
+
block_cipher = None
|
35
|
+
|
36
|
+
a = Analysis(
|
37
|
+
['{config['main_script']}'],
|
38
|
+
pathex={config.get('pathex', [])},
|
39
|
+
binaries={config.get('binaries', [])},
|
40
|
+
datas={config.get('datas', [])},
|
41
|
+
hiddenimports={config.get('hiddenimports', [])},
|
42
|
+
hookspath={config.get('hookspath', [])},
|
43
|
+
hooksconfig={config.get('hooksconfig', {})},
|
44
|
+
runtime_hooks={config.get('runtime_hooks', [])},
|
45
|
+
excludes={config.get('excludes', [])},
|
46
|
+
win_no_prefer_redirects=False,
|
47
|
+
win_private_assemblies=False,
|
48
|
+
cipher=block_cipher,
|
49
|
+
noarchive=False
|
50
|
+
)
|
51
|
+
|
52
|
+
pyz = PYZ(a.pure, a.zipped_data,
|
53
|
+
cipher=block_cipher)
|
54
|
+
|
55
|
+
exe = EXE(
|
56
|
+
pyz,
|
57
|
+
a.scripts,
|
58
|
+
[],
|
59
|
+
exclude_binaries=True,
|
60
|
+
name='{config.get("name", "pyloid-app")}',
|
61
|
+
debug=False,
|
62
|
+
bootloader_ignore_signals=False,
|
63
|
+
strip=False,
|
64
|
+
upx=True,
|
65
|
+
console=False,
|
66
|
+
disable_windowed_traceback=False,
|
67
|
+
argv_emulation=False,
|
68
|
+
target_arch=None,
|
69
|
+
codesign_identity=None,
|
70
|
+
entitlements_file=None,
|
71
|
+
icon='{config.get('icon', 'src-pyloid/icons/icon.ico')}'
|
72
|
+
)
|
73
|
+
|
74
|
+
coll = COLLECT(
|
75
|
+
exe,
|
76
|
+
a.binaries,
|
77
|
+
a.zipfiles,
|
78
|
+
a.datas,
|
79
|
+
strip=False,
|
80
|
+
upx=True,
|
81
|
+
upx_exclude=[],
|
82
|
+
name='{config.get("name", "pyloid-app")}'
|
83
|
+
)
|
84
|
+
"""
|
85
|
+
|
86
|
+
def _create_macos_spec(config):
|
87
|
+
return f"""# -*- mode: python ; coding: utf-8 -*-
|
88
|
+
|
89
|
+
a = Analysis(
|
90
|
+
['{config['main_script']}'],
|
91
|
+
pathex={config.get('pathex', [])},
|
92
|
+
binaries={config.get('binaries', [])},
|
93
|
+
datas={config.get('datas', [])},
|
94
|
+
hiddenimports={config.get('hiddenimports', [])},
|
95
|
+
hookspath={config.get('hookspath', [])},
|
96
|
+
hooksconfig={config.get('hooksconfig', {})},
|
97
|
+
runtime_hooks={config.get('runtime_hooks', [])},
|
98
|
+
excludes={config.get('excludes', [])},
|
99
|
+
noarchive=False,
|
100
|
+
optimize=0
|
101
|
+
)
|
102
|
+
|
103
|
+
pyz = PYZ(a.pure)
|
104
|
+
|
105
|
+
exe = EXE(
|
106
|
+
pyz,
|
107
|
+
a.scripts,
|
108
|
+
[],
|
109
|
+
exclude_binaries=True,
|
110
|
+
name='{config.get("name", "pyloid-app")}',
|
111
|
+
debug=False,
|
112
|
+
bootloader_ignore_signals=False,
|
113
|
+
strip=False,
|
114
|
+
upx=True,
|
115
|
+
console=False,
|
116
|
+
disable_windowed_traceback=False,
|
117
|
+
argv_emulation=False,
|
118
|
+
target_arch=None,
|
119
|
+
codesign_identity=None,
|
120
|
+
entitlements_file=None,
|
121
|
+
icon='{config.get('icon', 'src-pyloid/icons/icon.ico')}'
|
122
|
+
)
|
123
|
+
|
124
|
+
coll = COLLECT(
|
125
|
+
exe,
|
126
|
+
a.binaries,
|
127
|
+
a.datas,
|
128
|
+
strip=False,
|
129
|
+
upx=True,
|
130
|
+
upx_exclude=[],
|
131
|
+
name='{config.get("name", "pyloid-app")}'
|
132
|
+
)
|
133
|
+
|
134
|
+
app = BUNDLE(
|
135
|
+
coll,
|
136
|
+
name='{config.get("name", "pyloid-app")}.app',
|
137
|
+
icon='{config.get('icon', 'src-pyloid/icons/icon.icns')}',
|
138
|
+
bundle_identifier=None
|
139
|
+
)
|
140
|
+
"""
|
141
|
+
|
142
|
+
def _create_linux_spec(config):
|
143
|
+
return f"""# -*- mode: python ; coding: utf-8 -*-
|
144
|
+
|
145
|
+
block_cipher = None
|
146
|
+
|
147
|
+
a = Analysis(
|
148
|
+
['{config['main_script']}'],
|
149
|
+
pathex={config.get('pathex', [])},
|
150
|
+
binaries={config.get('binaries', [])},
|
151
|
+
datas={config.get('datas', [])},
|
152
|
+
hiddenimports={config.get('hiddenimports', [])},
|
153
|
+
hookspath={config.get('hookspath', [])},
|
154
|
+
hooksconfig={config.get('hooksconfig', {})},
|
155
|
+
runtime_hooks={config.get('runtime_hooks', [])},
|
156
|
+
excludes={config.get('excludes', [])},
|
157
|
+
win_no_prefer_redirects=False,
|
158
|
+
win_private_assemblies=False,
|
159
|
+
cipher=block_cipher,
|
160
|
+
noarchive=False
|
161
|
+
)
|
162
|
+
|
163
|
+
pyz = PYZ(a.pure, a.zipped_data,
|
164
|
+
cipher=block_cipher)
|
165
|
+
|
166
|
+
exe = EXE(
|
167
|
+
pyz,
|
168
|
+
a.scripts,
|
169
|
+
[],
|
170
|
+
exclude_binaries=True,
|
171
|
+
name='{config.get("name", "pyloid-app")}',
|
172
|
+
debug=False,
|
173
|
+
bootloader_ignore_signals=False,
|
174
|
+
strip=False,
|
175
|
+
upx=True,
|
176
|
+
console=False,
|
177
|
+
disable_windowed_traceback=False,
|
178
|
+
argv_emulation=False,
|
179
|
+
target_arch=None,
|
180
|
+
codesign_identity=None,
|
181
|
+
entitlements_file=None,
|
182
|
+
icon={config.get('icon', 'src-pyloid/icons/icon.png')}
|
183
|
+
)
|
184
|
+
|
185
|
+
coll = COLLECT(
|
186
|
+
exe,
|
187
|
+
a.binaries,
|
188
|
+
a.zipfiles,
|
189
|
+
a.datas,
|
190
|
+
strip=False,
|
191
|
+
upx=True,
|
192
|
+
upx_exclude=[],
|
193
|
+
name='{config.get("name", "pyloid-app")}'
|
194
|
+
)
|
195
|
+
"""
|
196
|
+
|
197
|
+
def cleanup_after_build(json_path):
|
198
|
+
"""Function to clean up unnecessary files after build"""
|
199
|
+
try:
|
200
|
+
with open(json_path, 'r', encoding='utf-8') as f:
|
201
|
+
config = json.load(f)
|
202
|
+
|
203
|
+
cleanup_patterns = config.get('cleanup_patterns', [])
|
204
|
+
if not cleanup_patterns:
|
205
|
+
return True
|
206
|
+
|
207
|
+
dist_dir = Path(f'dist/{config.get("name", "pyloid-app")}')
|
208
|
+
if not dist_dir.exists():
|
209
|
+
print(f"Cannot find directory to clean: {dist_dir}")
|
210
|
+
return False
|
211
|
+
|
212
|
+
print("Cleaning up unnecessary files...")
|
213
|
+
for pattern in cleanup_patterns:
|
214
|
+
for file_path in dist_dir.glob(pattern):
|
215
|
+
if file_path.is_dir():
|
216
|
+
shutil.rmtree(file_path)
|
217
|
+
else:
|
218
|
+
file_path.unlink()
|
219
|
+
print(f"Removed: {file_path}")
|
220
|
+
|
221
|
+
print("File cleanup completed.")
|
222
|
+
return True
|
223
|
+
|
224
|
+
except Exception as e:
|
225
|
+
print(f"Error occurred during file cleanup: {e}")
|
226
|
+
return False
|
227
|
+
|
228
|
+
def build_from_spec(spec_path):
|
229
|
+
try:
|
230
|
+
pyinstaller_run([
|
231
|
+
'--clean', # Clean temporary files
|
232
|
+
spec_path # Spec file path
|
233
|
+
])
|
234
|
+
print("Build completed.")
|
235
|
+
|
236
|
+
return True
|
237
|
+
except Exception as e:
|
238
|
+
print(f"Error occurred during build: {e}")
|
239
|
+
return False
|
240
|
+
|
241
|
+
def main():
|
242
|
+
spec_path = create_spec_from_json('build_config.json')
|
243
|
+
|
244
|
+
build_from_spec(spec_path)
|
245
|
+
|
246
|
+
cleanup_after_build('build_config.json')
|
247
|
+
|
248
|
+
if __name__ == "__main__":
|
249
|
+
main()
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"name": "pyloid-app",
|
3
|
+
"datas": [
|
4
|
+
["src-pyloid/icons/", "src-pyloid/icons/"],
|
5
|
+
["build-front/", "build-front/"]
|
6
|
+
],
|
7
|
+
"excludes": [
|
8
|
+
"PySide6.QtQml",
|
9
|
+
"PySide6.QtTest",
|
10
|
+
"PySide6.Qt3D",
|
11
|
+
"PySide6.QtSensors",
|
12
|
+
"PySide6.QtCharts",
|
13
|
+
"PySide6.QtGraphs",
|
14
|
+
"PySide6.QtDataVisualization",
|
15
|
+
"PySide6.QtQuick",
|
16
|
+
"PySide6.QtDesigner",
|
17
|
+
"PySide6.QtUiTools",
|
18
|
+
"PySide6.QtHelp"
|
19
|
+
],
|
20
|
+
"icon": "src-pyloid/icons/icon.ico",
|
21
|
+
"after_build": {
|
22
|
+
"cleanup_patterns": [
|
23
|
+
"_internal/PySide*/opengl32sw.dll",
|
24
|
+
"_internal/PySide*/translations"
|
25
|
+
]
|
26
|
+
}
|
27
|
+
}
|
@@ -74,19 +74,28 @@ def get_platform() -> str:
|
|
74
74
|
|
75
75
|
Returns
|
76
76
|
-------
|
77
|
-
"
|
78
|
-
- "
|
79
|
-
- "
|
80
|
-
- "
|
77
|
+
"windows" | "macos" | "linux"
|
78
|
+
- "windows" for Windows systems
|
79
|
+
- "macos" for macOS systems
|
80
|
+
- "linux" for Linux systems
|
81
81
|
|
82
82
|
Examples
|
83
83
|
--------
|
84
84
|
>>> from pyloid.utils import get_platform
|
85
85
|
>>> platform_name = get_platform()
|
86
86
|
>>> print(platform_name)
|
87
|
-
|
87
|
+
windows
|
88
88
|
"""
|
89
|
-
|
89
|
+
os_name = platform.system().lower()
|
90
|
+
os_type = {
|
91
|
+
'darwin': 'macos',
|
92
|
+
'linux': 'linux',
|
93
|
+
'windows': 'windows'
|
94
|
+
}.get(os_name)
|
95
|
+
if os_type is None:
|
96
|
+
raise ValueError(f"Unsupported platform: {os_name}")
|
97
|
+
|
98
|
+
return os_type
|
90
99
|
|
91
100
|
def get_absolute_path(path: str) -> str:
|
92
101
|
"""
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|