effectual 0.3.5__tar.gz → 0.4.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: effectual
3
- Version: 0.3.5
3
+ Version: 0.4.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>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "effectual"
3
- version = "0.3.5"
3
+ version = "0.4.0"
4
4
  description = "A python package/script bundler"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -137,6 +137,8 @@ docstring-code-line-length = "dynamic"
137
137
 
138
138
  [tool.mypy]
139
139
 
140
+ disable_error_code = "name-defined"
141
+
140
142
  warn_unused_configs = true
141
143
  warn_redundant_casts = true
142
144
  warn_unused_ignores = true
@@ -21,14 +21,14 @@ def bundleFiles(
21
21
  compressionLevel: int,
22
22
  minification: bool,
23
23
  ) -> None:
24
- """Bundles dependencies and scripts into a single .py archive
24
+ """Bundles dependencies and scripts into a single .pyz archive
25
25
 
26
26
  Args:
27
27
  sourceDirectory (Path): Source directory which must contain a __main__.py script
28
28
  outputDirectory (Path): Output directory for the bundle
29
29
  outputFileName (str): Name of the output bundle
30
30
  compressionLevel (int): Compression level for the bundle from 0-9
31
- minification (bool): If the dependencies and scripts should be minified
31
+ minification (bool): If the scripts should be minified
32
32
  """
33
33
  outputDirectory.mkdir(parents=True, exist_ok=True)
34
34
  outputPath: Path = outputDirectory / outputFileName
@@ -90,11 +90,12 @@ def dependencies(minify: bool) -> None:
90
90
 
91
91
 
92
92
  def optimizeDependencies(file: Path) -> None:
93
+ stringFile: str = str(file)
93
94
  if (
94
95
  file.suffix in (".pyc", ".pyd", ".exe", ".typed")
95
- or "__pycache__" in str(file)
96
- or ".dist-info" in str(file)
97
- or ".lock" in str(file)
96
+ or "__pycache__" in stringFile
97
+ or ".dist-info" in stringFile
98
+ or ".lock" in stringFile
98
99
  ):
99
100
  try:
100
101
  file.unlink()
@@ -128,7 +129,7 @@ def main() -> None:
128
129
  )
129
130
 
130
131
  uvHashPath: Path = Path("./.effectual_cache/pyprojectHash.toml")
131
- currentHash: dict[str, dict] = dict()
132
+ currentHash: dict[str, dict[str, str]] = dict()
132
133
 
133
134
  startTime = perf_counter()
134
135
 
@@ -139,7 +140,7 @@ def main() -> None:
139
140
 
140
141
  if uvHashPath.exists():
141
142
  with open(uvHashPath, "r") as file:
142
- lastHash: dict = dict(rtoml.load(file)).get("hashes")
143
+ lastHash: dict[Any, Any] = dict(rtoml.load(file)).get("hashes")
143
144
  if currentHash["hashes"] != lastHash:
144
145
  with open(uvHashPath, "w") as file:
145
146
  rtoml.dump(currentHash, file)
@@ -40,12 +40,12 @@ def main() -> None:
40
40
 
41
41
  runCommand = subprocess.Popen(["uv", "run", outputFile], shell=True)
42
42
 
43
- lastHashList: list[str] = getAllHashes(sourceDirectory)
43
+ lastHashSet: set[str] = getAllHashes(sourceDirectory, ".py")
44
44
 
45
45
  while True:
46
- currentHashList: list[str] = getAllHashes(sourceDirectory)
47
- if currentHashList != lastHashList:
48
- lastHashList = currentHashList
46
+ currentHashSet: set[str] = getAllHashes(sourceDirectory, ".py")
47
+ if currentHashSet != lastHashSet:
48
+ lastHashSet = currentHashSet
49
49
  runCommand.kill()
50
50
  runCommand.wait()
51
51
  outputFile.unlink()
@@ -0,0 +1,34 @@
1
+ import hashlib
2
+ from multiprocessing import Pool
3
+ from pathlib import Path
4
+
5
+
6
+ def getFilehash(filePath: Path) -> str:
7
+ """Gets the file hash of a single python script
8
+
9
+ Args:
10
+ filePath (Path): Path to a file
11
+
12
+ Returns:
13
+ str: Hash of the file
14
+ """
15
+ with open(filePath, "rb") as file:
16
+ fileHash = hashlib.sha1(file.read()).hexdigest()
17
+ return fileHash
18
+
19
+
20
+ def getAllHashes(sourceDirectory: Path, fileExtension: str) -> set[str]:
21
+ """Gets all hashes in directory
22
+
23
+ Args:
24
+ sourceDirectory (Path): Path to a folder containing files
25
+
26
+ Returns:
27
+ set[str]: Set containing paths and hashes
28
+ """
29
+
30
+ with Pool() as pool:
31
+ hashList: set[str] = set(
32
+ pool.map(getFilehash, sourceDirectory.glob(f"*.{fileExtension}"))
33
+ )
34
+ return hashList
@@ -1,27 +1,27 @@
1
- version: "3.17"
2
-
3
- tasks:
4
-
5
- dist:
6
- cmds:
7
- - uv sync
8
- - uv lock
9
- - task: check
10
- - uv build
11
- - uv publish
12
-
13
- check:
14
- deps: [lint, format]
15
-
16
- format:
17
- cmds:
18
- - uv run ruff format --config pyproject.toml
19
-
20
- lint:
21
- cmds:
22
- - uv run ruff check --config pyproject.toml
23
-
24
-
25
- type:
26
- cmds:
27
- - uv run mypy src/effectual/*.py
1
+ version: "3.17"
2
+
3
+ tasks:
4
+
5
+ dist:
6
+ cmds:
7
+ - uv sync
8
+ - uv lock
9
+ - task: check
10
+ - uv build
11
+ - uv publish
12
+
13
+ check:
14
+ deps: [lint, format]
15
+
16
+ format:
17
+ cmds:
18
+ - uv run ruff format --config pyproject.toml
19
+
20
+ lint:
21
+ cmds:
22
+ - uv run ruff check --config pyproject.toml
23
+
24
+
25
+ type:
26
+ cmds:
27
+ - uv run mypy src/effectual/*.py
@@ -24,7 +24,7 @@ wheels = [
24
24
 
25
25
  [[package]]
26
26
  name = "effectual"
27
- version = "0.3.5"
27
+ version = "0.4.0"
28
28
  source = { editable = "." }
29
29
  dependencies = [
30
30
  { name = "click" },
@@ -1,32 +0,0 @@
1
- import hashlib
2
- from multiprocessing import Pool
3
- from pathlib import Path
4
-
5
-
6
- def getFilehash(filePath: Path) -> str:
7
- """Gets the file hash of a single python script
8
-
9
- Args:
10
- filePath (Path): Path to the python script
11
-
12
- Returns:
13
- str: Hash of the python script
14
- """
15
- with open(filePath, "rb") as file:
16
- fileHash = hashlib.sha256(file.read()).hexdigest()
17
- return fileHash
18
-
19
-
20
- def getAllHashes(sourceDirectory: Path) -> list[str]:
21
- """Gets all hashes in directory
22
-
23
- Args:
24
- sourceDirectory (Path): Path to the python scripts
25
-
26
- Returns:
27
- dict[str]: Dictionary containing paths and hashes
28
- """
29
-
30
- with Pool() as pool:
31
- hashList: list[str] = pool.map(getFilehash, sourceDirectory.glob("*.py"))
32
- return hashList
File without changes
File without changes
File without changes
File without changes