pyloid 0.20.1.dev1__py3-none-any.whl → 0.20.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyloid/__init__.py +7 -7
- pyloid/api.py +104 -104
- pyloid/autostart.py +101 -101
- pyloid/browser_window.py +1915 -1968
- pyloid/builder/__init__.py +80 -80
- pyloid/builder/build_config.schema.json +72 -72
- pyloid/builder/spec.py +246 -246
- pyloid/custom/titlebar.py +116 -116
- pyloid/filewatcher.py +163 -163
- pyloid/js_api/event_api.py +24 -24
- pyloid/js_api/window_api.py +255 -255
- pyloid/monitor.py +921 -921
- pyloid/pyloid.py +1404 -1404
- pyloid/thread_pool.py +500 -500
- pyloid/timer.py +307 -307
- pyloid/tray.py +48 -48
- pyloid/utils.py +122 -122
- {pyloid-0.20.1.dev1.dist-info → pyloid-0.20.2.dist-info}/LICENSE +200 -200
- {pyloid-0.20.1.dev1.dist-info → pyloid-0.20.2.dist-info}/METADATA +4 -2
- pyloid-0.20.2.dist-info/RECORD +21 -0
- {pyloid-0.20.1.dev1.dist-info → pyloid-0.20.2.dist-info}/WHEEL +1 -1
- pyloid-0.20.1.dev1.dist-info/RECORD +0 -21
pyloid/builder/__init__.py
CHANGED
@@ -1,81 +1,81 @@
|
|
1
|
-
import json
|
2
|
-
from pathlib import Path
|
3
|
-
from PyInstaller.__main__ import run as pyinstaller_run
|
4
|
-
import shutil
|
5
|
-
import site
|
6
|
-
from pyloid.builder.spec import create_spec_from_json
|
7
|
-
|
8
|
-
__all__ = ['create_spec_from_json', 'cleanup_before_build', 'build_from_spec', 'get_site_packages']
|
9
|
-
|
10
|
-
def cleanup_before_build(json_path):
|
11
|
-
"""Function to clean up unnecessary files before build"""
|
12
|
-
try:
|
13
|
-
with open(json_path, 'r', encoding='utf-8') as f:
|
14
|
-
config = json.load(f)
|
15
|
-
|
16
|
-
cleanup_patterns = config.get('before_build', {}).get('cleanup_patterns', [])
|
17
|
-
if not cleanup_patterns:
|
18
|
-
return Exception("Cannot find cleanup patterns.")
|
19
|
-
|
20
|
-
site_packages = get_site_packages()
|
21
|
-
if not site_packages:
|
22
|
-
raise Exception("Cannot find site-packages directory.")
|
23
|
-
|
24
|
-
dist_dir = Path(f'{site_packages}')
|
25
|
-
if not dist_dir.exists():
|
26
|
-
raise Exception(f"Cannot find directory to clean: {dist_dir}")
|
27
|
-
|
28
|
-
print("\033[1;34mCleaning up unnecessary files...\033[0m")
|
29
|
-
exclude_patterns = [p[1:] for p in cleanup_patterns if p.startswith('!')]
|
30
|
-
include_patterns = [p for p in cleanup_patterns if not p.startswith('!')]
|
31
|
-
|
32
|
-
for pattern in include_patterns:
|
33
|
-
matching_files = list(dist_dir.glob(pattern))
|
34
|
-
for file_path in matching_files:
|
35
|
-
if any(file_path.match(p) for p in exclude_patterns):
|
36
|
-
print(f"\033[33mSkipping: {file_path}\033[0m")
|
37
|
-
continue
|
38
|
-
print(f"\033[33mRemoving: {file_path}\033[0m")
|
39
|
-
if file_path.is_dir():
|
40
|
-
shutil.rmtree(file_path)
|
41
|
-
else:
|
42
|
-
file_path.unlink()
|
43
|
-
print(f"\033[32mRemoved: {file_path}\033[0m")
|
44
|
-
|
45
|
-
print("\033[1;32mFile cleanup completed.\033[0m")
|
46
|
-
|
47
|
-
except Exception as e:
|
48
|
-
raise Exception(f"\033[1;31mError occurred during file cleanup: {e}\033[0m")
|
49
|
-
|
50
|
-
def build_from_spec(spec_path):
|
51
|
-
try:
|
52
|
-
pyinstaller_run([
|
53
|
-
'--clean', # Clean temporary files
|
54
|
-
spec_path # Spec file path
|
55
|
-
])
|
56
|
-
print("Build completed.")
|
57
|
-
|
58
|
-
except Exception as e:
|
59
|
-
raise Exception(f"Error occurred during build: {e}")
|
60
|
-
|
61
|
-
def get_site_packages():
|
62
|
-
"""
|
63
|
-
Returns the path to the site-packages directory.
|
64
|
-
Raises an exception if the directory is not found.
|
65
|
-
"""
|
66
|
-
for path in site.getsitepackages():
|
67
|
-
if 'site-packages' in path:
|
68
|
-
return path
|
69
|
-
raise Exception("Site-packages directory not found.")
|
70
|
-
|
71
|
-
def main():
|
72
|
-
spec_path = create_spec_from_json('build_config.json')
|
73
|
-
|
74
|
-
cleanup_before_build('build_config.json')
|
75
|
-
|
76
|
-
# build_from_spec(spec_path)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
if __name__ == "__main__":
|
1
|
+
import json
|
2
|
+
from pathlib import Path
|
3
|
+
from PyInstaller.__main__ import run as pyinstaller_run
|
4
|
+
import shutil
|
5
|
+
import site
|
6
|
+
from pyloid.builder.spec import create_spec_from_json
|
7
|
+
|
8
|
+
__all__ = ['create_spec_from_json', 'cleanup_before_build', 'build_from_spec', 'get_site_packages']
|
9
|
+
|
10
|
+
def cleanup_before_build(json_path):
|
11
|
+
"""Function to clean up unnecessary files before build"""
|
12
|
+
try:
|
13
|
+
with open(json_path, 'r', encoding='utf-8') as f:
|
14
|
+
config = json.load(f)
|
15
|
+
|
16
|
+
cleanup_patterns = config.get('before_build', {}).get('cleanup_patterns', [])
|
17
|
+
if not cleanup_patterns:
|
18
|
+
return Exception("Cannot find cleanup patterns.")
|
19
|
+
|
20
|
+
site_packages = get_site_packages()
|
21
|
+
if not site_packages:
|
22
|
+
raise Exception("Cannot find site-packages directory.")
|
23
|
+
|
24
|
+
dist_dir = Path(f'{site_packages}')
|
25
|
+
if not dist_dir.exists():
|
26
|
+
raise Exception(f"Cannot find directory to clean: {dist_dir}")
|
27
|
+
|
28
|
+
print("\033[1;34mCleaning up unnecessary files...\033[0m")
|
29
|
+
exclude_patterns = [p[1:] for p in cleanup_patterns if p.startswith('!')]
|
30
|
+
include_patterns = [p for p in cleanup_patterns if not p.startswith('!')]
|
31
|
+
|
32
|
+
for pattern in include_patterns:
|
33
|
+
matching_files = list(dist_dir.glob(pattern))
|
34
|
+
for file_path in matching_files:
|
35
|
+
if any(file_path.match(p) for p in exclude_patterns):
|
36
|
+
print(f"\033[33mSkipping: {file_path}\033[0m")
|
37
|
+
continue
|
38
|
+
print(f"\033[33mRemoving: {file_path}\033[0m")
|
39
|
+
if file_path.is_dir():
|
40
|
+
shutil.rmtree(file_path)
|
41
|
+
else:
|
42
|
+
file_path.unlink()
|
43
|
+
print(f"\033[32mRemoved: {file_path}\033[0m")
|
44
|
+
|
45
|
+
print("\033[1;32mFile cleanup completed.\033[0m")
|
46
|
+
|
47
|
+
except Exception as e:
|
48
|
+
raise Exception(f"\033[1;31mError occurred during file cleanup: {e}\033[0m")
|
49
|
+
|
50
|
+
def build_from_spec(spec_path):
|
51
|
+
try:
|
52
|
+
pyinstaller_run([
|
53
|
+
'--clean', # Clean temporary files
|
54
|
+
spec_path # Spec file path
|
55
|
+
])
|
56
|
+
print("Build completed.")
|
57
|
+
|
58
|
+
except Exception as e:
|
59
|
+
raise Exception(f"Error occurred during build: {e}")
|
60
|
+
|
61
|
+
def get_site_packages():
|
62
|
+
"""
|
63
|
+
Returns the path to the site-packages directory.
|
64
|
+
Raises an exception if the directory is not found.
|
65
|
+
"""
|
66
|
+
for path in site.getsitepackages():
|
67
|
+
if 'site-packages' in path:
|
68
|
+
return path
|
69
|
+
raise Exception("Site-packages directory not found.")
|
70
|
+
|
71
|
+
def main():
|
72
|
+
spec_path = create_spec_from_json('build_config.json')
|
73
|
+
|
74
|
+
cleanup_before_build('build_config.json')
|
75
|
+
|
76
|
+
# build_from_spec(spec_path)
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
if __name__ == "__main__":
|
81
81
|
main()
|
@@ -1,73 +1,73 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
|
-
"type": "object",
|
4
|
-
"required": ["before_build", "name", "main_script", "datas", "excludes", "icon", "bundle"],
|
5
|
-
"properties": {
|
6
|
-
"before_build": {
|
7
|
-
"type": "object",
|
8
|
-
"properties": {
|
9
|
-
"cleanup_patterns": {
|
10
|
-
"type": "array",
|
11
|
-
"items": {
|
12
|
-
"type": "string"
|
13
|
-
},
|
14
|
-
"description": "List of file patterns to clean up in the library folder before building (used to remove files that cannot be excluded through pyinstaller) - default path is site-packages"
|
15
|
-
}
|
16
|
-
}
|
17
|
-
},
|
18
|
-
"name": {
|
19
|
-
"type": "string",
|
20
|
-
"description": "Application name"
|
21
|
-
},
|
22
|
-
"main_script": {
|
23
|
-
"type": "string",
|
24
|
-
"description": "Path to the main Python script"
|
25
|
-
},
|
26
|
-
"datas": {
|
27
|
-
"type": "array",
|
28
|
-
"items": {
|
29
|
-
"type": "array",
|
30
|
-
"minItems": 2,
|
31
|
-
"maxItems": 2,
|
32
|
-
"items": [
|
33
|
-
{ "type": "string" },
|
34
|
-
{ "type": "string" }
|
35
|
-
]
|
36
|
-
},
|
37
|
-
"description": "List of data files to include [source path, destination path]"
|
38
|
-
},
|
39
|
-
"excludes": {
|
40
|
-
"type": "array",
|
41
|
-
"items": {
|
42
|
-
"type": "string"
|
43
|
-
},
|
44
|
-
"description": "List of modules to exclude during build with pyinstaller"
|
45
|
-
},
|
46
|
-
"icon": {
|
47
|
-
"type": "string",
|
48
|
-
"description": "Path to the application icon file"
|
49
|
-
},
|
50
|
-
"bundle": {
|
51
|
-
"type": "object",
|
52
|
-
"properties": {
|
53
|
-
"windows": {
|
54
|
-
"type": "string",
|
55
|
-
"enum": ["onefile", "directory"],
|
56
|
-
"description": "Windows build type"
|
57
|
-
},
|
58
|
-
"macos": {
|
59
|
-
"type": "string",
|
60
|
-
"enum": ["app"],
|
61
|
-
"description": "macOS build type"
|
62
|
-
},
|
63
|
-
"linux": {
|
64
|
-
"type": "string",
|
65
|
-
"enum": ["onefile", "directory"],
|
66
|
-
"description": "Linux build type"
|
67
|
-
}
|
68
|
-
},
|
69
|
-
"required": ["windows", "macos", "linux"],
|
70
|
-
"description": "Build settings for each OS"
|
71
|
-
}
|
72
|
-
}
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
|
+
"type": "object",
|
4
|
+
"required": ["before_build", "name", "main_script", "datas", "excludes", "icon", "bundle"],
|
5
|
+
"properties": {
|
6
|
+
"before_build": {
|
7
|
+
"type": "object",
|
8
|
+
"properties": {
|
9
|
+
"cleanup_patterns": {
|
10
|
+
"type": "array",
|
11
|
+
"items": {
|
12
|
+
"type": "string"
|
13
|
+
},
|
14
|
+
"description": "List of file patterns to clean up in the library folder before building (used to remove files that cannot be excluded through pyinstaller) - default path is site-packages"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"name": {
|
19
|
+
"type": "string",
|
20
|
+
"description": "Application name"
|
21
|
+
},
|
22
|
+
"main_script": {
|
23
|
+
"type": "string",
|
24
|
+
"description": "Path to the main Python script"
|
25
|
+
},
|
26
|
+
"datas": {
|
27
|
+
"type": "array",
|
28
|
+
"items": {
|
29
|
+
"type": "array",
|
30
|
+
"minItems": 2,
|
31
|
+
"maxItems": 2,
|
32
|
+
"items": [
|
33
|
+
{ "type": "string" },
|
34
|
+
{ "type": "string" }
|
35
|
+
]
|
36
|
+
},
|
37
|
+
"description": "List of data files to include [source path, destination path]"
|
38
|
+
},
|
39
|
+
"excludes": {
|
40
|
+
"type": "array",
|
41
|
+
"items": {
|
42
|
+
"type": "string"
|
43
|
+
},
|
44
|
+
"description": "List of modules to exclude during build with pyinstaller"
|
45
|
+
},
|
46
|
+
"icon": {
|
47
|
+
"type": "string",
|
48
|
+
"description": "Path to the application icon file"
|
49
|
+
},
|
50
|
+
"bundle": {
|
51
|
+
"type": "object",
|
52
|
+
"properties": {
|
53
|
+
"windows": {
|
54
|
+
"type": "string",
|
55
|
+
"enum": ["onefile", "directory"],
|
56
|
+
"description": "Windows build type"
|
57
|
+
},
|
58
|
+
"macos": {
|
59
|
+
"type": "string",
|
60
|
+
"enum": ["app"],
|
61
|
+
"description": "macOS build type"
|
62
|
+
},
|
63
|
+
"linux": {
|
64
|
+
"type": "string",
|
65
|
+
"enum": ["onefile", "directory"],
|
66
|
+
"description": "Linux build type"
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"required": ["windows", "macos", "linux"],
|
70
|
+
"description": "Build settings for each OS"
|
71
|
+
}
|
72
|
+
}
|
73
73
|
}
|