effectual 0.5.3__py3-none-any.whl → 0.5.5__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- effectual/__init__.py +8 -2
- effectual/build.py +45 -35
- effectual/config.py +6 -5
- effectual/developer.py +1 -1
- {effectual-0.5.3.dist-info → effectual-0.5.5.dist-info}/METADATA +1 -1
- effectual-0.5.5.dist-info/RECORD +11 -0
- effectual-0.5.3.dist-info/RECORD +0 -11
- /effectual/{minifier.py → transformations.py} +0 -0
- {effectual-0.5.3.dist-info → effectual-0.5.5.dist-info}/WHEEL +0 -0
- {effectual-0.5.3.dist-info → effectual-0.5.5.dist-info}/entry_points.txt +0 -0
- {effectual-0.5.3.dist-info → effectual-0.5.5.dist-info}/licenses/LICENSE +0 -0
effectual/__init__.py
CHANGED
@@ -8,7 +8,10 @@ def main() -> None:
|
|
8
8
|
|
9
9
|
@click.command("dist")
|
10
10
|
def dist() -> None:
|
11
|
-
"""
|
11
|
+
"""
|
12
|
+
Bundles your source directory
|
13
|
+
into a production bundle
|
14
|
+
"""
|
12
15
|
from . import build
|
13
16
|
|
14
17
|
build.main()
|
@@ -16,7 +19,10 @@ def dist() -> None:
|
|
16
19
|
|
17
20
|
@click.command("dev")
|
18
21
|
def dev() -> None:
|
19
|
-
"""
|
22
|
+
"""
|
23
|
+
Bundles your source directory
|
24
|
+
into a developer bundle
|
25
|
+
"""
|
20
26
|
from . import developer
|
21
27
|
|
22
28
|
developer.main()
|
effectual/build.py
CHANGED
@@ -10,15 +10,15 @@ from watch_lite import getHash
|
|
10
10
|
|
11
11
|
from .colors import completeColor, fileColor, folderColor, tagColor
|
12
12
|
from .config import dumpHashes, loadConfig, loadToml
|
13
|
-
from .
|
13
|
+
from .transformations import minifyFile, minifyToString
|
14
14
|
|
15
15
|
|
16
16
|
def bundleFiles(
|
17
|
-
sourceDirectory: Path,
|
18
|
-
outputDirectory: Path,
|
19
|
-
outputFileName: str,
|
20
|
-
compressionLevel: int,
|
21
|
-
minification: bool,
|
17
|
+
sourceDirectory: Path = Path("./src/"),
|
18
|
+
outputDirectory: Path = Path("./out"),
|
19
|
+
outputFileName: str = "bundle.pyz",
|
20
|
+
compressionLevel: int = 5,
|
21
|
+
minification: bool = True,
|
22
22
|
) -> None:
|
23
23
|
"""Bundles dependencies and scripts into a single .pyz archive
|
24
24
|
|
@@ -42,16 +42,19 @@ def bundleFiles(
|
|
42
42
|
compression=zipfile.ZIP_DEFLATED,
|
43
43
|
) as bundler:
|
44
44
|
cachePath: Path = Path("./.effectual_cache/cachedPackages")
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
45
|
+
if cachePath.exists():
|
46
|
+
if os.listdir(cachePath):
|
47
|
+
totalSize: int = int(0)
|
48
|
+
for cachedFile in cachePath.rglob("*"):
|
49
|
+
if cachedFile.is_dir() and not any(cachedFile.iterdir()):
|
50
|
+
continue
|
51
|
+
totalSize += cachedFile.stat().st_size
|
52
|
+
arcName = cachedFile.relative_to(cachePath)
|
53
|
+
bundler.write(cachedFile, arcname=arcName)
|
54
|
+
|
55
|
+
print(
|
56
|
+
f"{tagColor('bundling')} || uv dependencies {folderColor(totalSize)}" # noqa: E501
|
57
|
+
)
|
55
58
|
|
56
59
|
for pyFile in sourceDirectory.rglob("*.py"):
|
57
60
|
print(f"{tagColor('bundling')} || {pyFile.name} {fileColor(pyFile)}")
|
@@ -65,27 +68,36 @@ def bundleFiles(
|
|
65
68
|
|
66
69
|
|
67
70
|
def dependencies(minify: bool) -> None:
|
68
|
-
|
69
|
-
|
71
|
+
packages: list[str] = (
|
72
|
+
loadToml("./pyproject.toml").get("project").get("dependencies")
|
73
|
+
)
|
70
74
|
|
71
|
-
|
75
|
+
if len(packages) != 0:
|
76
|
+
arguments: list[str] = [
|
77
|
+
"--no-compile",
|
78
|
+
"--quiet",
|
79
|
+
"--no-binary=none",
|
80
|
+
"--no-cache",
|
81
|
+
]
|
72
82
|
|
73
|
-
|
74
|
-
|
83
|
+
pathToInstallTo: str = "./.effectual_cache/cachedPackages"
|
84
|
+
argumentString: str = " ".join(arguments)
|
75
85
|
|
76
|
-
|
77
|
-
|
86
|
+
if Path(pathToInstallTo).exists():
|
87
|
+
shutil.rmtree(pathToInstallTo)
|
78
88
|
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
for key in packages:
|
90
|
+
print(f"{tagColor('installing')} || {key}")
|
91
|
+
os.system(
|
92
|
+
f'uv pip install "{key}" {argumentString} --target {pathToInstallTo}'
|
93
|
+
)
|
82
94
|
|
83
|
-
|
95
|
+
print(f"{tagColor('optimizing')} || {', '.join(packages)}")
|
84
96
|
|
85
|
-
|
97
|
+
multiprocessing = importlib.import_module("multiprocessing")
|
86
98
|
|
87
|
-
|
88
|
-
|
99
|
+
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
|
100
|
+
pool.map(optimizeDependencies, Path(pathToInstallTo).rglob("*"))
|
89
101
|
|
90
102
|
|
91
103
|
def optimizeDependencies(file: Path) -> None:
|
@@ -111,7 +123,7 @@ def main() -> None:
|
|
111
123
|
RuntimeError: In the event there is no source directory
|
112
124
|
"""
|
113
125
|
|
114
|
-
configData: dict[
|
126
|
+
configData: dict[str, Any] = loadConfig("./pyproject.toml")
|
115
127
|
|
116
128
|
sourceDirectory: Path = Path(configData.get("sourceDirectory", "src/"))
|
117
129
|
outputDirectory: Path = Path(configData.get("outputDirectory", "out/"))
|
@@ -119,8 +131,7 @@ def main() -> None:
|
|
119
131
|
compressionLevel: int = max(
|
120
132
|
0, min(9, configData.get("compressionLevel", 5))
|
121
133
|
) # Default level if not set
|
122
|
-
|
123
|
-
minification = configData.get("minification", True)
|
134
|
+
minification: bool = configData.get("minification", True)
|
124
135
|
|
125
136
|
if not sourceDirectory.is_dir():
|
126
137
|
raise RuntimeError(
|
@@ -138,8 +149,7 @@ def main() -> None:
|
|
138
149
|
currentHash["hashes"]["lock"] = getHash("./uv.lock")
|
139
150
|
|
140
151
|
if uvHashPath.exists():
|
141
|
-
|
142
|
-
lastHash: dict[Any, Any] = loadToml(file).get("hashes")
|
152
|
+
lastHash: dict[str, Any] = loadToml(uvHashPath).get("hashes")
|
143
153
|
if currentHash["hashes"] != lastHash:
|
144
154
|
with open(uvHashPath, "w") as file:
|
145
155
|
dumpHashes(currentHash, file)
|
effectual/config.py
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
import io
|
2
|
+
from pathlib import Path
|
2
3
|
from typing import Any
|
3
4
|
|
4
5
|
import rtoml
|
5
6
|
|
6
7
|
|
7
|
-
def loadToml(tomlFile: str |
|
8
|
+
def loadToml(tomlFile: str | Path) -> dict[str, Any]:
|
8
9
|
"""Loads a toml file from a specific path to a dictionary
|
9
10
|
|
10
11
|
Args:
|
11
|
-
pathToToml (str
|
12
|
+
pathToToml (str): Path of a toml file
|
12
13
|
|
13
14
|
Raises:
|
14
15
|
RuntimeError: Toml file is incorrectly configured
|
@@ -19,14 +20,14 @@ def loadToml(tomlFile: str | io.TextIOWrapper) -> dict[str, Any]:
|
|
19
20
|
"""
|
20
21
|
try:
|
21
22
|
with open(tomlFile, "r", encoding="utf-8") as file:
|
22
|
-
return dict(rtoml.load(file))
|
23
|
+
return dict(rtoml.load(file))
|
23
24
|
except ValueError as e:
|
24
25
|
raise RuntimeError(f"Invalid TOML in {tomlFile}: {e}")
|
25
26
|
except FileNotFoundError:
|
26
27
|
raise RuntimeError(f"TOML file {tomlFile} not found.")
|
27
28
|
|
28
29
|
|
29
|
-
def loadConfig(configPath: str) -> dict[Any, Any]:
|
30
|
+
def loadConfig(configPath: str = "./pyproject.toml") -> dict[Any, Any]:
|
30
31
|
"""Loads effectual config from a file
|
31
32
|
|
32
33
|
Args:
|
@@ -57,4 +58,4 @@ def dumpHashes(hashesToDump: dict[str, dict[str, str]], file: io.TextIOWrapper)
|
|
57
58
|
hashesToDump (dict[str, dict[str, str]]): Dictionary of hashes to dump as toml
|
58
59
|
file (_type_): File object
|
59
60
|
"""
|
60
|
-
|
61
|
+
rtoml.dump(hashesToDump, file, pretty=False)
|
effectual/developer.py
CHANGED
@@ -46,10 +46,10 @@ def main() -> None:
|
|
46
46
|
while True:
|
47
47
|
currentHashSet: set[str] = getAllHashes(str(sourceDirectory))
|
48
48
|
if currentHashSet != lastHashSet:
|
49
|
-
lastHashSet = currentHashSet
|
50
49
|
runCommand.kill()
|
51
50
|
runCommand.wait()
|
52
51
|
outputFile.unlink()
|
52
|
+
lastHashSet = currentHashSet
|
53
53
|
print(f"{tagColor('reloaded')} || file change detected")
|
54
54
|
bundle(sourceDirectory, outputFile)
|
55
55
|
runCommand = subprocess.Popen(["uv", "run", outputFile], shell=True)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
effectual/__init__.py,sha256=Hg_RSVgpLZvaeBUqt5uL_r5YIDsVdKPcFE2L5WJVYbM,482
|
2
|
+
effectual/build.py,sha256=id8BZ4ZEs1VbpL_gEz3iXk60PKKHIwM5FGjoFB5YPeI,5946
|
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-0.5.5.dist-info/METADATA,sha256=7PFhRgidBjPr0-soAFbNbvG1aikUp-kNJX6-_1j5jH8,2560
|
8
|
+
effectual-0.5.5.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
9
|
+
effectual-0.5.5.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
|
10
|
+
effectual-0.5.5.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
|
11
|
+
effectual-0.5.5.dist-info/RECORD,,
|
effectual-0.5.3.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
effectual/__init__.py,sha256=9hA5S-390BtY7m-NojGHioaBJJ8vEM3IXuMvmzWBv0E,407
|
2
|
-
effectual/build.py,sha256=PfnE6A8OfrVNV5AFxwqQIpNwr7OxbfhjkIzkcwSRM0M,5638
|
3
|
-
effectual/colors.py,sha256=na7SEUSXM7aHvEKeIAn5shrZJtrBYq_ZUp121GRO_PQ,1411
|
4
|
-
effectual/config.py,sha256=HthkvUSOvkEN9N2_Eg5z4OU1jLLixLB5mmv-Npf3f4o,1815
|
5
|
-
effectual/developer.py,sha256=ERbmZuaUzSVzKgWNUWMa1H7K39xfBNeHolUEdUKcOWc,2052
|
6
|
-
effectual/minifier.py,sha256=7GHgQWzin2J1W62yMReHXaYIChXc3f0rNJA-yY4LDEI,1313
|
7
|
-
effectual-0.5.3.dist-info/METADATA,sha256=J5La4SFmCBy5DYzkzagOQqUbysivbsoknc1RAV_vV-Y,2560
|
8
|
-
effectual-0.5.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
9
|
-
effectual-0.5.3.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
|
10
|
-
effectual-0.5.3.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
|
11
|
-
effectual-0.5.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|