atrace 0.1.0__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.
@@ -0,0 +1,30 @@
1
+ # From https://docs.astral.sh/uv/guides/integration/github/#publishing-to-pypi
2
+ name: "Publish to pypi"
3
+
4
+ on:
5
+ # Runs on pushes targeting the default branch
6
+ push:
7
+ branches: ["main"]
8
+
9
+ # Allows you to run this workflow manually from the Actions tab
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ run:
14
+ runs-on: ubuntu-latest
15
+ environment:
16
+ name: pypi
17
+ permissions:
18
+ id-token: write
19
+ contents: read
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v5
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v7
25
+ - name: Install Python 3.13
26
+ run: uv python install 3.13
27
+ - name: Build
28
+ run: uv build
29
+ - name: Publish
30
+ run: uv publish
@@ -0,0 +1,13 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Mac
13
+ .DS_Store
@@ -0,0 +1 @@
1
+ 3.13
atrace-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: atrace
3
+ Version: 0.1.0
4
+ Author-email: Nicholas Wolff <nwolff@gmail.com>
5
+ Requires-Python: >=3.7
atrace-0.1.0/README.md ADDED
File without changes
@@ -0,0 +1,12 @@
1
+ [project]
2
+ name = "atrace"
3
+ version = "0.1.0"
4
+ description = ""
5
+ readme = "README.md"
6
+ authors = [{ name = "Nicholas Wolff", email = "nwolff@gmail.com" }]
7
+ requires-python = ">=3.7"
8
+ dependencies = []
9
+
10
+ [build-system]
11
+ requires = ["hatchling"]
12
+ build-backend = "hatchling.build"
@@ -0,0 +1,2 @@
1
+ def hello() -> str:
2
+ return "Hello from atrace!"
File without changes
@@ -0,0 +1,58 @@
1
+ import sys
2
+
3
+
4
+ def trace_vars(frame, event, arg):
5
+
6
+ if event != "line":
7
+ return trace_vars
8
+ code = frame.f_code
9
+ lineno = frame.f_lineno
10
+ locals_now = frame.f_locals.copy()
11
+ global last_locals
12
+
13
+ if code.co_name not in last_locals:
14
+ last_locals[code.co_name] = locals_now
15
+ return trace_vars
16
+
17
+ old_locals = last_locals[code.co_name]
18
+
19
+ for var, new_val in locals_now.items():
20
+ if var not in old_locals:
21
+ print(f"[{code.co_name}:{lineno}] NEW {var} = {new_val}")
22
+ elif old_locals[var] != new_val:
23
+ print(
24
+ f"[{code.co_name}:{lineno}] MODIFIED {var}: {old_locals[var]} → {new_val}"
25
+ )
26
+
27
+ for var in old_locals:
28
+ if var not in locals_now:
29
+ print(f"[{code.co_name}:{lineno}] DELETED {var}")
30
+
31
+ last_locals[code.co_name] = locals_now
32
+ return trace_vars
33
+
34
+
35
+ def monitor(func):
36
+
37
+ def wrapper(*args, **kwargs):
38
+ global last_locals
39
+ last_locals = {}
40
+ sys.settrace(trace_vars)
41
+ try:
42
+ return func(*args, **kwargs)
43
+ finally:
44
+ sys.settrace(None)
45
+
46
+ return wrapper
47
+
48
+
49
+ @monitor
50
+ def run_example():
51
+ a = 10
52
+ b = a + 5
53
+ b = b * 2
54
+ del a
55
+ return b
56
+
57
+
58
+ run_example()
@@ -0,0 +1,13 @@
1
+ from pytracertool.pytracertool import CodeTracer
2
+
3
+ example_code = """
4
+ x = 1
5
+ y = 1
6
+ x = x + y
7
+ print(x)
8
+ """
9
+
10
+ tracer = CodeTracer(example_code, None)
11
+ tracer.generate_trace_table()
12
+ trace_table_str = str(tracer)
13
+ print(trace_table_str)