omdev 0.0.0.dev416__py3-none-any.whl → 0.0.0.dev500__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.

Potentially problematic release.


This version of omdev might be problematic. Click here for more details.

Files changed (211) hide show
  1. omdev/{.manifests.json → .omlish-manifests.json} +23 -47
  2. omdev/README.md +51 -0
  3. omdev/__about__.py +12 -8
  4. omdev/amalg/cli/main.py +1 -2
  5. omdev/amalg/gen/gen.py +49 -6
  6. omdev/amalg/gen/imports.py +1 -1
  7. omdev/amalg/gen/manifests.py +1 -1
  8. omdev/amalg/gen/resources.py +1 -1
  9. omdev/amalg/gen/srcfiles.py +26 -3
  10. omdev/amalg/gen/strip.py +1 -1
  11. omdev/amalg/gen/types.py +1 -1
  12. omdev/amalg/gen/typing.py +1 -1
  13. omdev/amalg/info.py +32 -0
  14. omdev/cache/compute/storage.py +3 -1
  15. omdev/cache/data/actions.py +1 -1
  16. omdev/cache/data/cache.py +2 -2
  17. omdev/cache/data/specs.py +1 -1
  18. omdev/cexts/_boilerplate.cc +2 -3
  19. omdev/cexts/_distutils/build_ext.py +5 -2
  20. omdev/cexts/_distutils/compilers/ccompiler.py +5 -2
  21. omdev/cexts/_distutils/compilers/options.py +3 -0
  22. omdev/cexts/_distutils/compilers/unixccompiler.py +6 -2
  23. omdev/cexts/_distutils/dir_util.py +6 -2
  24. omdev/cexts/_distutils/errors.py +3 -0
  25. omdev/cexts/_distutils/extension.py +3 -0
  26. omdev/cexts/_distutils/file_util.py +6 -2
  27. omdev/cexts/_distutils/modified.py +3 -0
  28. omdev/cexts/_distutils/spawn.py +6 -2
  29. omdev/cexts/_distutils/sysconfig.py +3 -0
  30. omdev/cexts/_distutils/util.py +6 -2
  31. omdev/cexts/_distutils/version.py +3 -0
  32. omdev/cexts/cmake.py +5 -3
  33. omdev/cexts/scan.py +1 -2
  34. omdev/ci/cache.py +7 -3
  35. omdev/ci/cli.py +6 -4
  36. omdev/ci/docker/buildcaching.py +3 -1
  37. omdev/ci/docker/cache.py +2 -1
  38. omdev/ci/docker/cacheserved/cache.py +4 -1
  39. omdev/ci/docker/cacheserved/manifests.py +2 -2
  40. omdev/ci/docker/dataserver.py +2 -2
  41. omdev/ci/docker/imagepulling.py +2 -1
  42. omdev/ci/docker/packing.py +1 -1
  43. omdev/ci/docker/repositories.py +2 -1
  44. omdev/ci/github/api/clients.py +8 -4
  45. omdev/ci/github/api/v1/client.py +4 -1
  46. omdev/ci/github/api/v2/api.py +2 -0
  47. omdev/ci/github/api/v2/azure.py +4 -1
  48. omdev/ci/github/api/v2/client.py +4 -1
  49. omdev/cli/clicli.py +37 -7
  50. omdev/clipboard/clipboard.py +1 -1
  51. omdev/cmake.py +2 -1
  52. omdev/cmdlog/cli.py +1 -2
  53. omdev/dataclasses/_dumping.py +1960 -0
  54. omdev/dataclasses/_template.py +22 -0
  55. omdev/dataclasses/cli.py +7 -2
  56. omdev/dataclasses/codegen.py +342 -62
  57. omdev/dataclasses/dumping.py +200 -0
  58. omdev/dataserver/handlers.py +3 -2
  59. omdev/dataserver/targets.py +2 -2
  60. omdev/imgur.py +2 -2
  61. omdev/interp/cli.py +1 -1
  62. omdev/interp/inspect.py +2 -1
  63. omdev/interp/providers/base.py +3 -2
  64. omdev/interp/providers/standalone.py +4 -1
  65. omdev/interp/providers/system.py +2 -2
  66. omdev/interp/pyenv/install.py +2 -1
  67. omdev/interp/pyenv/provider.py +2 -2
  68. omdev/interp/types.py +3 -2
  69. omdev/interp/uv/provider.py +40 -2
  70. omdev/interp/uv/uv.py +2 -2
  71. omdev/interp/venvs.py +3 -2
  72. omdev/irc/messages/base.py +50 -0
  73. omdev/irc/messages/formats.py +92 -0
  74. omdev/irc/messages/messages.py +775 -0
  75. omdev/irc/messages/parsing.py +99 -0
  76. omdev/irc/numerics/formats.py +97 -0
  77. omdev/irc/numerics/numerics.py +865 -0
  78. omdev/irc/numerics/types.py +59 -0
  79. omdev/irc/protocol/LICENSE +11 -0
  80. omdev/irc/protocol/__init__.py +61 -0
  81. omdev/irc/protocol/consts.py +6 -0
  82. omdev/irc/protocol/errors.py +30 -0
  83. omdev/irc/protocol/message.py +21 -0
  84. omdev/irc/protocol/nuh.py +55 -0
  85. omdev/irc/protocol/parsing.py +158 -0
  86. omdev/irc/protocol/rendering.py +153 -0
  87. omdev/irc/protocol/tags.py +102 -0
  88. omdev/irc/protocol/utils.py +30 -0
  89. omdev/manifests/_dumping.py +529 -136
  90. omdev/manifests/building.py +6 -3
  91. omdev/manifests/main.py +1 -1
  92. omdev/markdown/__init__.py +0 -0
  93. omdev/markdown/incparse.py +116 -0
  94. omdev/markdown/tokens.py +51 -0
  95. omdev/oci/data.py +2 -2
  96. omdev/oci/datarefs.py +2 -2
  97. omdev/oci/media.py +2 -2
  98. omdev/oci/repositories.py +3 -2
  99. omdev/packaging/marshal.py +9 -9
  100. omdev/packaging/requires.py +6 -6
  101. omdev/packaging/revisions.py +5 -2
  102. omdev/packaging/specifiers.py +41 -42
  103. omdev/packaging/versions.py +10 -10
  104. omdev/packaging/wheelfile.py +4 -2
  105. omdev/precheck/blanklines.py +66 -0
  106. omdev/precheck/caches.py +1 -1
  107. omdev/precheck/imports.py +14 -1
  108. omdev/precheck/lite.py +2 -2
  109. omdev/precheck/main.py +5 -5
  110. omdev/precheck/unicode.py +39 -15
  111. omdev/py/asts/__init__.py +0 -0
  112. omdev/py/asts/parents.py +28 -0
  113. omdev/py/asts/toplevel.py +123 -0
  114. omdev/py/asts/visitors.py +18 -0
  115. omdev/py/attrdocs.py +6 -7
  116. omdev/py/bracepy.py +12 -4
  117. omdev/py/docstrings/numpydoc.py +4 -4
  118. omdev/py/reprs.py +32 -0
  119. omdev/py/scripts/execstat.py +31 -26
  120. omdev/py/srcheaders.py +1 -1
  121. omdev/py/tokens/__init__.py +0 -0
  122. omdev/{tokens → py/tokens}/utils.py +2 -1
  123. omdev/py/tools/importscan.py +2 -2
  124. omdev/py/tools/mkrelimp.py +3 -4
  125. omdev/py/tools/pipdepup.py +686 -0
  126. omdev/pyproject/cli.py +1 -1
  127. omdev/pyproject/pkg.py +197 -48
  128. omdev/pyproject/reqs.py +36 -10
  129. omdev/pyproject/tools/__init__.py +0 -0
  130. omdev/pyproject/tools/aboutdeps.py +60 -0
  131. omdev/pyproject/venvs.py +12 -2
  132. omdev/rs/__init__.py +0 -0
  133. omdev/scripts/ci.py +9551 -6982
  134. omdev/scripts/interp.py +1323 -892
  135. omdev/scripts/lib/__init__.py +0 -0
  136. omdev/scripts/lib/inject.py +2086 -0
  137. omdev/scripts/lib/logs.py +2175 -0
  138. omdev/scripts/lib/marshal.py +1731 -0
  139. omdev/scripts/pyproject.py +4979 -1874
  140. omdev/tools/docker.py +19 -7
  141. omdev/tools/git/cli.py +56 -16
  142. omdev/tools/git/messages.py +2 -2
  143. omdev/tools/json/cli.py +6 -6
  144. omdev/tools/json/formats.py +2 -0
  145. omdev/tools/json/parsing.py +5 -5
  146. omdev/tools/json/processing.py +6 -3
  147. omdev/tools/json/rendering.py +2 -2
  148. omdev/tools/jsonview/cli.py +49 -65
  149. omdev/tools/jsonview/resources/jsonview.html.j2 +43 -0
  150. omdev/tools/pawk/README.md +195 -0
  151. omdev/tools/pawk/pawk.py +2 -2
  152. omdev/tools/pip.py +8 -0
  153. omdev/tui/__init__.py +0 -0
  154. omdev/tui/apps/__init__.py +0 -0
  155. omdev/tui/apps/edit/__init__.py +0 -0
  156. omdev/tui/apps/edit/main.py +167 -0
  157. omdev/tui/apps/irc/__init__.py +0 -0
  158. omdev/tui/apps/irc/__main__.py +4 -0
  159. omdev/tui/apps/irc/app.py +286 -0
  160. omdev/tui/apps/irc/client.py +187 -0
  161. omdev/tui/apps/irc/commands.py +175 -0
  162. omdev/tui/apps/irc/main.py +26 -0
  163. omdev/tui/apps/markdown/__init__.py +0 -0
  164. omdev/tui/apps/markdown/__main__.py +11 -0
  165. omdev/{ptk → tui/apps}/markdown/cli.py +5 -7
  166. omdev/tui/rich/__init__.py +46 -0
  167. omdev/tui/rich/console2.py +20 -0
  168. omdev/tui/rich/markdown2.py +186 -0
  169. omdev/tui/textual/__init__.py +265 -0
  170. omdev/tui/textual/app2.py +16 -0
  171. omdev/tui/textual/autocomplete/LICENSE +21 -0
  172. omdev/tui/textual/autocomplete/__init__.py +33 -0
  173. omdev/tui/textual/autocomplete/matching.py +226 -0
  174. omdev/tui/textual/autocomplete/paths.py +202 -0
  175. omdev/tui/textual/autocomplete/widget.py +612 -0
  176. omdev/tui/textual/debug/__init__.py +10 -0
  177. omdev/tui/textual/debug/dominfo.py +151 -0
  178. omdev/tui/textual/debug/screen.py +24 -0
  179. omdev/tui/textual/devtools.py +187 -0
  180. omdev/tui/textual/drivers2.py +55 -0
  181. omdev/tui/textual/logging2.py +20 -0
  182. omdev/tui/textual/types.py +45 -0
  183. {omdev-0.0.0.dev416.dist-info → omdev-0.0.0.dev500.dist-info}/METADATA +18 -12
  184. omdev-0.0.0.dev500.dist-info/RECORD +386 -0
  185. omdev/ptk/__init__.py +0 -103
  186. omdev/ptk/apps/ncdu.py +0 -167
  187. omdev/ptk/confirm.py +0 -60
  188. omdev/ptk/markdown/LICENSE +0 -22
  189. omdev/ptk/markdown/__init__.py +0 -10
  190. omdev/ptk/markdown/__main__.py +0 -11
  191. omdev/ptk/markdown/border.py +0 -94
  192. omdev/ptk/markdown/markdown.py +0 -390
  193. omdev/ptk/markdown/parser.py +0 -42
  194. omdev/ptk/markdown/styles.py +0 -29
  195. omdev/ptk/markdown/tags.py +0 -299
  196. omdev/ptk/markdown/utils.py +0 -366
  197. omdev/pyproject/cexts.py +0 -110
  198. omdev/tools/antlr/__main__.py +0 -11
  199. omdev/tools/antlr/cli.py +0 -62
  200. omdev/tools/antlr/consts.py +0 -7
  201. omdev/tools/antlr/gen.py +0 -188
  202. omdev-0.0.0.dev416.dist-info/RECORD +0 -332
  203. /omdev/{ptk/apps → irc}/__init__.py +0 -0
  204. /omdev/{tokens → irc/messages}/__init__.py +0 -0
  205. /omdev/{tools/antlr → irc/numerics}/__init__.py +0 -0
  206. /omdev/{tokens → py/tokens}/all.py +0 -0
  207. /omdev/{tokens → py/tokens}/tokenizert.py +0 -0
  208. {omdev-0.0.0.dev416.dist-info → omdev-0.0.0.dev500.dist-info}/WHEEL +0 -0
  209. {omdev-0.0.0.dev416.dist-info → omdev-0.0.0.dev500.dist-info}/entry_points.txt +0 -0
  210. {omdev-0.0.0.dev416.dist-info → omdev-0.0.0.dev500.dist-info}/licenses/LICENSE +0 -0
  211. {omdev-0.0.0.dev416.dist-info → omdev-0.0.0.dev500.dist-info}/top_level.txt +0 -0
@@ -27,7 +27,7 @@
27
27
  "module": ".cexts.cmake",
28
28
  "attr": "_CLI_MODULE",
29
29
  "file": "omdev/cexts/cmake.py",
30
- "line": 333,
30
+ "line": 335,
31
31
  "value": {
32
32
  "!.cli.types.CliModule": {
33
33
  "name": "cmake",
@@ -39,7 +39,7 @@
39
39
  "module": ".cli.clicli",
40
40
  "attr": "_CLI_MODULE",
41
41
  "file": "omdev/cli/clicli.py",
42
- "line": 233,
42
+ "line": 263,
43
43
  "value": {
44
44
  "!.cli.types.CliModule": {
45
45
  "name": "cli",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  {
75
75
  "module": ".imgur",
76
- "attr": "_FOO_CLI_MODULE",
76
+ "attr": "_CLI_MODULE",
77
77
  "file": "omdev/imgur.py",
78
78
  "line": 136,
79
79
  "value": {
@@ -157,38 +157,11 @@
157
157
  }
158
158
  }
159
159
  },
160
- {
161
- "module": ".ptk.apps.ncdu",
162
- "attr": "_CLI_MODULE",
163
- "file": "omdev/ptk/apps/ncdu.py",
164
- "line": 162,
165
- "value": {
166
- "!.cli.types.CliModule": {
167
- "name": "ptk/ncdu",
168
- "module": "omdev.ptk.apps.ncdu"
169
- }
170
- }
171
- },
172
- {
173
- "module": ".ptk.markdown.__main__",
174
- "attr": "_CLI_MODULE",
175
- "file": "omdev/ptk/markdown/__main__.py",
176
- "line": 4,
177
- "value": {
178
- "!.cli.types.CliModule": {
179
- "name": [
180
- "ptk/markdown",
181
- "ptk/md"
182
- ],
183
- "module": "omdev.ptk.markdown.__main__"
184
- }
185
- }
186
- },
187
160
  {
188
161
  "module": ".py.attrdocs",
189
162
  "attr": "_CLI_MODULE",
190
163
  "file": "omdev/py/attrdocs.py",
191
- "line": 160,
164
+ "line": 159,
192
165
  "value": {
193
166
  "!.cli.types.CliModule": {
194
167
  "name": "py/attrdocs",
@@ -236,7 +209,7 @@
236
209
  "module": ".py.scripts.execstat",
237
210
  "attr": "_CLI_MODULE",
238
211
  "file": "omdev/py/scripts/execstat.py",
239
- "line": 89,
212
+ "line": 92,
240
213
  "value": {
241
214
  "!.cli.types.CliModule": {
242
215
  "name": "py/execstat",
@@ -284,7 +257,7 @@
284
257
  "module": ".py.tools.mkrelimp",
285
258
  "attr": "_CLI_MODULE",
286
259
  "file": "omdev/py/tools/mkrelimp.py",
287
- "line": 149,
260
+ "line": 148,
288
261
  "value": {
289
262
  "!.cli.types.CliModule": {
290
263
  "name": "py/mkrelimp",
@@ -328,18 +301,6 @@
328
301
  }
329
302
  }
330
303
  },
331
- {
332
- "module": ".tools.antlr.__main__",
333
- "attr": "_CLI_MODULE",
334
- "file": "omdev/tools/antlr/__main__.py",
335
- "line": 4,
336
- "value": {
337
- "!.cli.types.CliModule": {
338
- "name": "antlr",
339
- "module": "omdev.tools.antlr.__main__"
340
- }
341
- }
342
- },
343
304
  {
344
305
  "module": ".tools.cloc",
345
306
  "attr": "_CLI_MODULE",
@@ -380,7 +341,7 @@
380
341
  "module": ".tools.docker",
381
342
  "attr": "_CLI_MODULE",
382
343
  "file": "omdev/tools/docker.py",
383
- "line": 259,
344
+ "line": 271,
384
345
  "value": {
385
346
  "!.cli.types.CliModule": {
386
347
  "name": "docker",
@@ -503,7 +464,7 @@
503
464
  "module": ".tools.pip",
504
465
  "attr": "_CLI_MODULE",
505
466
  "file": "omdev/tools/pip.py",
506
- "line": 123,
467
+ "line": 131,
507
468
  "value": {
508
469
  "!.cli.types.CliModule": {
509
470
  "name": "pip",
@@ -573,5 +534,20 @@
573
534
  "module": "omdev.tools.sqlrepl"
574
535
  }
575
536
  }
537
+ },
538
+ {
539
+ "module": ".tui.apps.markdown.__main__",
540
+ "attr": "_CLI_MODULE",
541
+ "file": "omdev/tui/apps/markdown/__main__.py",
542
+ "line": 4,
543
+ "value": {
544
+ "!.cli.types.CliModule": {
545
+ "name": [
546
+ "tui/markdown",
547
+ "tui/md"
548
+ ],
549
+ "module": "omdev.tui.apps.markdown.__main__"
550
+ }
551
+ }
576
552
  }
577
553
  ]
omdev/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Overview
2
+
3
+ Development utilities and support code.
4
+
5
+ # Notable packages
6
+
7
+ - **[cli](https://github.com/wrmsr/omlish/blob/master/omdev/cli)** - The codebase's all-in-one CLI. This is not
8
+ installed as an entrypoint / command when this package is itself installed - that is separated into the `omdev-cli`
9
+ installable package so as to not pollute users' bin/ directories when depping this lib for its utility code.
10
+
11
+ - **[amalg](https://github.com/wrmsr/omlish/blob/master/omdev/amalg)** - The [amalgamator](#amalgamation).
12
+
13
+ - **[pyproject](https://github.com/wrmsr/omlish/blob/master/omdev/pyproject)**
14
+ ([amalg](https://github.com/wrmsr/omlish/blob/master/omdev/scripts/pyproject.py)) - python project management tool.
15
+ wrangles but does not replace tools like venv, pip, setuptools, and uv. does things like sets up venvs, generates
16
+ [`.pkg`](https://github.com/wrmsr/omlish/blob/master/.pkg) directories and their `pyproject.toml`'s (from their
17
+ `__about__.py`'s), and packages them. this should grow to eat more and more of the Makefile. as it is amalgamated it
18
+ requires no installation and can just be dropped into other projects / repos.
19
+
20
+ - **[ci](https://github.com/wrmsr/omlish/blob/master/omdev/ci)**
21
+ ([amalg](https://github.com/wrmsr/omlish/blob/master/omdev/scripts/ci.py)) - ci runner. given a
22
+ [`compose.yml`](https://github.com/wrmsr/omlish/blob/master/docker/compose.yml)
23
+ and requirements.txt files, takes care of building and caching of containers and venvs and execution of required ci
24
+ commands. detects and [natively uses](https://github.com/wrmsr/omlish/blob/master/omdev/ci/github/api/v2)
25
+ github-action's caching system. unifies ci execution between local dev and github runners.
26
+
27
+ - **[tools.json](https://github.com/wrmsr/omlish/blob/master/omdev/tools/json)** (cli: `om j`) - a tool for json-like
28
+ data, obviously in the vein of [jq](https://github.com/jqlang/jq) but using the internal
29
+ [jmespath](https://github.com/wrmsr/omlish/blob/master/omlish/specs/jmespath) engine. supports
30
+ [true streaming](https://github.com/wrmsr/omlish/blob/master/omlish/formats/json/stream) json input and output, as
31
+ well as [various other](https://github.com/wrmsr/omlish/blob/master/omdev/tools/json/formats.py) non-streaming input
32
+ formats.
33
+
34
+ - **[tools.git](https://github.com/wrmsr/omlish/blob/master/omdev/tools/git)** (cli: `om git`) - a tool for various lazy
35
+ git operations, including the one that (poorly) writes all of these commit messages.
36
+
37
+ # Amalgamation
38
+
39
+ Amalgamation is the process of stitching together multiple python source files into a single self-contained python
40
+ script. ['lite'](https://github.com/wrmsr/omlish/blob/master/omlish#lite-code) code is written in a style conducive to
41
+ this.
42
+
43
+ # Local storage
44
+
45
+ Some of this code, when asked, will store things on the local filesystem. The only directories used (outside of ones
46
+ explicitly specified as command or function arguments) are managed in
47
+ [home.paths](https://github.com/wrmsr/omlish/blob/master/omdev/home/paths.py), and are the following:
48
+
49
+ - `$OMLISH_HOME`, default of `~/.omlish` - persistent things like config and state.
50
+ - `$OMLISH_CACHE`, default of `~/.cache/omlish` - used for things like the local ci cache and
51
+ [various other](https://github.com/search?q=repo%3Awrmsr%2Fomlish+%22dcache.%22&type=code) cached data.
omdev/__about__.py CHANGED
@@ -13,11 +13,11 @@ class Project(ProjectBase):
13
13
 
14
14
  optional_dependencies = {
15
15
  'black': [
16
- 'black ~= 25.1',
16
+ 'black ~= 25.12',
17
17
  ],
18
18
 
19
19
  'c': [
20
- 'pycparser ~= 2.22',
20
+ 'pycparser ~= 2.23',
21
21
  'pcpp ~= 1.30',
22
22
  ],
23
23
 
@@ -31,20 +31,23 @@ class Project(ProjectBase):
31
31
  ],
32
32
 
33
33
  'mypy': [
34
- 'mypy ~= 1.17',
34
+ 'mypy ~= 1.19',
35
35
  ],
36
36
 
37
37
  'prof': [
38
38
  'gprof2dot ~= 2025.4',
39
39
  ],
40
40
 
41
- 'ptk': [
42
- 'prompt-toolkit ~= 3.0',
43
- ],
44
-
45
41
  'qr': [
46
42
  'segno ~= 1.6',
47
43
  ],
44
+
45
+ 'tui': [
46
+ 'rich ~= 14.2',
47
+ 'textual ~= 7.0', # [syntax]
48
+ 'textual-dev ~= 1.8',
49
+ 'textual-speedups ~= 0.2',
50
+ ],
48
51
  }
49
52
 
50
53
  entry_points = {
@@ -57,7 +60,8 @@ class Project(ProjectBase):
57
60
 
58
61
 
59
62
  class Setuptools(SetuptoolsBase):
60
- cexts = True
63
+ cext = True
64
+ rs = True
61
65
 
62
66
  find_packages = {
63
67
  'include': [Project.name, f'{Project.name}.*'],
omdev/amalg/cli/main.py CHANGED
@@ -26,7 +26,6 @@ Targets:
26
26
  - supervisor?
27
27
  """
28
28
  import argparse
29
- import logging
30
29
  import os.path
31
30
  import stat
32
31
  import typing as ta
@@ -38,7 +37,7 @@ from ..gen.gen import SCAN_COMMENT
38
37
  from ..gen.gen import AmalgGenerator
39
38
 
40
39
 
41
- log = logging.getLogger(__name__)
40
+ log = logs.get_module_logger(globals())
42
41
 
43
42
 
44
43
  ##
omdev/amalg/gen/gen.py CHANGED
@@ -9,7 +9,8 @@ from omlish.algorithm import all as alg
9
9
  from omlish.lite.runtime import LITE_REQUIRED_PYTHON_VERSION
10
10
 
11
11
  from ...git.magic import GIT_DIFF_OMIT_MAGIC
12
- from ...tokens import all as tks
12
+ from ...py.tokens import all as tks
13
+ from ..info import AMALG_INFO_ATTR
13
14
  from .srcfiles import SrcFile
14
15
  from .srcfiles import make_src_file
15
16
  from .strip import strip_main_lines
@@ -32,18 +33,22 @@ SCAN_COMMENT = '# @omlish-amalg '
32
33
 
33
34
 
34
35
  class AmalgGenerator:
36
+ DEFAULT_TARGET_LINE_LEN: ta.ClassVar[int] = 120
37
+
35
38
  def __init__(
36
39
  self,
37
40
  main_path: str,
38
41
  *,
39
42
  mounts: ta.Mapping[str, str],
40
43
  output_dir: str | None = None,
44
+ target_line_len: int | None = DEFAULT_TARGET_LINE_LEN,
41
45
  ) -> None:
42
46
  super().__init__()
43
47
 
44
48
  self._main_path = main_path
45
49
  self._mounts = mounts
46
50
  self._output_dir = output_dir
51
+ self._target_line_len = target_line_len
47
52
 
48
53
  @cached.function
49
54
  def _src_files(self) -> dict[str, SrcFile]:
@@ -105,6 +110,40 @@ class AmalgGenerator:
105
110
 
106
111
  return [*additional_header_lines, *header_lines]
107
112
 
113
+ def gen_amalg_info_block(self, sfs: ta.Sequence[str]) -> str:
114
+ md = os.path.dirname(self._main_path)
115
+ src_files = self._src_files()
116
+ sf_dcts = [
117
+ dict(
118
+ path=os.path.relpath(sfn, md),
119
+ sha1=src_files[sfn].sha1,
120
+ )
121
+ for sfn in sfs
122
+ ]
123
+ sf_lines = [
124
+ ''.join([
125
+ ' dict(',
126
+ ', '.join([f'{k}={v!r}' for k, v in sf_dct.items()]),
127
+ '),',
128
+ ])
129
+ for sf_dct in sf_dcts
130
+ ]
131
+ if (tll := self._target_line_len) is not None:
132
+ sf_lines = [
133
+ l + ' # noqa' if len(l) >= tll else l
134
+ for l in sf_lines
135
+ ]
136
+
137
+ return '\n'.join([
138
+ f'def {AMALG_INFO_ATTR}(): # noqa',
139
+ f' return dict(',
140
+ f' src_files=[',
141
+ *sf_lines,
142
+ f' ],',
143
+ f' )',
144
+ '',
145
+ ])
146
+
108
147
  @cached.function
109
148
  def gen_amalg(self) -> str:
110
149
  src_files = self._src_files()
@@ -137,6 +176,13 @@ class AmalgGenerator:
137
176
  out.write(il if isinstance(il, str) else tks.join_toks(il.toks))
138
177
  if dct:
139
178
  out.write('\n\n')
179
+ ##
180
+
181
+ ts = list(alg.toposort({ # noqa
182
+ f.path: {mp for i in f.imports if (mp := i.mod_path) is not None}
183
+ for f in src_files.values()
184
+ }))
185
+ sfs = [sf for ss in ts for sf in sorted(ss)]
140
186
 
141
187
  ##
142
188
 
@@ -155,11 +201,8 @@ class AmalgGenerator:
155
201
 
156
202
  ##
157
203
 
158
- ts = list(alg.toposort({ # noqa
159
- f.path: {mp for i in f.imports if (mp := i.mod_path) is not None}
160
- for f in src_files.values()
161
- }))
162
- sfs = [sf for ss in ts for sf in sorted(ss)]
204
+ out.write(self.gen_amalg_info_block(sfs))
205
+ out.write('\n\n')
163
206
 
164
207
  ##
165
208
 
@@ -4,7 +4,7 @@ import typing as ta
4
4
 
5
5
  from omlish import check
6
6
 
7
- from ...tokens import all as tks
7
+ from ...py.tokens import all as tks
8
8
 
9
9
 
10
10
  ##
@@ -2,7 +2,7 @@ import ast
2
2
 
3
3
  from omlish import check
4
4
 
5
- from ...tokens import all as tks
5
+ from ...py.tokens import all as tks
6
6
 
7
7
 
8
8
  ##
@@ -4,7 +4,7 @@ import itertools
4
4
  import os.path
5
5
  import typing as ta
6
6
 
7
- from ...tokens import all as tks
7
+ from ...py.tokens import all as tks
8
8
 
9
9
 
10
10
  ##
@@ -1,10 +1,11 @@
1
1
  import dataclasses as dc
2
+ import hashlib
2
3
  import typing as ta
3
4
 
4
5
  from omlish import collections as col
5
6
  from omlish import lang
6
7
 
7
- from ...tokens import all as tks
8
+ from ...py.tokens import all as tks
8
9
  from .imports import Import
9
10
  from .imports import make_import
10
11
  from .manifests import comment_out_manifest_comment
@@ -26,6 +27,9 @@ from .typing import skip_root_level_if_type_checking_block
26
27
  class SrcFile:
27
28
  path: str
28
29
 
30
+ src_bytes: bytes = dc.field(repr=False)
31
+ sha1: str = dc.field(repr=False)
32
+
29
33
  src: str = dc.field(repr=False)
30
34
  tokens: tks.Tokens = dc.field(repr=False)
31
35
  lines: ta.Sequence[tks.Tokens] = dc.field(repr=False)
@@ -40,17 +44,33 @@ class SrcFile:
40
44
  has_binary_resources: bool = False
41
45
 
42
46
 
47
+ def drop_amalg_comment_lines(lines: ta.Iterable[tks.Tokens]) -> list[tks.Tokens]:
48
+ out: list[tks.Tokens] = []
49
+ for l in lines:
50
+ cl = list(tks.ignore_ws(l, drop_nl=True, keep=['COMMENT']))
51
+ if len(cl) == 1 and (t := cl[0]).name == 'COMMENT':
52
+ if t.src.split()[1:2] == ['@omlish-amalg']:
53
+ continue
54
+ out.append(l)
55
+ return out
56
+
57
+
43
58
  def make_src_file(
44
59
  path: str,
45
60
  *,
46
61
  mounts: ta.Mapping[str, str],
47
62
  ) -> SrcFile:
48
- with open(path) as f:
49
- src = f.read().strip()
63
+ with open(path, 'rb') as f:
64
+ src_bytes = f.read()
50
65
 
66
+ sha1 = hashlib.sha1(src_bytes).hexdigest() # noqa
67
+
68
+ src = src_bytes.decode('utf-8').strip()
51
69
  tokens = tks.src_to_tokens(src)
52
70
  lines = tks.split_lines(tokens)
53
71
 
72
+ lines = drop_amalg_comment_lines(lines)
73
+
54
74
  header_lines, cls = split_header_lines(lines)
55
75
 
56
76
  header_lines = strip_header_lines(header_lines)
@@ -102,6 +122,9 @@ def make_src_file(
102
122
  return SrcFile(
103
123
  path=path,
104
124
 
125
+ src_bytes=src_bytes,
126
+ sha1=sha1,
127
+
105
128
  src=src,
106
129
  tokens=tokens,
107
130
  lines=lines,
omdev/amalg/gen/strip.py CHANGED
@@ -2,7 +2,7 @@ import re
2
2
  import typing as ta
3
3
 
4
4
  from ... import magic
5
- from ...tokens import all as tks
5
+ from ...py.tokens import all as tks
6
6
 
7
7
 
8
8
  ##
omdev/amalg/gen/types.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import typing as ta
2
2
 
3
- from ...tokens import all as tks
3
+ from ...py.tokens import all as tks
4
4
 
5
5
 
6
6
  Tokens: ta.TypeAlias = tks.Tokens
omdev/amalg/gen/typing.py CHANGED
@@ -2,7 +2,7 @@ import dataclasses as dc
2
2
 
3
3
  from omlish import check
4
4
 
5
- from ...tokens import all as tks
5
+ from ...py.tokens import all as tks
6
6
 
7
7
 
8
8
  ##
omdev/amalg/info.py ADDED
@@ -0,0 +1,32 @@
1
+ # ruff: noqa: UP045
2
+ # @omlish-lite
3
+ import typing as ta
4
+
5
+
6
+ ##
7
+
8
+
9
+ AMALG_INFO_ATTR = '__omlish_amalg__'
10
+
11
+
12
+ class AmalgInfoSrcFile(ta.NamedTuple):
13
+ path: str
14
+ sha1: str
15
+
16
+
17
+ class AmalgInfo(ta.NamedTuple):
18
+ src_files: ta.Sequence[AmalgInfoSrcFile]
19
+
20
+
21
+ def get_amalg_info() -> ta.Optional[AmalgInfo]:
22
+ try:
23
+ fn = globals()[AMALG_INFO_ATTR]
24
+ except KeyError:
25
+ return None
26
+ dct = fn()
27
+ dct['src_files'] = [AmalgInfoSrcFile(**sf_dct) for sf_dct in dct['src_files']]
28
+ return AmalgInfo(**dct)
29
+
30
+
31
+ def is_amalg() -> bool:
32
+ return AMALG_INFO_ATTR in globals()
@@ -1,5 +1,7 @@
1
1
  import abc
2
2
 
3
+ from omlish import lang
4
+
3
5
  from .types import CacheEntry
4
6
  from .types import CacheKey
5
7
 
@@ -7,7 +9,7 @@ from .types import CacheKey
7
9
  ##
8
10
 
9
11
 
10
- class Storage(abc.ABC):
12
+ class Storage(lang.Abstract):
11
13
  @abc.abstractmethod
12
14
  def get(self, key: CacheKey) -> CacheEntry | None:
13
15
  raise NotImplementedError
@@ -39,7 +39,7 @@ class ExtractAction(Action, lang.Final):
39
39
 
40
40
 
41
41
  @lang.static_init
42
- def _install_standard_marshalling() -> None:
42
+ def _install_standard_marshaling() -> None:
43
43
  actions_poly = msh.polymorphism_from_subclasses(Action, naming=msh.Naming.SNAKE, strip_suffix=True)
44
44
  msh.install_standard_factories(
45
45
  msh.PolymorphismMarshalerFactory(actions_poly),
omdev/cache/data/cache.py CHANGED
@@ -11,7 +11,6 @@ TODO:
11
11
  - download resume ala hf_hub
12
12
  """
13
13
  import contextlib
14
- import logging
15
14
  import os.path
16
15
  import shutil
17
16
  import subprocess
@@ -25,6 +24,7 @@ from omlish import check
25
24
  from omlish import lang
26
25
  from omlish import marshal as msh
27
26
  from omlish.formats import json
27
+ from omlish.logs import all as logs
28
28
  from omlish.os.files import touch
29
29
 
30
30
  from ...git.shallow import git_shallow_clone
@@ -37,7 +37,7 @@ from .specs import Spec
37
37
  from .specs import UrlSpec
38
38
 
39
39
 
40
- log = logging.getLogger(__name__)
40
+ log = logs.get_module_logger(globals())
41
41
 
42
42
 
43
43
  ##
omdev/cache/data/specs.py CHANGED
@@ -93,7 +93,7 @@ class GithubContentSpec(Spec):
93
93
 
94
94
 
95
95
  @lang.static_init
96
- def _install_standard_marshalling() -> None:
96
+ def _install_standard_marshaling() -> None:
97
97
  specs_poly = msh.polymorphism_from_subclasses(Spec, naming=msh.Naming.SNAKE, strip_suffix=True)
98
98
  msh.install_standard_factories(
99
99
  msh.PolymorphismMarshalerFactory(specs_poly),
@@ -54,9 +54,8 @@ static PyMethodDef boilerplate_methods[] = {
54
54
 
55
55
  static struct PyModuleDef_Slot boilerplate_slots[] = {
56
56
  {Py_mod_exec, (void *) boilerplate_exec},
57
- // #if PY_VERSION_HEX >= 0x030D0000
58
- // {Py_mod_gil, Py_MOD_GIL_NOT_USED},
59
- // #endif
57
+ {Py_mod_gil, Py_MOD_GIL_NOT_USED},
58
+ {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED},
60
59
  {0, NULL}
61
60
  };
62
61
 
@@ -37,7 +37,6 @@ License Agreement.
37
37
  """
38
38
  import contextlib
39
39
  import dataclasses as dc
40
- import logging
41
40
  import os
42
41
  import site
43
42
  import sys
@@ -46,6 +45,7 @@ import typing as ta
46
45
  from omlish import cached
47
46
  from omlish import check
48
47
  from omlish import lang
48
+ from omlish.logs import all as logs
49
49
 
50
50
  from . import compilers
51
51
  from . import errors
@@ -55,7 +55,10 @@ from . import sysconfig
55
55
  from . import util
56
56
 
57
57
 
58
- log = logging.getLogger(__name__)
58
+ log = logs.get_module_logger(globals())
59
+
60
+
61
+ ##
59
62
 
60
63
 
61
64
  def _get_str_config_var(name: str) -> str:
@@ -1,7 +1,6 @@
1
1
  """
2
2
  Contains CCompiler, an abstract base class that defines the interface for the Distutils compiler abstraction model.
3
3
  """
4
- import logging
5
4
  import os
6
5
  import re
7
6
  import sys
@@ -9,6 +8,7 @@ import typing as ta
9
8
  import warnings
10
9
 
11
10
  from omlish import check
11
+ from omlish.logs import all as logs
12
12
 
13
13
  from ..dir_util import mkpath
14
14
  from ..errors import CompileError
@@ -25,7 +25,10 @@ from .options import Macro
25
25
  from .options import gen_preprocess_options
26
26
 
27
27
 
28
- log = logging.getLogger(__name__)
28
+ log = logs.get_module_logger(globals())
29
+
30
+
31
+ ##
29
32
 
30
33
 
31
34
  class CCompiler:
@@ -4,6 +4,9 @@ import typing as ta
4
4
  from ..util import always_iterable
5
5
 
6
6
 
7
+ ##
8
+
9
+
7
10
  Macro: ta.TypeAlias = tuple[str, str | None] | tuple[str]
8
11
 
9
12