omdev 0.0.0.dev396__py3-none-any.whl → 0.0.0.dev397__py3-none-any.whl
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.
- omdev/.manifests.json +1 -1
- omdev/dataclasses/codegen.py +1 -2
- omdev/tools/prof.py +91 -20
- {omdev-0.0.0.dev396.dist-info → omdev-0.0.0.dev397.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev396.dist-info → omdev-0.0.0.dev397.dist-info}/RECORD +9 -9
- {omdev-0.0.0.dev396.dist-info → omdev-0.0.0.dev397.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev396.dist-info → omdev-0.0.0.dev397.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev396.dist-info → omdev-0.0.0.dev397.dist-info}/licenses/LICENSE +0 -0
- {omdev-0.0.0.dev396.dist-info → omdev-0.0.0.dev397.dist-info}/top_level.txt +0 -0
omdev/.manifests.json
CHANGED
omdev/dataclasses/codegen.py
CHANGED
@@ -7,7 +7,6 @@ TODO:
|
|
7
7
|
- !! manifests for dataclass config?
|
8
8
|
- more sparse / diffuse intent, not package-level
|
9
9
|
"""
|
10
|
-
import json
|
11
10
|
import logging
|
12
11
|
import os.path
|
13
12
|
import typing as ta
|
@@ -78,7 +77,7 @@ class DataclassCodeGen:
|
|
78
77
|
for dp, _, fns in os.walk(root_dir):
|
79
78
|
if PACKAGE_CONFIG_FILE_NAME in fns:
|
80
79
|
with open(os.path.join(dp, PACKAGE_CONFIG_FILE_NAME)) as f:
|
81
|
-
config = PackageConfig(
|
80
|
+
config = PackageConfig.loads(f.read())
|
82
81
|
pkg_parts = dp.split(os.sep)
|
83
82
|
trie[pkg_parts] = config
|
84
83
|
|
omdev/tools/prof.py
CHANGED
@@ -3,6 +3,7 @@ TODO:
|
|
3
3
|
- a general purpose profile tool lol - or is this for / in bootstrap?
|
4
4
|
"""
|
5
5
|
import os.path
|
6
|
+
import shutil
|
6
7
|
import subprocess
|
7
8
|
import sys
|
8
9
|
import tempfile
|
@@ -15,43 +16,113 @@ from ..cli import CliModule
|
|
15
16
|
##
|
16
17
|
|
17
18
|
|
19
|
+
def pstats_to_pdf(
|
20
|
+
pstats_file: str,
|
21
|
+
pdf_file: str,
|
22
|
+
) -> None:
|
23
|
+
dot = subprocess.check_output([
|
24
|
+
sys.executable,
|
25
|
+
'-m', 'gprof2dot',
|
26
|
+
'-f', 'pstats',
|
27
|
+
pstats_file,
|
28
|
+
])
|
29
|
+
|
30
|
+
pdf = subprocess.check_output(
|
31
|
+
['dot', '-Tpdf'],
|
32
|
+
input=dot,
|
33
|
+
)
|
34
|
+
|
35
|
+
with open(pdf_file, 'wb') as f:
|
36
|
+
f.write(pdf)
|
37
|
+
|
38
|
+
|
18
39
|
class Cli(ap.Cli):
|
19
40
|
@ap.cmd(
|
20
|
-
ap.arg('file'),
|
21
|
-
ap.arg('
|
41
|
+
ap.arg('pstats-file'),
|
42
|
+
ap.arg('pdf-file', nargs='?'),
|
22
43
|
ap.arg('-w', '--write', action='store_true'),
|
23
44
|
ap.arg('-o', '--open', action='store_true'),
|
24
45
|
ap.arg('-O', '--overwrite', action='store_true'),
|
25
46
|
)
|
26
47
|
def pstats_pdf(self) -> None:
|
27
|
-
|
28
|
-
if
|
29
|
-
|
48
|
+
pdf_file = self.args.pdf_file
|
49
|
+
if pdf_file is None and self.args.write:
|
50
|
+
pdf_file = self.args.pstats_file + '.pdf'
|
30
51
|
|
31
|
-
if
|
32
|
-
if os.path.exists(
|
33
|
-
raise OSError(f'File exists: {
|
52
|
+
if pdf_file is not None:
|
53
|
+
if os.path.exists(pdf_file) and not self.args.overwrite:
|
54
|
+
raise OSError(f'File exists: {pdf_file}')
|
34
55
|
else:
|
35
|
-
|
56
|
+
pdf_file = tempfile.mktemp(suffix=os.path.basename(self.args.pstats_file) + '.pdf') # noqa
|
57
|
+
|
58
|
+
pstats_to_pdf(
|
59
|
+
self.args.pstats_file,
|
60
|
+
self.args.pdf_file,
|
61
|
+
)
|
62
|
+
|
63
|
+
print(pdf_file)
|
64
|
+
|
65
|
+
if self.args.open:
|
66
|
+
subprocess.check_call(['open', pdf_file])
|
67
|
+
|
68
|
+
@ap.cmd(
|
69
|
+
ap.arg('src'),
|
70
|
+
ap.arg('out-file', nargs='?'),
|
71
|
+
ap.arg('-p', '--pdf', action='store_true'),
|
72
|
+
ap.arg('-o', '--open', action='store_true'),
|
73
|
+
ap.arg('-O', '--overwrite', action='store_true'),
|
74
|
+
)
|
75
|
+
def pstats_exec(self) -> None:
|
76
|
+
if self.args.out_file is not None:
|
77
|
+
if os.path.exists(self.args.out_file) and not self.args.overwrite:
|
78
|
+
raise OSError(f'File exists: {self.args.out_file}')
|
79
|
+
|
80
|
+
tmp_dir = tempfile.mkdtemp()
|
81
|
+
|
82
|
+
src_file = os.path.join(tmp_dir, 'pstats_exec.py')
|
83
|
+
with open(src_file, 'w') as f:
|
84
|
+
f.write(self.args.src)
|
85
|
+
|
86
|
+
pstats_file = os.path.join(tmp_dir, 'prof.pstats')
|
36
87
|
|
37
|
-
|
88
|
+
# TODO: --python - and handle env vars, unset venv and pythonpath stuff - helper for this, scrub env
|
89
|
+
# - share with execstat, -x
|
90
|
+
subprocess.check_call([
|
38
91
|
sys.executable,
|
39
|
-
'-m', '
|
40
|
-
'-
|
41
|
-
|
92
|
+
'-m', 'cProfile',
|
93
|
+
'-o', pstats_file,
|
94
|
+
os.path.abspath(src_file),
|
42
95
|
])
|
43
96
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
97
|
+
if self.args.pdf:
|
98
|
+
out_file = os.path.join(tmp_dir, 'pstats.pdf')
|
99
|
+
|
100
|
+
pstats_to_pdf(
|
101
|
+
pstats_file,
|
102
|
+
out_file,
|
103
|
+
)
|
104
|
+
|
105
|
+
else:
|
106
|
+
out_file = pstats_file
|
107
|
+
|
108
|
+
if self.args.out_file is not None:
|
109
|
+
shutil.move(out_file, self.args.out_file)
|
110
|
+
out_file = self.args.out_file
|
48
111
|
|
49
|
-
with open(out_file, 'wb') as f:
|
50
|
-
f.write(pdf)
|
51
112
|
print(out_file)
|
52
113
|
|
53
114
|
if self.args.open:
|
54
|
-
|
115
|
+
if self.args.pdf:
|
116
|
+
subprocess.check_call(['open', out_file])
|
117
|
+
|
118
|
+
else:
|
119
|
+
# Alt: python -i <setup.py> where setup.py is 'import pstats; stats = pstats.Stats(<out_file>)'
|
120
|
+
os.execl(
|
121
|
+
sys.executable,
|
122
|
+
sys.executable,
|
123
|
+
'-m', 'pstats',
|
124
|
+
out_file,
|
125
|
+
)
|
55
126
|
|
56
127
|
|
57
128
|
# @omlish-manifest
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: omdev
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev397
|
4
4
|
Summary: omdev
|
5
5
|
Author: wrmsr
|
6
6
|
License-Expression: BSD-3-Clause
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Requires-Python: >=3.13
|
15
15
|
Description-Content-Type: text/markdown
|
16
16
|
License-File: LICENSE
|
17
|
-
Requires-Dist: omlish==0.0.0.
|
17
|
+
Requires-Dist: omlish==0.0.0.dev397
|
18
18
|
Provides-Extra: all
|
19
19
|
Requires-Dist: black~=25.1; extra == "all"
|
20
20
|
Requires-Dist: pycparser~=2.22; extra == "all"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
omdev/.manifests.json,sha256=
|
1
|
+
omdev/.manifests.json,sha256=vqg148YzWHn61WpGqC2PuTiOIR2HcH5O55XZZGTcnVw,12452
|
2
2
|
omdev/__about__.py,sha256=fQNmzSa1MntcPSrzg_Vpo6JRU2RbXik2NqRz0oQCApE,1202
|
3
3
|
omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
omdev/cmake.py,sha256=9rfSvFHPmKDj9ngvfDB2vK8O-xO_ZwUm7hMKLWA-yOw,4578
|
@@ -128,7 +128,7 @@ omdev/cmdlog/cmdlog.py,sha256=MJqfCG7sVWjSK_i1shD7cgWpFZXZkPvGhGEh-yd6iwM,1982
|
|
128
128
|
omdev/dataclasses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
129
129
|
omdev/dataclasses/__main__.py,sha256=N-a0Lf_s7D0VajuZCCY_dt8R4rSpeck9inbCsoIvciQ,175
|
130
130
|
omdev/dataclasses/cli.py,sha256=j5GfpJQSkA_jmV94XTVb3amCFYjgrasMs-bp_zJEkqE,445
|
131
|
-
omdev/dataclasses/codegen.py,sha256=
|
131
|
+
omdev/dataclasses/codegen.py,sha256=T9SYsTjmNrM1HMUFVMO46-Szd3DH0Em0B-I_UTan6qg,3029
|
132
132
|
omdev/dataserver/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
133
133
|
omdev/dataserver/handlers.py,sha256=YTuRfZehP9panTwq8dPReHZwXF1_fFIueh-_ZoztA98,5446
|
134
134
|
omdev/dataserver/http.py,sha256=SMS6w-GVevG58FypqmPytcEqW8aUWpd2_F6JlBDIuBc,1730
|
@@ -288,7 +288,7 @@ omdev/tools/linehisto.py,sha256=0ZNm34EuiZBE9Q2YC6KNLNNydNT8QPSOwvYzXiU9S2Q,8881
|
|
288
288
|
omdev/tools/mkenv.py,sha256=G2tu5bmiyKFyZuqtUoM7Z-6AI6CI86F2LwoIozoWOvo,2300
|
289
289
|
omdev/tools/notebook.py,sha256=MGi2JEwyIPR1n7gakaaYZL1HHbSVmDKGQROqH56ppgU,3499
|
290
290
|
omdev/tools/pip.py,sha256=HF5ILsNcU1IGn9bRthwjp4XicafZWR7zdp6rOhqSMiw,3464
|
291
|
-
omdev/tools/prof.py,sha256=
|
291
|
+
omdev/tools/prof.py,sha256=AWcuToo3VACxyFRdUEmdqtGcfidPlvJCwkD-q_b6uIs,3485
|
292
292
|
omdev/tools/qr.py,sha256=1p4tMJmImDa4YTQQNPwQPkM8FnhGRYj6J79BJR-MNHo,1742
|
293
293
|
omdev/tools/shadow.py,sha256=4E2ilxa16liIvQxvgU37ITkOMrP6ufShRQfeW7wwtRc,1697
|
294
294
|
omdev/tools/shell.py,sha256=5hF_8DCtB3XrzJSfmQDsr7X3Fi9KRV4M70q9qp0KREA,2341
|
@@ -321,9 +321,9 @@ omdev/tools/jsonview/resources/jsonview.js,sha256=faDvXDOXKvEvjOuIlz4D3F2ReQXb_b
|
|
321
321
|
omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
322
322
|
omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
|
323
323
|
omdev/tools/pawk/pawk.py,sha256=ao5mdrpiSU4AZ8mBozoEaV3UVlmVTnRG9wD9XP70MZE,11429
|
324
|
-
omdev-0.0.0.
|
325
|
-
omdev-0.0.0.
|
326
|
-
omdev-0.0.0.
|
327
|
-
omdev-0.0.0.
|
328
|
-
omdev-0.0.0.
|
329
|
-
omdev-0.0.0.
|
324
|
+
omdev-0.0.0.dev397.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
325
|
+
omdev-0.0.0.dev397.dist-info/METADATA,sha256=bAgNwHp9Gc2_P6AUojLiMF61tGyHIvXlOmx8C065zhI,5094
|
326
|
+
omdev-0.0.0.dev397.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
327
|
+
omdev-0.0.0.dev397.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
328
|
+
omdev-0.0.0.dev397.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
329
|
+
omdev-0.0.0.dev397.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|