effectual 0.5.6__py3-none-any.whl → 0.6.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- effectual/build.py +27 -18
- effectual/developer.py +0 -1
- {effectual-0.5.6.dist-info → effectual-0.6.0.dist-info}/METADATA +2 -2
- effectual-0.6.0.dist-info/RECORD +11 -0
- effectual/treeshake.py +0 -19
- effectual-0.5.6.dist-info/RECORD +0 -12
- {effectual-0.5.6.dist-info → effectual-0.6.0.dist-info}/WHEEL +0 -0
- {effectual-0.5.6.dist-info → effectual-0.6.0.dist-info}/entry_points.txt +0 -0
- {effectual-0.5.6.dist-info → effectual-0.6.0.dist-info}/licenses/LICENSE +0 -0
effectual/build.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import importlib
|
2
1
|
import os
|
3
2
|
import shutil
|
4
3
|
import zipfile
|
@@ -10,8 +9,7 @@ from watch_lite import getHash
|
|
10
9
|
|
11
10
|
from .colors import completeColor, fileColor, folderColor, tagColor
|
12
11
|
from .config import dumpHashes, loadConfig, loadToml
|
13
|
-
from .transformations import minifyToString
|
14
|
-
from .treeshake import cleanPackages
|
12
|
+
from .transformations import minifyFile, minifyToString
|
15
13
|
|
16
14
|
|
17
15
|
def bundleFiles(
|
@@ -20,6 +18,7 @@ def bundleFiles(
|
|
20
18
|
outputFileName: str = "bundle.pyz",
|
21
19
|
compressionLevel: int = 5,
|
22
20
|
minification: bool = True,
|
21
|
+
freshHash: bool = False,
|
23
22
|
) -> None:
|
24
23
|
"""Bundles dependencies and scripts into a single .pyz archive
|
25
24
|
|
@@ -29,13 +28,11 @@ def bundleFiles(
|
|
29
28
|
outputFileName (str): Name of the output bundle
|
30
29
|
compressionLevel (int): Compression level for the bundle from 0-9
|
31
30
|
minification (bool): If the scripts should be minified
|
31
|
+
freshHash (bool): Is the pyproject hash different then previously?
|
32
32
|
"""
|
33
33
|
outputDirectory.mkdir(parents=True, exist_ok=True)
|
34
34
|
outputPath: Path = outputDirectory / outputFileName
|
35
35
|
|
36
|
-
if outputPath.exists():
|
37
|
-
outputPath.unlink()
|
38
|
-
|
39
36
|
with zipfile.ZipFile(
|
40
37
|
outputPath,
|
41
38
|
"w",
|
@@ -50,8 +47,19 @@ def bundleFiles(
|
|
50
47
|
if cachedFile.is_dir() and not any(cachedFile.iterdir()):
|
51
48
|
continue
|
52
49
|
totalSize += cachedFile.stat().st_size
|
53
|
-
|
54
|
-
|
50
|
+
stringCachedFile = str(cachedFile)
|
51
|
+
if (
|
52
|
+
cachedFile.suffix in (".pyc", ".pyd", ".exe", ".typed")
|
53
|
+
or "__pycache__" in stringCachedFile
|
54
|
+
or ".dist-info" in stringCachedFile
|
55
|
+
or ".lock" in stringCachedFile
|
56
|
+
):
|
57
|
+
continue
|
58
|
+
else:
|
59
|
+
if cachedFile.suffix == ".py" and minification and freshHash:
|
60
|
+
minifyFile(cachedFile)
|
61
|
+
arcName: str = str(cachedFile.relative_to(cachePath))
|
62
|
+
bundler.write(cachedFile, arcname=arcName)
|
55
63
|
|
56
64
|
print(
|
57
65
|
f"{tagColor('bundling')} || uv dependencies {folderColor(totalSize)}" # noqa: E501
|
@@ -68,7 +76,8 @@ def bundleFiles(
|
|
68
76
|
print(f"{tagColor('OUTPUT')} || {outputFileName} {fileColor(outputPath)}")
|
69
77
|
|
70
78
|
|
71
|
-
def dependencies(
|
79
|
+
def dependencies() -> None:
|
80
|
+
"""Installs relevant dependencies"""
|
72
81
|
packages: list[str] = (
|
73
82
|
loadToml("./pyproject.toml").get("project").get("dependencies")
|
74
83
|
)
|
@@ -88,13 +97,6 @@ def dependencies(minify: bool) -> None:
|
|
88
97
|
f'uv pip install "{key}" {argumentString} --target {pathToInstallTo}'
|
89
98
|
)
|
90
99
|
|
91
|
-
print(f"{tagColor('optimizing')} || {', '.join(packages)}")
|
92
|
-
|
93
|
-
multiprocessing = importlib.import_module("multiprocessing")
|
94
|
-
|
95
|
-
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
|
96
|
-
pool.map(cleanPackages, Path(pathToInstallTo).rglob("*"))
|
97
|
-
|
98
100
|
|
99
101
|
def main() -> None:
|
100
102
|
"""Entrypoint
|
@@ -128,16 +130,22 @@ def main() -> None:
|
|
128
130
|
currentHash["hashes"]["pyproject"] = getHash("./pyproject.toml")
|
129
131
|
currentHash["hashes"]["lock"] = getHash("./uv.lock")
|
130
132
|
|
133
|
+
freshHash: bool = False
|
134
|
+
|
131
135
|
if uvHashPath.exists():
|
132
136
|
lastHash: dict[str, Any] = loadToml(uvHashPath).get("hashes")
|
133
137
|
if currentHash["hashes"] != lastHash:
|
134
138
|
with open(uvHashPath, "w") as file:
|
135
139
|
dumpHashes(currentHash, file)
|
136
|
-
dependencies(
|
140
|
+
dependencies()
|
141
|
+
freshHash = True
|
142
|
+
else:
|
143
|
+
freshHash = False
|
137
144
|
else:
|
138
145
|
with open(uvHashPath, "x") as file:
|
139
146
|
dumpHashes(currentHash, file)
|
140
|
-
dependencies(
|
147
|
+
dependencies()
|
148
|
+
freshHash = True
|
141
149
|
|
142
150
|
bundleFiles(
|
143
151
|
sourceDirectory,
|
@@ -145,6 +153,7 @@ def main() -> None:
|
|
145
153
|
outputFileName,
|
146
154
|
compressionLevel,
|
147
155
|
minification,
|
156
|
+
freshHash,
|
148
157
|
)
|
149
158
|
endTime = perf_counter()
|
150
159
|
|
effectual/developer.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: effectual
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.6.0
|
4
4
|
Summary: A python package/script bundler
|
5
5
|
Project-URL: Homepage, https://github.com/effectualpy/effectual
|
6
6
|
Author-email: jake <jakewdr@proton.me>
|
@@ -53,7 +53,7 @@ sourceDirectory = "./src/"
|
|
53
53
|
outputDirectory = "./dist/"
|
54
54
|
outputFileName = "bundle.pyz"
|
55
55
|
minification = true
|
56
|
-
compressionLevel=5
|
56
|
+
compressionLevel = 5
|
57
57
|
```
|
58
58
|
|
59
59
|
Note you must have a \_\_main\_\_.py entrypoint for this to work
|
@@ -0,0 +1,11 @@
|
|
1
|
+
effectual/__init__.py,sha256=Hg_RSVgpLZvaeBUqt5uL_r5YIDsVdKPcFE2L5WJVYbM,482
|
2
|
+
effectual/build.py,sha256=XzpbgcPgb3OKA0dlFfkKu7SRN8Ihj9lrHQ8uT-PWTk8,5895
|
3
|
+
effectual/colors.py,sha256=na7SEUSXM7aHvEKeIAn5shrZJtrBYq_ZUp121GRO_PQ,1411
|
4
|
+
effectual/config.py,sha256=Z99V7AnJpSWuo-aEz10TDj5BAaT7tboGJUjggj-HQh4,1798
|
5
|
+
effectual/developer.py,sha256=ekwlqvrOlX574aTdW0_kobu5f1x2UBspnhFAVitsV1k,2019
|
6
|
+
effectual/transformations.py,sha256=7GHgQWzin2J1W62yMReHXaYIChXc3f0rNJA-yY4LDEI,1313
|
7
|
+
effectual-0.6.0.dist-info/METADATA,sha256=zsNMMpKCCl4ie9PyV9yXnMXzNHUyp_d44JygXvBc1F0,2589
|
8
|
+
effectual-0.6.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
9
|
+
effectual-0.6.0.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
|
10
|
+
effectual-0.6.0.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
|
11
|
+
effectual-0.6.0.dist-info/RECORD,,
|
effectual/treeshake.py
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
from pathlib import Path
|
2
|
-
|
3
|
-
from transformations import minifyFile
|
4
|
-
|
5
|
-
|
6
|
-
def cleanPackages(file: Path) -> None:
|
7
|
-
stringFile: str = str(file)
|
8
|
-
if (
|
9
|
-
file.suffix in (".pyc", ".pyd", ".exe", ".typed")
|
10
|
-
or "__pycache__" in stringFile
|
11
|
-
or ".dist-info" in stringFile
|
12
|
-
or ".lock" in stringFile
|
13
|
-
):
|
14
|
-
try:
|
15
|
-
file.unlink()
|
16
|
-
except PermissionError:
|
17
|
-
pass
|
18
|
-
elif file.suffix == ".py":
|
19
|
-
minifyFile(file)
|
effectual-0.5.6.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
effectual/__init__.py,sha256=Hg_RSVgpLZvaeBUqt5uL_r5YIDsVdKPcFE2L5WJVYbM,482
|
2
|
-
effectual/build.py,sha256=c1GyLhIqybBhED8eou8B7GOXwpmeSWvxpv4PBkYgLtQ,5463
|
3
|
-
effectual/colors.py,sha256=na7SEUSXM7aHvEKeIAn5shrZJtrBYq_ZUp121GRO_PQ,1411
|
4
|
-
effectual/config.py,sha256=Z99V7AnJpSWuo-aEz10TDj5BAaT7tboGJUjggj-HQh4,1798
|
5
|
-
effectual/developer.py,sha256=D_KX6YYWgHF5b6ri-48ai1RqxqiIqZ0Rw-dVHG9NLHE,2052
|
6
|
-
effectual/transformations.py,sha256=7GHgQWzin2J1W62yMReHXaYIChXc3f0rNJA-yY4LDEI,1313
|
7
|
-
effectual/treeshake.py,sha256=VQCFFbS9DF7824Qwl8oIBTcRMJoyYi5LOdXlAA9vo2g,485
|
8
|
-
effectual-0.5.6.dist-info/METADATA,sha256=Q-DezI6eEDCfqYpjMFsth5F00JFXHw-u3FkOXpzpcqM,2587
|
9
|
-
effectual-0.5.6.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
10
|
-
effectual-0.5.6.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
|
11
|
-
effectual-0.5.6.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
|
12
|
-
effectual-0.5.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|