dependency-cache 0.2.1__tar.gz → 0.2.3__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.
Files changed (30) hide show
  1. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/.github/workflows/CI.yml +72 -33
  2. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/.github/workflows/Test.yml +8 -0
  3. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/PKG-INFO +2 -2
  4. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/README.md +1 -1
  5. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/pyproject.toml +1 -1
  6. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/examples/automagic_dependency_example.py +1 -0
  7. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/examples/example.py +1 -0
  8. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/examples/inheritance_example.py +1 -1
  9. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/examples/manual_dependency_example.py +1 -0
  10. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/examples/runtime_dependencies_example.py +19 -4
  11. dependency_cache-0.2.3/python/examples/runtime_function_calls_example.py +34 -0
  12. dependency_cache-0.2.1/python/examples/function_calls_example.py → dependency_cache-0.2.3/python/examples/static_function_calls_example.py +1 -1
  13. dependency_cache-0.2.3/python/examples/use_cache_example.py +30 -0
  14. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/uv.lock +1 -1
  15. dependency_cache-0.2.1/python/examples/use_cache_example.py +0 -30
  16. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/.gitignore +0 -0
  17. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/Cargo.lock +0 -0
  18. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/Cargo.toml +0 -0
  19. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/LICENSE +0 -0
  20. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/dependency_cache/__init__.py +0 -0
  21. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/dependency_cache/dependency_cache.pyi +0 -0
  22. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/dependency_cache/plot_dependency_graph.py +0 -0
  23. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/test_python.py +0 -0
  24. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/python/test_python_automagic.py +0 -0
  25. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/src/decorator.rs +0 -0
  26. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/src/decorator_factory.rs +0 -0
  27. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/src/dependency_cache_base.rs +0 -0
  28. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/src/dependency_graph.rs +0 -0
  29. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/src/lib.rs +0 -0
  30. {dependency_cache-0.2.1 → dependency_cache-0.2.3}/src/py_introspection_utils.rs +0 -0
@@ -1,7 +1,7 @@
1
- # This file is autogenerated by maturin v1.9.6
1
+ # This file is autogenerated by maturin v1.14.1
2
2
  # To update, run
3
3
  #
4
- # maturin generate-ci github
4
+ # maturin generate-ci github -o .github\workflows\CI.yml
5
5
  #
6
6
  name: CI
7
7
 
@@ -30,19 +30,26 @@ jobs:
30
30
  - runner: ubuntu-22.04
31
31
  target: ppc64le
32
32
  steps:
33
- - uses: actions/checkout@v4
34
- - uses: actions/setup-python@v5
33
+ - uses: actions/checkout@v6
34
+ - uses: actions/setup-python@v6
35
35
  with:
36
- python-version: 3.x
36
+ python-version: "3.8"
37
37
  - name: Build wheels
38
38
  uses: PyO3/maturin-action@v1
39
39
  with:
40
40
  target: ${{ matrix.platform.target }}
41
- args: --release --out dist --find-interpreter
41
+ args: --release --out dist
42
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
43
+ manylinux: auto
44
+ - name: Build free-threaded wheels
45
+ uses: PyO3/maturin-action@v1
46
+ with:
47
+ target: ${{ matrix.platform.target }}
48
+ args: --release --out dist -i python3.14t
42
49
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
43
50
  manylinux: auto
44
51
  - name: Upload wheels
45
- uses: actions/upload-artifact@v4
52
+ uses: actions/upload-artifact@v6
46
53
  with:
47
54
  name: wheels-linux-${{ matrix.platform.target }}
48
55
  path: dist
@@ -61,19 +68,26 @@ jobs:
61
68
  - runner: ubuntu-22.04
62
69
  target: armv7
63
70
  steps:
64
- - uses: actions/checkout@v4
65
- - uses: actions/setup-python@v5
71
+ - uses: actions/checkout@v6
72
+ - uses: actions/setup-python@v6
66
73
  with:
67
- python-version: 3.x
74
+ python-version: "3.8"
68
75
  - name: Build wheels
69
76
  uses: PyO3/maturin-action@v1
70
77
  with:
71
78
  target: ${{ matrix.platform.target }}
72
- args: --release --out dist --find-interpreter
79
+ args: --release --out dist
80
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
81
+ manylinux: musllinux_1_2
82
+ - name: Build free-threaded wheels
83
+ uses: PyO3/maturin-action@v1
84
+ with:
85
+ target: ${{ matrix.platform.target }}
86
+ args: --release --out dist -i python3.14t
73
87
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
74
88
  manylinux: musllinux_1_2
75
89
  - name: Upload wheels
76
- uses: actions/upload-artifact@v4
90
+ uses: actions/upload-artifact@v6
77
91
  with:
78
92
  name: wheels-musllinux-${{ matrix.platform.target }}
79
93
  path: dist
@@ -85,22 +99,37 @@ jobs:
85
99
  platform:
86
100
  - runner: windows-latest
87
101
  target: x64
102
+ python_arch: x64
88
103
  - runner: windows-latest
89
104
  target: x86
105
+ python_arch: x86
106
+ - runner: windows-11-arm
107
+ target: aarch64
108
+ python_arch: arm64
90
109
  steps:
91
- - uses: actions/checkout@v4
92
- - uses: actions/setup-python@v5
110
+ - uses: actions/checkout@v6
111
+ - uses: actions/setup-python@v6
93
112
  with:
94
- python-version: 3.x
95
- architecture: ${{ matrix.platform.target }}
113
+ python-version: "3.13"
114
+ architecture: ${{ matrix.platform.python_arch }}
96
115
  - name: Build wheels
97
116
  uses: PyO3/maturin-action@v1
98
117
  with:
99
118
  target: ${{ matrix.platform.target }}
100
- args: --release --out dist --find-interpreter
119
+ args: --release --out dist
120
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
121
+ - uses: actions/setup-python@v6
122
+ with:
123
+ python-version: "3.14t"
124
+ architecture: ${{ matrix.platform.python_arch }}
125
+ - name: Build free-threaded wheels
126
+ uses: PyO3/maturin-action@v1
127
+ with:
128
+ target: ${{ matrix.platform.target }}
129
+ args: --release --out dist -i python3.14t
101
130
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
102
131
  - name: Upload wheels
103
- uses: actions/upload-artifact@v4
132
+ uses: actions/upload-artifact@v6
104
133
  with:
105
134
  name: wheels-windows-${{ matrix.platform.target }}
106
135
  path: dist
@@ -112,21 +141,30 @@ jobs:
112
141
  platform:
113
142
  - runner: macos-15-intel
114
143
  target: x86_64
115
- - runner: macos-14
144
+ - runner: macos-latest
116
145
  target: aarch64
117
146
  steps:
118
- - uses: actions/checkout@v4
119
- - uses: actions/setup-python@v5
147
+ - uses: actions/checkout@v6
148
+ - uses: actions/setup-python@v6
120
149
  with:
121
- python-version: 3.x
150
+ python-version: "3.8"
122
151
  - name: Build wheels
123
152
  uses: PyO3/maturin-action@v1
124
153
  with:
125
154
  target: ${{ matrix.platform.target }}
126
- args: --release --out dist --find-interpreter
155
+ args: --release --out dist
156
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
157
+ - uses: actions/setup-python@v6
158
+ with:
159
+ python-version: "3.14t"
160
+ - name: Build free-threaded wheels
161
+ uses: PyO3/maturin-action@v1
162
+ with:
163
+ target: ${{ matrix.platform.target }}
164
+ args: --release --out dist -i python3.14t
127
165
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
128
166
  - name: Upload wheels
129
- uses: actions/upload-artifact@v4
167
+ uses: actions/upload-artifact@v6
130
168
  with:
131
169
  name: wheels-macos-${{ matrix.platform.target }}
132
170
  path: dist
@@ -134,14 +172,14 @@ jobs:
134
172
  sdist:
135
173
  runs-on: ubuntu-latest
136
174
  steps:
137
- - uses: actions/checkout@v4
175
+ - uses: actions/checkout@v6
138
176
  - name: Build sdist
139
177
  uses: PyO3/maturin-action@v1
140
178
  with:
141
179
  command: sdist
142
180
  args: --out dist
143
181
  - name: Upload sdist
144
- uses: actions/upload-artifact@v4
182
+ uses: actions/upload-artifact@v6
145
183
  with:
146
184
  name: wheels-sdist
147
185
  path: dist
@@ -152,18 +190,19 @@ jobs:
152
190
  if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
153
191
  needs: [linux, musllinux, windows, macos, sdist]
154
192
  permissions:
193
+ # Use to sign the release artifacts
155
194
  id-token: write
195
+ # Used to upload release artifacts
156
196
  contents: write
197
+ # Used to generate artifact attestation
157
198
  attestations: write
158
199
  steps:
159
- - uses: actions/download-artifact@v4
200
+ - uses: actions/download-artifact@v7
160
201
  - name: Generate artifact attestation
161
- uses: actions/attest-build-provenance@v2
202
+ uses: actions/attest@v4
162
203
  with:
163
204
  subject-path: 'wheels-*/*'
205
+ - name: Install uv
206
+ uses: astral-sh/setup-uv@v7
164
207
  - name: Publish to PyPI
165
- uses: PyO3/maturin-action@v1
166
- with:
167
- command: upload
168
- args: --non-interactive --skip-existing wheels-*/*
169
- trust-publishing: true
208
+ run: uv publish 'wheels-*/*'
@@ -34,3 +34,11 @@ jobs:
34
34
  pip install --upgrade pip pytest
35
35
  maturin develop --release
36
36
  pytest -v
37
+
38
+ - name: Ensure Python examples valid
39
+ run: |
40
+ source venv/bin/activate
41
+ for example in python/examples/*.py; do
42
+ echo "Running $example"
43
+ python "$example"
44
+ done
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dependency_cache
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -108,7 +108,7 @@ c.update_cached_value("A", 0) # invalidates C (but not B)
108
108
  print(c.C()) # recalculates C -> 5
109
109
  ```
110
110
 
111
- This example can be found [here](/python/examples/example.py) with more runnable examples and use cases provided in the [python/examples](/python/examples) folder.
111
+ This example can be found [here](https://github.com/XtdWt/dependency_cache/blob/master/python/examples/example.py) with more runnable examples and use cases provided in the [python/examples](https://github.com/XtdWt/dependency_cache/tree/master/python/examples) folder.
112
112
 
113
113
  ```bash
114
114
  uv run ./python/examples/example.py
@@ -90,7 +90,7 @@ c.update_cached_value("A", 0) # invalidates C (but not B)
90
90
  print(c.C()) # recalculates C -> 5
91
91
  ```
92
92
 
93
- This example can be found [here](/python/examples/example.py) with more runnable examples and use cases provided in the [python/examples](/python/examples) folder.
93
+ This example can be found [here](https://github.com/XtdWt/dependency_cache/blob/master/python/examples/example.py) with more runnable examples and use cases provided in the [python/examples](https://github.com/XtdWt/dependency_cache/tree/master/python/examples) folder.
94
94
 
95
95
  ```bash
96
96
  uv run ./python/examples/example.py
@@ -11,7 +11,7 @@ classifiers = [
11
11
  "Programming Language :: Python :: Implementation :: PyPy",
12
12
  ]
13
13
  keywords = ["caching", "dependency-graph", "invalidation"]
14
- version = "0.2.1"
14
+ version = "0.2.3"
15
15
  description = "A caching library for Python object methods that utilises a dependency graph to track relationships and control invalidation, enabling efficient recomputation"
16
16
  readme = "README.md"
17
17
  license = { text = "MIT" }
@@ -42,6 +42,7 @@ class ExampleCalculationMagic(DependencyCacheBase):
42
42
 
43
43
 
44
44
  if __name__ == "__main__":
45
+ print("example of using the automagic parsing of dependencies")
45
46
  print(" E")
46
47
  print(" / \\")
47
48
  print(" D \\")
@@ -29,6 +29,7 @@ class ExampleCalculation(DependencyCacheBase):
29
29
 
30
30
 
31
31
  if __name__ == "__main__":
32
+ print("example of using dependency_cache for recomputation")
32
33
  print(" C")
33
34
  print(" / \\")
34
35
  print("A B")
@@ -32,7 +32,7 @@ class ParentClass(ChildClass):
32
32
 
33
33
 
34
34
  if __name__ == "__main__":
35
- print("dependency graph obeys MRO (standard inheritance method order)")
35
+ print("example that dependency graph obeys MRO (standard inheritance method order)")
36
36
  c = ParentClass()
37
37
 
38
38
  print(f"Result of A {c.A()}") # calculates parent A and does not calculates child
@@ -41,6 +41,7 @@ class ExampleCalculationManual(DependencyCacheBase):
41
41
 
42
42
 
43
43
  if __name__ == "__main__":
44
+ print("example of manually declaring dependencies")
44
45
  print("D E")
45
46
  print(" \\ /")
46
47
  print(" C")
@@ -32,14 +32,29 @@ class RuntimeGraphExample(DependencyCacheBase):
32
32
 
33
33
 
34
34
  if __name__ == "__main__":
35
+ print("example of using runtime dependencies")
36
+ print("graph only partially built!")
37
+ print(" A")
38
+ print(" / |")
39
+ print(" / |")
40
+ print("C B")
35
41
  c = RuntimeGraphExample()
36
42
  print(c.A()) # calculates A, prints 1000
37
- print("graph only partially built!")
38
43
 
39
- print("repeatedly updating D!")
44
+ print("updating D!")
45
+ print(c.D())
40
46
  c.update_cached_value("D", 1)
41
- c.update_cached_value("D", 2)
47
+ print(c.D())
42
48
  c.update_cached_value("D", 3)
43
-
49
+ print(c.D())
44
50
  print(c.A()) # no calculation, returns cached 1000
51
+
52
+ print("graph fully built!")
53
+ print(" A")
54
+ print(" / | \\")
55
+ print(" / | \\")
56
+ print("C B D")
57
+ c.update_cached_value("B", False)
58
+ print(c.A()) # calculates A, prints 3
59
+
45
60
  print(c.get_cached_values(), c.get_dependency_graph(), c.get_validation_state())
@@ -0,0 +1,34 @@
1
+ from dependency_cache import DependencyCacheBase, dependency_cached
2
+
3
+
4
+ class FibonacciExample(DependencyCacheBase):
5
+ def __init__(self):
6
+ super().__init__()
7
+
8
+ @dependency_cached(track_runtime_dependencies=True)
9
+ def Calculate(self, n):
10
+ print(f"calculating the {n=} fibonacci number")
11
+ if n <= 0:
12
+ return 0
13
+ if n == 1:
14
+ return 1
15
+ return self.Calculate(n - 1) + self.Calculate(n - 2)
16
+
17
+
18
+ if __name__ == "__main__":
19
+ print("example of using runtime dependencies, with nested function calls")
20
+ print("Fib(3)")
21
+ print("| \\")
22
+ print("| Fib(2)")
23
+ print("| | \\")
24
+ print("----> Fib(1)")
25
+ print(" | \\")
26
+ print(" ----> Fib(0)")
27
+ c = FibonacciExample()
28
+
29
+ print(f"Result of Fib(3) {c.Calculate(3)}") # calculates Calculate(3), Calculate(2), Calculate(1), Calculate(0)
30
+
31
+ print(f"Result of Fib(2) {c.Calculate(2)}") # cache works for Calculate(2), no more prints
32
+ print(f"Result of Fib(1) {c.Calculate(1)}") # cache works for Calculate(2), no more prints
33
+ print(f"Result of Fib(4) {c.Calculate(4)}") # calculates Calculate(4), rest cached
34
+ print(c.get_cached_values(), c.get_dependency_graph(), c.get_validation_state())
@@ -26,7 +26,7 @@ class FunctionCallObj(DependencyCacheBase):
26
26
 
27
27
 
28
28
  if __name__ == "__main__":
29
- print("dependency graph can have each function call cached")
29
+ print("example of manually defining function calls")
30
30
  c = FunctionCallObj(1)
31
31
 
32
32
  print(f"Result of B {c.B()}") # calculates parent B and does calculates A(0), C, A(1)
@@ -0,0 +1,30 @@
1
+ import time
2
+
3
+ from dependency_cache import DependencyCacheBase, dependency_cached
4
+
5
+
6
+ class UseCacheExample(DependencyCacheBase):
7
+ def __init__(self):
8
+ super().__init__()
9
+
10
+ @dependency_cached(use_cache=False)
11
+ def A(self):
12
+ print("calculating A")
13
+ return time.time()
14
+
15
+ @dependency_cached(dependencies=["A"])
16
+ def B(self):
17
+ print("calculating B")
18
+ return self.A() + 1
19
+
20
+
21
+ if __name__ == "__main__":
22
+ print("example of use_cache flagging permanent invalidation of graph")
23
+ print(" B")
24
+ print(" |")
25
+ print("A (always recalcs)")
26
+ c = UseCacheExample()
27
+ print(f"Result of B = {c.B()}") # calculates all
28
+ print(c.get_cached_values(), c.get_dependency_graph(), c.get_validation_state())
29
+ print(f"Result of B = {c.B()}") # still calculates all
30
+ print(c.get_cached_values(), c.get_dependency_graph(), c.get_validation_state())
@@ -329,7 +329,7 @@ wheels = [
329
329
 
330
330
  [[package]]
331
331
  name = "dependency-cache"
332
- version = "0.2.1"
332
+ version = "0.2.3"
333
333
  source = { editable = "." }
334
334
  dependencies = [
335
335
  { name = "matplotlib", version = "3.7.5", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.9'" },
@@ -1,30 +0,0 @@
1
- import time
2
-
3
- from dependency_cache import DependencyCacheBase, dependency_cached
4
-
5
-
6
- class UseCacheExample(DependencyCacheBase):
7
- def __init__(self):
8
- super().__init__()
9
-
10
- @dependency_cached(use_cache=False)
11
- def A(self):
12
- print("calculating A")
13
- return time.time()
14
-
15
- @dependency_cached(dependencies=["A"])
16
- def B(self):
17
- print("calculating B")
18
- return self.A() + 1
19
-
20
-
21
- if __name__ == "__main__":
22
- if __name__ == "__main__":
23
- print(" B")
24
- print(" |")
25
- print("A (always recalcs)")
26
- c = UseCacheExample()
27
- print(f"Result of B = {c.B()}") # calculates all
28
- print(c.get_cached_values(), c.get_dependency_graph(), c.get_validation_state())
29
- print(f"Result of B = {c.B()}") # still calculates all
30
- print(c.get_cached_values(), c.get_dependency_graph(), c.get_validation_state())