pyloid 0.18.3__tar.gz → 0.19.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyloid
3
- Version: 0.18.3
3
+ Version: 0.19.0
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.18.3"
3
+ version = "0.19.0"
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]
@@ -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
+ }
@@ -30,9 +30,7 @@ def get_production_path(path: Optional[str] = None) -> Optional[str]:
30
30
  base_path = sys._MEIPASS
31
31
  else:
32
32
  # Nuitka
33
- base_path = globals()['__compiled__'].containing_dir
34
-
35
- print(base_path)
33
+ base_path = os.path.dirname(sys.executable)
36
34
 
37
35
  if base_path is None:
38
36
  # 환경변수가 없는 경우 실행 파일 디렉토리 사용
@@ -76,19 +74,28 @@ def get_platform() -> str:
76
74
 
77
75
  Returns
78
76
  -------
79
- "Windows" | "Darwin" | "Linux"
80
- - "Windows" for Windows systems
81
- - "Darwin" for macOS systems
82
- - "Linux" for Linux systems
77
+ "windows" | "macos" | "linux"
78
+ - "windows" for Windows systems
79
+ - "macos" for macOS systems
80
+ - "linux" for Linux systems
83
81
 
84
82
  Examples
85
83
  --------
86
84
  >>> from pyloid.utils import get_platform
87
85
  >>> platform_name = get_platform()
88
86
  >>> print(platform_name)
89
- Windows
87
+ windows
90
88
  """
91
- return platform.system()
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
92
99
 
93
100
  def get_absolute_path(path: str) -> str:
94
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