effectual 0.3.5__tar.gz → 0.5.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.5.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>
@@ -18,6 +18,7 @@ Requires-Dist: python-minifier>=2.11.3
18
18
  Requires-Dist: rtoml>=0.11.0
19
19
  Requires-Dist: ruff>=0.8.0
20
20
  Requires-Dist: termcolor>=2.4.0
21
+ Requires-Dist: watch-lite>=0.1.1
21
22
  Description-Content-Type: text/markdown
22
23
 
23
24
  # effectual
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "effectual"
3
- version = "0.3.5"
3
+ version = "0.5.0"
4
4
  description = "A python package/script bundler"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -28,6 +28,7 @@ dependencies = [
28
28
  "rtoml>=0.11.0",
29
29
  "ruff>=0.8.0",
30
30
  "termcolor>=2.4.0",
31
+ "watch-lite>=0.1.1",
31
32
  ]
32
33
 
33
34
  [project.urls]
@@ -137,6 +138,8 @@ docstring-code-line-length = "dynamic"
137
138
 
138
139
  [tool.mypy]
139
140
 
141
+ disable_error_code = "name-defined"
142
+
140
143
  warn_unused_configs = true
141
144
  warn_redundant_casts = true
142
145
  warn_unused_ignores = true
@@ -5,12 +5,12 @@ import zipfile
5
5
  from pathlib import Path
6
6
  from time import perf_counter
7
7
  from typing import Any
8
+ from watch_lite import getHash
8
9
 
9
10
  import rtoml
10
11
 
11
12
  from .colors import completeColor, fileColor, folderColor, tagColor
12
13
  from .config import loadConfig
13
- from .fileHash import getFilehash
14
14
  from .minifier import minifyFile, minifyToString
15
15
 
16
16
 
@@ -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,18 +129,18 @@ 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
 
135
136
  Path("./.effectual_cache/").mkdir(parents=True, exist_ok=True)
136
137
  currentHash["hashes"] = dict()
137
- currentHash["hashes"]["pyproject"] = getFilehash(Path("./pyproject.toml"))
138
- currentHash["hashes"]["lock"] = getFilehash(Path("./uv.lock"))
138
+ currentHash["hashes"]["pyproject"] = getHash("./pyproject.toml")
139
+ currentHash["hashes"]["lock"] = getHash("./uv.lock")
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)
@@ -3,10 +3,10 @@ import time
3
3
  import zipfile
4
4
  from pathlib import Path
5
5
  from typing import Any
6
+ from watch_lite import getAllHashes
6
7
 
7
8
  from .colors import completeColor, fileColor, tagColor
8
9
  from .config import loadConfig
9
- from .fileHash import getAllHashes
10
10
 
11
11
 
12
12
  def bundle(sourceDirectory: Path, outputFile: Path) -> None:
@@ -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" },
@@ -32,6 +32,7 @@ dependencies = [
32
32
  { name = "rtoml" },
33
33
  { name = "ruff" },
34
34
  { name = "termcolor" },
35
+ { name = "watch-lite" },
35
36
  ]
36
37
 
37
38
  [package.dev-dependencies]
@@ -47,6 +48,7 @@ requires-dist = [
47
48
  { name = "rtoml", specifier = ">=0.11.0" },
48
49
  { name = "ruff", specifier = ">=0.8.0" },
49
50
  { name = "termcolor", specifier = ">=2.4.0" },
51
+ { name = "watch-lite", specifier = ">=0.1.1" },
50
52
  ]
51
53
 
52
54
  [package.metadata.requires-dev]
@@ -55,6 +57,29 @@ dev = [
55
57
  { name = "ruff", specifier = ">=0.8.1" },
56
58
  ]
57
59
 
60
+ [[package]]
61
+ name = "maturin"
62
+ version = "1.7.8"
63
+ source = { registry = "https://pypi.org/simple" }
64
+ dependencies = [
65
+ { name = "tomli", marker = "python_full_version < '3.11'" },
66
+ ]
67
+ sdist = { url = "https://files.pythonhosted.org/packages/ab/1e/085ddc0e5b08ae7af7a743a0dd6ed06b22a1332288488f1a333137885150/maturin-1.7.8.tar.gz", hash = "sha256:649c6ef3f0fa4c5f596140d761dc5a4d577c485cc32fb5b9b344a8280352880d", size = 195704 }
68
+ wheels = [
69
+ { url = "https://files.pythonhosted.org/packages/7e/ed/c8bb26e91c879e418ae1b01630722ed20b6fe0e6755be8d538d83666f136/maturin-1.7.8-py3-none-linux_armv6l.whl", hash = "sha256:c6950fd2790acd93265e1501cea66f9249cff19724654424ca75a3b17ebb315b", size = 7515691 },
70
+ { url = "https://files.pythonhosted.org/packages/38/7a/573f969315f0b92a09a0a565d45e98812c87796e2e19a7856159ab234faf/maturin-1.7.8-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:f98288d5c382bacf0c076871dfd50c38f1eb2248f417551e98dd6f47f6ee8afa", size = 14434454 },
71
+ { url = "https://files.pythonhosted.org/packages/a6/17/46834841fbf19231487f185e68b95ca348cc05cce49be8787e0bc7e9dc47/maturin-1.7.8-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b2d4e0f674ca29864e6b86c2eb9fee8236d1c7496c25f7300e34229272468f4c", size = 7509122 },
72
+ { url = "https://files.pythonhosted.org/packages/c1/8f/bf8b4871eb390a4baef2e0bb5016852c7c0311a9772e2945534cfa2ee40e/maturin-1.7.8-py3-none-manylinux_2_12_i686.manylinux2010_i686.musllinux_1_1_i686.whl", hash = "sha256:6cafb17bf57822bdc04423d9e3e766d42918d474848fe9833e397267514ba891", size = 7598870 },
73
+ { url = "https://files.pythonhosted.org/packages/dc/43/c842be67a7c59568082345249b956138ae93d0b2474fb41c186ce26d05e1/maturin-1.7.8-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl", hash = "sha256:2b2bdee0c3a84696b3a809054c43ead1a04b7b3321cbd5b8f5676e4ba4691d0f", size = 7932310 },
74
+ { url = "https://files.pythonhosted.org/packages/12/12/42435d05f2d6c75eb621751e6f021d29eb34d18e3b9c5c94d828744c2d54/maturin-1.7.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:b8188b71259fc2bc568d9c8acc186fcfed96f42539bcb55b8e6f4ec26e411f37", size = 7321964 },
75
+ { url = "https://files.pythonhosted.org/packages/b4/26/f3272ee985ebf9b3e8c4cd4f4efb022af1e12c9f53aed0dcc9a255399f4e/maturin-1.7.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.musllinux_1_1_armv7l.whl", hash = "sha256:a4f58c2a53c2958a1bf090960b08b28e676136cd88ac2f5dfdcf1b14ea54ec06", size = 7408613 },
76
+ { url = "https://files.pythonhosted.org/packages/36/7d/be27bcc7d3ac6e6c2136a8ec0cc56f227a292d6cfdde55e095b6c0aa24a9/maturin-1.7.8-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.musllinux_1_1_ppc64le.whl", hash = "sha256:c5d6c0c631d1fc646cd3834795e6cfd72ab4271d289df7e0f911261a02bec75f", size = 9496974 },
77
+ { url = "https://files.pythonhosted.org/packages/e1/e8/0d7323e9a31c11edf69c4473d73eca74803ce3e2390abf8ae3ac7eb10b04/maturin-1.7.8-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c23664d19dadcbf800ef70f26afb2e0485a985c62889930934f019c565534c23", size = 10828401 },
78
+ { url = "https://files.pythonhosted.org/packages/7e/82/5080e052c0d8c9872f6d4b94cae84c17ed7f2ea270d709210ea6445b655f/maturin-1.7.8-py3-none-win32.whl", hash = "sha256:403eebf1afa6f19b49425f089e39c53b8e597bc86a47f3a76e828dc78d27fa80", size = 6845240 },
79
+ { url = "https://files.pythonhosted.org/packages/6d/c9/9b162361ded893f36038c2f8ac6a972ec441c11df8d17c440997eb28090f/maturin-1.7.8-py3-none-win_amd64.whl", hash = "sha256:1ce48d007438b895f8665314b6748ac0dab31e4f32049a60b52281dd2dccbdde", size = 7762332 },
80
+ { url = "https://files.pythonhosted.org/packages/fa/40/46d4742db742f69a7fe0054cd7c82bc79b2d70cb8c91f7e737e75c28a5f3/maturin-1.7.8-py3-none-win_arm64.whl", hash = "sha256:cc92a62953205e8945b6cfe6943d6a8576a4442d30d9c67141f944f4f4640e62", size = 6501353 },
81
+ ]
82
+
58
83
  [[package]]
59
84
  name = "mypy"
60
85
  version = "1.13.0"
@@ -268,3 +293,15 @@ sdist = { url = "https://files.pythonhosted.org/packages/df/db/f35a00659bc03fec3
268
293
  wheels = [
269
294
  { url = "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", size = 37438 },
270
295
  ]
296
+
297
+ [[package]]
298
+ name = "watch-lite"
299
+ version = "0.1.1"
300
+ source = { registry = "https://pypi.org/simple" }
301
+ dependencies = [
302
+ { name = "maturin" },
303
+ ]
304
+ sdist = { url = "https://files.pythonhosted.org/packages/f4/a0/bea3567de1c30c029c62fd024492f2ac7dd61634fdde2134462a7a75bad1/watch_lite-0.1.1.tar.gz", hash = "sha256:5b6c1dd4750609e389d5eb8356f48d244376735ee99421ade7672889752cead4", size = 11152 }
305
+ wheels = [
306
+ { url = "https://files.pythonhosted.org/packages/c7/1e/17b02b821d22ae0e9850fbbfd2edf7b59e2df3e9d94c1079c795678d846d/watch_lite-0.1.1-cp39-abi3-win_amd64.whl", hash = "sha256:e7fb78ee6426a19c7da31869d3e8efca65236d6f5b0533b53032f28d25b87c95", size = 117841 },
307
+ ]
@@ -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