effectual 0.5.4__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 CHANGED
@@ -8,7 +8,10 @@ def main() -> None:
8
8
 
9
9
  @click.command("dist")
10
10
  def dist() -> None:
11
- """Bundles your source directory."""
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
- """Bundles your source directory."""
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 .minifier import minifyFile, minifyToString
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
- totalSize: int = int(0)
47
- for cachedFile in cachePath.rglob("*"):
48
- if cachedFile.is_dir() and not any(cachedFile.iterdir()):
49
- continue
50
- totalSize += cachedFile.stat().st_size
51
- arcName = cachedFile.relative_to(cachePath)
52
- bundler.write(cachedFile, arcname=arcName)
53
-
54
- print(f"{tagColor('bundling')} || uv dependencies {folderColor(totalSize)}")
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)}")
@@ -67,26 +70,34 @@ def bundleFiles(
67
70
  def dependencies(minify: bool) -> None:
68
71
  packages: list[str] = (
69
72
  loadToml("./pyproject.toml").get("project").get("dependencies")
70
- ) # type: ignore
73
+ )
71
74
 
72
- arguments: list[str] = ["--no-compile", "--quiet", "--no-binary=none", "--no-cache"]
75
+ if len(packages) != 0:
76
+ arguments: list[str] = [
77
+ "--no-compile",
78
+ "--quiet",
79
+ "--no-binary=none",
80
+ "--no-cache",
81
+ ]
73
82
 
74
- pathToInstallTo: str = "./.effectual_cache/cachedPackages"
75
- argumentString: str = " ".join(arguments)
83
+ pathToInstallTo: str = "./.effectual_cache/cachedPackages"
84
+ argumentString: str = " ".join(arguments)
76
85
 
77
- if Path(pathToInstallTo).exists():
78
- shutil.rmtree(pathToInstallTo)
86
+ if Path(pathToInstallTo).exists():
87
+ shutil.rmtree(pathToInstallTo)
79
88
 
80
- for key in packages:
81
- print(f"{tagColor('installing')} || {key}")
82
- os.system(f'uv pip install "{key}" {argumentString} --target {pathToInstallTo}')
89
+ for key in packages:
90
+ print(f"{tagColor('installing')} || {key}")
91
+ os.system(
92
+ f'uv pip install "{key}" {argumentString} --target {pathToInstallTo}'
93
+ )
83
94
 
84
- print(f"{tagColor('optimizing')} || {', '.join(packages)}")
95
+ print(f"{tagColor('optimizing')} || {', '.join(packages)}")
85
96
 
86
- multiprocessing = importlib.import_module("multiprocessing")
97
+ multiprocessing = importlib.import_module("multiprocessing")
87
98
 
88
- with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
89
- pool.map(optimizeDependencies, Path(pathToInstallTo).rglob("*"))
99
+ with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
100
+ pool.map(optimizeDependencies, Path(pathToInstallTo).rglob("*"))
90
101
 
91
102
 
92
103
  def optimizeDependencies(file: Path) -> None:
@@ -120,8 +131,7 @@ def main() -> None:
120
131
  compressionLevel: int = max(
121
132
  0, min(9, configData.get("compressionLevel", 5))
122
133
  ) # Default level if not set
123
- global minification
124
- minification = configData.get("minification", True)
134
+ minification: bool = configData.get("minification", True)
125
135
 
126
136
  if not sourceDirectory.is_dir():
127
137
  raise RuntimeError(
effectual/config.py CHANGED
@@ -1,10 +1,11 @@
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) -> dict[str, Any]:
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:
@@ -19,14 +20,14 @@ def loadToml(tomlFile: str) -> 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)) # type: ignore
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
- return rtoml.dump(hashesToDump, file, pretty=False)
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: effectual
3
- Version: 0.5.4
3
+ Version: 0.5.5
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>
@@ -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,,
@@ -1,11 +0,0 @@
1
- effectual/__init__.py,sha256=9hA5S-390BtY7m-NojGHioaBJJ8vEM3IXuMvmzWBv0E,407
2
- effectual/build.py,sha256=Ub_EL71GcclEoG0zJz20aomm-8iwOFxh6wS01W5PlK8,5556
3
- effectual/colors.py,sha256=na7SEUSXM7aHvEKeIAn5shrZJtrBYq_ZUp121GRO_PQ,1411
4
- effectual/config.py,sha256=3vMO_r9jf3GX7VMnZBbedk-g9rgUkfwa57bpq7yLQiQ,1767
5
- effectual/developer.py,sha256=ERbmZuaUzSVzKgWNUWMa1H7K39xfBNeHolUEdUKcOWc,2052
6
- effectual/minifier.py,sha256=7GHgQWzin2J1W62yMReHXaYIChXc3f0rNJA-yY4LDEI,1313
7
- effectual-0.5.4.dist-info/METADATA,sha256=S46Zge-cvbJWjq5mcxt_CW5P953iEnDf1pYROylBqIE,2560
8
- effectual-0.5.4.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
9
- effectual-0.5.4.dist-info/entry_points.txt,sha256=1W7EjlLZkw_Wz8V1SgdzzDis-CRE5IINyg74upsB0zU,40
10
- effectual-0.5.4.dist-info/licenses/LICENSE,sha256=RrVXS_K_FctToNx9BLuZm9vbcpTi3PHNzWMaz7QyVeg,1082
11
- effectual-0.5.4.dist-info/RECORD,,
File without changes