omdev 0.0.0.dev440__py3-none-any.whl → 0.0.0.dev495__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 (148) hide show
  1. omdev/.omlish-manifests.json +18 -30
  2. omdev/README.md +51 -0
  3. omdev/__about__.py +11 -7
  4. omdev/amalg/gen/gen.py +49 -6
  5. omdev/amalg/gen/imports.py +1 -1
  6. omdev/amalg/gen/manifests.py +1 -1
  7. omdev/amalg/gen/resources.py +1 -1
  8. omdev/amalg/gen/srcfiles.py +13 -3
  9. omdev/amalg/gen/strip.py +1 -1
  10. omdev/amalg/gen/types.py +1 -1
  11. omdev/amalg/gen/typing.py +1 -1
  12. omdev/amalg/info.py +32 -0
  13. omdev/cache/data/actions.py +1 -1
  14. omdev/cache/data/specs.py +1 -1
  15. omdev/cexts/_boilerplate.cc +2 -3
  16. omdev/cexts/cmake.py +4 -1
  17. omdev/ci/cli.py +2 -3
  18. omdev/cli/clicli.py +37 -7
  19. omdev/cmdlog/cli.py +1 -2
  20. omdev/dataclasses/_dumping.py +1960 -0
  21. omdev/dataclasses/_template.py +22 -0
  22. omdev/dataclasses/cli.py +7 -2
  23. omdev/dataclasses/codegen.py +340 -60
  24. omdev/dataclasses/dumping.py +200 -0
  25. omdev/interp/cli.py +1 -1
  26. omdev/interp/types.py +3 -2
  27. omdev/interp/uv/provider.py +37 -0
  28. omdev/interp/venvs.py +1 -0
  29. omdev/irc/messages/base.py +50 -0
  30. omdev/irc/messages/formats.py +92 -0
  31. omdev/irc/messages/messages.py +775 -0
  32. omdev/irc/messages/parsing.py +99 -0
  33. omdev/irc/numerics/__init__.py +0 -0
  34. omdev/irc/numerics/formats.py +97 -0
  35. omdev/irc/numerics/numerics.py +865 -0
  36. omdev/irc/numerics/types.py +59 -0
  37. omdev/irc/protocol/LICENSE +11 -0
  38. omdev/irc/protocol/__init__.py +61 -0
  39. omdev/irc/protocol/consts.py +6 -0
  40. omdev/irc/protocol/errors.py +30 -0
  41. omdev/irc/protocol/message.py +21 -0
  42. omdev/irc/protocol/nuh.py +55 -0
  43. omdev/irc/protocol/parsing.py +158 -0
  44. omdev/irc/protocol/rendering.py +153 -0
  45. omdev/irc/protocol/tags.py +102 -0
  46. omdev/irc/protocol/utils.py +30 -0
  47. omdev/manifests/_dumping.py +125 -25
  48. omdev/manifests/main.py +1 -1
  49. omdev/markdown/__init__.py +0 -0
  50. omdev/markdown/incparse.py +116 -0
  51. omdev/markdown/tokens.py +51 -0
  52. omdev/packaging/marshal.py +8 -8
  53. omdev/packaging/requires.py +6 -6
  54. omdev/packaging/revisions.py +1 -1
  55. omdev/packaging/specifiers.py +2 -1
  56. omdev/packaging/versions.py +4 -4
  57. omdev/packaging/wheelfile.py +2 -0
  58. omdev/precheck/blanklines.py +66 -0
  59. omdev/precheck/caches.py +1 -1
  60. omdev/precheck/imports.py +14 -1
  61. omdev/precheck/main.py +4 -3
  62. omdev/precheck/unicode.py +39 -15
  63. omdev/py/asts/__init__.py +0 -0
  64. omdev/py/asts/parents.py +28 -0
  65. omdev/py/asts/toplevel.py +123 -0
  66. omdev/py/asts/visitors.py +18 -0
  67. omdev/py/attrdocs.py +1 -1
  68. omdev/py/bracepy.py +12 -4
  69. omdev/py/reprs.py +32 -0
  70. omdev/py/srcheaders.py +1 -1
  71. omdev/py/tokens/__init__.py +0 -0
  72. omdev/py/tools/mkrelimp.py +1 -1
  73. omdev/py/tools/pipdepup.py +686 -0
  74. omdev/pyproject/cli.py +1 -1
  75. omdev/pyproject/pkg.py +190 -45
  76. omdev/pyproject/reqs.py +31 -9
  77. omdev/pyproject/tools/__init__.py +0 -0
  78. omdev/pyproject/tools/aboutdeps.py +60 -0
  79. omdev/pyproject/venvs.py +8 -1
  80. omdev/rs/__init__.py +0 -0
  81. omdev/scripts/ci.py +752 -98
  82. omdev/scripts/interp.py +232 -39
  83. omdev/scripts/lib/inject.py +74 -27
  84. omdev/scripts/lib/logs.py +187 -43
  85. omdev/scripts/lib/marshal.py +67 -25
  86. omdev/scripts/pyproject.py +1369 -143
  87. omdev/tools/git/cli.py +10 -0
  88. omdev/tools/json/formats.py +2 -0
  89. omdev/tools/json/processing.py +5 -2
  90. omdev/tools/jsonview/cli.py +49 -65
  91. omdev/tools/jsonview/resources/jsonview.html.j2 +43 -0
  92. omdev/tools/pawk/README.md +195 -0
  93. omdev/tools/pawk/pawk.py +2 -2
  94. omdev/tools/pip.py +8 -0
  95. omdev/tui/__init__.py +0 -0
  96. omdev/tui/apps/__init__.py +0 -0
  97. omdev/tui/apps/edit/__init__.py +0 -0
  98. omdev/tui/apps/edit/main.py +167 -0
  99. omdev/tui/apps/irc/__init__.py +0 -0
  100. omdev/tui/apps/irc/__main__.py +4 -0
  101. omdev/tui/apps/irc/app.py +286 -0
  102. omdev/tui/apps/irc/client.py +187 -0
  103. omdev/tui/apps/irc/commands.py +175 -0
  104. omdev/tui/apps/irc/main.py +26 -0
  105. omdev/tui/apps/markdown/__init__.py +0 -0
  106. omdev/tui/apps/markdown/__main__.py +11 -0
  107. omdev/{ptk → tui/apps}/markdown/cli.py +5 -7
  108. omdev/tui/rich/__init__.py +46 -0
  109. omdev/tui/rich/console2.py +20 -0
  110. omdev/tui/rich/markdown2.py +186 -0
  111. omdev/tui/textual/__init__.py +265 -0
  112. omdev/tui/textual/app2.py +16 -0
  113. omdev/tui/textual/autocomplete/LICENSE +21 -0
  114. omdev/tui/textual/autocomplete/__init__.py +33 -0
  115. omdev/tui/textual/autocomplete/matching.py +226 -0
  116. omdev/tui/textual/autocomplete/paths.py +202 -0
  117. omdev/tui/textual/autocomplete/widget.py +612 -0
  118. omdev/tui/textual/debug/__init__.py +10 -0
  119. omdev/tui/textual/debug/dominfo.py +151 -0
  120. omdev/tui/textual/debug/screen.py +24 -0
  121. omdev/tui/textual/devtools.py +187 -0
  122. omdev/tui/textual/drivers2.py +55 -0
  123. omdev/tui/textual/logging2.py +20 -0
  124. omdev/tui/textual/types.py +45 -0
  125. {omdev-0.0.0.dev440.dist-info → omdev-0.0.0.dev495.dist-info}/METADATA +15 -9
  126. {omdev-0.0.0.dev440.dist-info → omdev-0.0.0.dev495.dist-info}/RECORD +135 -80
  127. omdev/ptk/__init__.py +0 -103
  128. omdev/ptk/apps/ncdu.py +0 -167
  129. omdev/ptk/confirm.py +0 -60
  130. omdev/ptk/markdown/LICENSE +0 -22
  131. omdev/ptk/markdown/__init__.py +0 -10
  132. omdev/ptk/markdown/__main__.py +0 -11
  133. omdev/ptk/markdown/border.py +0 -94
  134. omdev/ptk/markdown/markdown.py +0 -390
  135. omdev/ptk/markdown/parser.py +0 -42
  136. omdev/ptk/markdown/styles.py +0 -29
  137. omdev/ptk/markdown/tags.py +0 -299
  138. omdev/ptk/markdown/utils.py +0 -366
  139. omdev/pyproject/cexts.py +0 -110
  140. /omdev/{ptk/apps → irc}/__init__.py +0 -0
  141. /omdev/{tokens → irc/messages}/__init__.py +0 -0
  142. /omdev/{tokens → py/tokens}/all.py +0 -0
  143. /omdev/{tokens → py/tokens}/tokenizert.py +0 -0
  144. /omdev/{tokens → py/tokens}/utils.py +0 -0
  145. {omdev-0.0.0.dev440.dist-info → omdev-0.0.0.dev495.dist-info}/WHEEL +0 -0
  146. {omdev-0.0.0.dev440.dist-info → omdev-0.0.0.dev495.dist-info}/entry_points.txt +0 -0
  147. {omdev-0.0.0.dev440.dist-info → omdev-0.0.0.dev495.dist-info}/licenses/LICENSE +0 -0
  148. {omdev-0.0.0.dev440.dist-info → omdev-0.0.0.dev495.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": 332,
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",
@@ -157,33 +157,6 @@
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",
@@ -491,7 +464,7 @@
491
464
  "module": ".tools.pip",
492
465
  "attr": "_CLI_MODULE",
493
466
  "file": "omdev/tools/pip.py",
494
- "line": 123,
467
+ "line": 131,
495
468
  "value": {
496
469
  "!.cli.types.CliModule": {
497
470
  "name": "pip",
@@ -561,5 +534,20 @@
561
534
  "module": "omdev.tools.sqlrepl"
562
535
  }
563
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
+ }
564
552
  }
565
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,7 +13,7 @@ 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': [
@@ -31,20 +31,23 @@ class Project(ProjectBase):
31
31
  ],
32
32
 
33
33
  'mypy': [
34
- 'mypy ~= 1.18',
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 ~= 6.11', # [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/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)
@@ -56,9 +60,12 @@ def make_src_file(
56
60
  *,
57
61
  mounts: ta.Mapping[str, str],
58
62
  ) -> SrcFile:
59
- with open(path) as f:
60
- src = f.read().strip()
63
+ with open(path, 'rb') as f:
64
+ src_bytes = f.read()
65
+
66
+ sha1 = hashlib.sha1(src_bytes).hexdigest() # noqa
61
67
 
68
+ src = src_bytes.decode('utf-8').strip()
62
69
  tokens = tks.src_to_tokens(src)
63
70
  lines = tks.split_lines(tokens)
64
71
 
@@ -115,6 +122,9 @@ def make_src_file(
115
122
  return SrcFile(
116
123
  path=path,
117
124
 
125
+ src_bytes=src_bytes,
126
+ sha1=sha1,
127
+
118
128
  src=src,
119
129
  tokens=tokens,
120
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()
@@ -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/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
 
omdev/cexts/cmake.py CHANGED
@@ -266,7 +266,10 @@ class CmakeProjectGen:
266
266
  '-g',
267
267
  '-c',
268
268
  ],
269
- ['-std=c++20'],
269
+ [
270
+ '$<$<COMPILE_LANGUAGE:C>:-std=c11>',
271
+ '$<$<COMPILE_LANGUAGE:CXX>:-std=c++20>',
272
+ ],
270
273
  ),
271
274
  ))
272
275
 
omdev/ci/cli.py CHANGED
@@ -14,7 +14,6 @@ import argparse
14
14
  import asyncio
15
15
  import itertools
16
16
  import os.path
17
- import sys
18
17
  import typing as ta
19
18
 
20
19
  from omlish.argparse.cli import ArgparseCli
@@ -23,7 +22,7 @@ from omlish.argparse.cli import argparse_cmd
23
22
  from omlish.lite.check import check
24
23
  from omlish.lite.inject import inj
25
24
  from omlish.logs.modules import get_module_logger
26
- from omlish.logs.standard import configure_standard_logging
25
+ from omlish.logs.std.standard import configure_standard_logging
27
26
 
28
27
  from .cache import DirectoryFileCache
29
28
  from .ci import Ci
@@ -260,7 +259,7 @@ async def _async_main() -> ta.Optional[int]:
260
259
  def _main() -> None:
261
260
  configure_standard_logging('DEBUG')
262
261
 
263
- sys.exit(rc if isinstance(rc := asyncio.run(_async_main()), int) else 0)
262
+ raise SystemExit(rc if isinstance(rc := asyncio.run(_async_main()), int) else 0)
264
263
 
265
264
 
266
265
  if __name__ == '__main__':
omdev/cli/clicli.py CHANGED
@@ -1,9 +1,11 @@
1
+ import dataclasses as dc
1
2
  import inspect
2
3
  import os
3
4
  import re
4
5
  import shlex
5
6
  import subprocess
6
7
  import sys
8
+ import time
7
9
  import typing as ta
8
10
  import urllib.parse
9
11
  import urllib.request
@@ -13,6 +15,7 @@ from omlish import lang
13
15
  from omlish.argparse import all as ap
14
16
  from omlish.os.temp import temp_dir_context
15
17
 
18
+ from ..packaging.versions import Version
16
19
  from ..pip import get_root_dists
17
20
  from ..pip import lookup_latest_package_version
18
21
  from . import install
@@ -87,22 +90,49 @@ class CliCli(ap.Cli):
87
90
 
88
91
  #
89
92
 
93
+ @dc.dataclass()
94
+ class ReinstallWouldNotUpgradeError(Exception):
95
+ current_version: str
96
+ target_version: str
97
+
98
+ def __str__(self) -> str:
99
+ return f'Current version {self.current_version} is not older than target version {self.target_version} '
100
+
90
101
  @ap.cmd(
91
102
  ap.arg('--url', default=DEFAULT_REINSTALL_URL),
92
103
  ap.arg('--local', action='store_true'),
93
104
  ap.arg('--no-deps', action='store_true'),
94
105
  ap.arg('--no-uv', action='store_true'),
95
106
  ap.arg('--dry-run', action='store_true'),
107
+ ap.arg('--must-upgrade', action='store_true'),
108
+ ap.arg('--must-upgrade-loop', action='store_true'),
96
109
  ap.arg('--version'),
97
110
  ap.arg('extra_deps', nargs='*'),
98
111
  )
99
112
  def reinstall(self) -> None:
100
- latest_version = _parse_latest_version_str(lookup_latest_package_version(__package__.split('.')[0]))
101
-
102
- if self.args.version is not None:
103
- target_version: str = self.args.version
104
- else:
105
- target_version = latest_version
113
+ current_version = __about__.__version__
114
+
115
+ while True:
116
+ latest_version = _parse_latest_version_str(lookup_latest_package_version(__package__.split('.')[0]))
117
+
118
+ if self.args.version is not None:
119
+ target_version: str = self.args.version
120
+ else:
121
+ target_version = latest_version
122
+
123
+ if self.args.must_upgrade or self.args.must_upgrade_loop:
124
+ current_vo = Version(current_version)
125
+ target_vo = Version(target_version)
126
+ if not (target_vo > current_vo):
127
+ ex = CliCli.ReinstallWouldNotUpgradeError(current_version, target_version)
128
+ if self.args.must_upgrade_loop:
129
+ print(ex)
130
+ time.sleep(1)
131
+ continue
132
+ else:
133
+ raise ex
134
+
135
+ break
106
136
 
107
137
  #
108
138
 
@@ -186,7 +216,7 @@ class CliCli(ap.Cli):
186
216
 
187
217
  #
188
218
 
189
- print(f'Current version: {__about__.__version__}')
219
+ print(f'Current version: {current_version}')
190
220
  print(f'Latest version: {latest_version}')
191
221
  print(f'Target version: {target_version}')
192
222
  print()
omdev/cmdlog/cli.py CHANGED
@@ -1,7 +1,6 @@
1
1
  import argparse
2
2
  import os.path
3
3
  import subprocess
4
- import sys
5
4
  import typing as ta
6
5
 
7
6
  from omlish.formats import json
@@ -60,7 +59,7 @@ def _main() -> None:
60
59
  entry_dcts = [json.loads(sl) for l in log_lines if (sl := l.strip())]
61
60
  print(json.dumps_compact(entry_dcts))
62
61
 
63
- sys.exit(rc)
62
+ raise SystemExit(rc)
64
63
 
65
64
 
66
65
  if __name__ == '__main__':