effectual 0.7.12__tar.gz → 0.8.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: effectual
3
- Version: 0.7.12
3
+ Version: 0.8.1
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>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "effectual"
3
- version = "0.7.12"
3
+ version = "0.8.1"
4
4
  description = "A python package/script bundler"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,4 @@
1
- import hashlib
2
1
  import os
3
- import shutil
4
2
  import zipfile
5
3
  from pathlib import Path
6
4
  from time import perf_counter
@@ -8,6 +6,7 @@ from typing import Any
8
6
 
9
7
  from .colors import completeColor, fileColor, folderColor, tagColor
10
8
  from .config import dumpHashes, loadConfig, loadToml
9
+ from .lib import getHash
11
10
  from .transformations import minifyFile, minifyToString
12
11
 
13
12
 
@@ -91,7 +90,7 @@ def dependencies() -> None:
91
90
  argumentString: str = " ".join(arguments)
92
91
 
93
92
  if Path(pathToInstallTo).exists():
94
- shutil.rmtree(pathToInstallTo)
93
+ __import__("shutil").rmtree(pathToInstallTo)
95
94
 
96
95
  for key in packages:
97
96
  print(f"{tagColor('installing')} || {key}")
@@ -100,20 +99,6 @@ def dependencies() -> None:
100
99
  )
101
100
 
102
101
 
103
- def getHash(filePath: Path) -> str:
104
- """Gets the hash of a single file
105
-
106
- Args:
107
- filePath (Path): Path to the file
108
-
109
- Returns:
110
- str: String of the hash
111
- """
112
- with open(filePath, "rb") as file:
113
- fileHash = hashlib.sha1(file.read()).hexdigest()
114
- return fileHash
115
-
116
-
117
102
  def main() -> None:
118
103
  """Entrypoint
119
104
 
@@ -146,7 +131,7 @@ def main() -> None:
146
131
  currentHash["hashes"]["pyproject"] = getHash(Path("./pyproject.toml"))
147
132
  currentHash["hashes"]["lock"] = getHash(Path("./uv.lock"))
148
133
 
149
- freshHash: bool = False
134
+ freshHash: bool = True # Whether or not to re-optimize deps
150
135
 
151
136
  if uvHashPath.exists():
152
137
  lastHash: dict[str, Any] = loadToml(uvHashPath).get("hashes")
@@ -154,14 +139,12 @@ def main() -> None:
154
139
  with open(uvHashPath, "w") as file:
155
140
  dumpHashes(currentHash, file)
156
141
  dependencies()
157
- freshHash = True
158
142
  else:
159
143
  freshHash = False
160
144
  else:
161
145
  with open(uvHashPath, "x") as file:
162
146
  dumpHashes(currentHash, file)
163
147
  dependencies()
164
- freshHash = True
165
148
 
166
149
  bundleFiles(
167
150
  sourceDirectory,
@@ -176,5 +159,5 @@ def main() -> None:
176
159
  print(completeColor(f"Completed in {endTime - startTime:.4f}s"))
177
160
 
178
161
 
179
- if "__main__" in __name__:
162
+ if "__main__" == __name__:
180
163
  main()
@@ -1,4 +1,4 @@
1
- import io
1
+ from io import TextIOWrapper
2
2
  from pathlib import Path
3
3
  from typing import Any
4
4
 
@@ -37,7 +37,9 @@ def loadConfig(configPath: str = "./pyproject.toml") -> dict[Any, Any]:
37
37
  dict: Dictionary containing effectual config
38
38
  """
39
39
  configData: dict[str, Any] = loadToml(configPath)
40
- if configData is None:
40
+ try:
41
+ configData = configData["tool"]["effectual"]
42
+ except KeyError:
41
43
  configData = {
42
44
  "sourceDirectory": "./src/",
43
45
  "outputDirectory": "./dist/",
@@ -45,13 +47,11 @@ def loadConfig(configPath: str = "./pyproject.toml") -> dict[Any, Any]:
45
47
  "minification": True,
46
48
  "compressionLevel": 5,
47
49
  }
48
- else:
49
- configData = configData.get("tool").get("effectual")
50
50
 
51
51
  return configData
52
52
 
53
53
 
54
- def dumpHashes(hashesToDump: dict[str, dict[str, str]], file: io.TextIOWrapper) -> None:
54
+ def dumpHashes(hashesToDump: dict[str, dict[str, str]], file: TextIOWrapper) -> None:
55
55
  """Dumps hashes in a specific format to a toml file
56
56
 
57
57
  Args:
@@ -0,0 +1,16 @@
1
+ from hashlib import md5
2
+ from pathlib import Path
3
+
4
+
5
+ def getHash(filePath: Path) -> str:
6
+ """Creates an MD5 Hash from a file
7
+
8
+ Args:
9
+ filePath (Path): Path to the file
10
+
11
+ Returns:
12
+ str: String of the hash
13
+ """
14
+ with open(filePath, "rb") as file:
15
+ fileHash = md5(file.read()).hexdigest()
16
+ return fileHash
@@ -164,7 +164,7 @@ wheels = [
164
164
 
165
165
  [[package]]
166
166
  name = "effectual"
167
- version = "0.7.12"
167
+ version = "0.8.1"
168
168
  source = { editable = "." }
169
169
  dependencies = [
170
170
  { name = "click" },
File without changes
File without changes
File without changes
File without changes
File without changes