omdev 0.0.0.dev37__py3-none-any.whl → 0.0.0.dev39__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.

omdev/.manifests.json CHANGED
@@ -35,6 +35,18 @@
35
35
  }
36
36
  }
37
37
  },
38
+ {
39
+ "module": ".cli._version",
40
+ "attr": "_CLI_MODULE",
41
+ "file": "omdev/cli/_version.py",
42
+ "line": 5,
43
+ "value": {
44
+ "$.cli.types.CliModule": {
45
+ "cmd_name": "version",
46
+ "mod_name": "omdev.cli._version"
47
+ }
48
+ }
49
+ },
38
50
  {
39
51
  "module": ".interp.__main__",
40
52
  "attr": "_CLI_MODULE",
@@ -99,7 +111,7 @@
99
111
  "module": ".tools.piptools",
100
112
  "attr": "_CLI_MODULE",
101
113
  "file": "omdev/tools/piptools.py",
102
- "line": 85,
114
+ "line": 88,
103
115
  "value": {
104
116
  "$.cli.types.CliModule": {
105
117
  "cmd_name": "pip",
omdev/cli/_version.py ADDED
@@ -0,0 +1,14 @@
1
+ from .. import __about__
2
+ from .types import CliModule
3
+
4
+
5
+ # @omlish-manifest
6
+ _CLI_MODULE = CliModule('version', __name__)
7
+
8
+
9
+ def _main() -> None:
10
+ print(__about__.__version__)
11
+
12
+
13
+ if __name__ == '__main__':
14
+ _main()
omdev/cli/install.py ADDED
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env python3
2
+ # @omlish-lite
3
+ # @omlish-script
4
+ """
5
+ TODO:
6
+ - used for self-reinstall, preserving non-root dists - fix list_root_dists
7
+
8
+ ==
9
+
10
+ curl -LsSf https://raw.githubusercontent.com/wrmsr/omlish/master/omdev/cli/install.py | python3 -
11
+ """
12
+ import abc
13
+ import argparse
14
+ import dataclasses as dc
15
+ import itertools
16
+ import json
17
+ import shutil
18
+ import subprocess
19
+ import sys
20
+ import typing as ta
21
+
22
+
23
+ DEFAULT_CLI_PKG = 'omdev-cli'
24
+ DEFAULT_PY_VER = '3.12'
25
+
26
+
27
+ @dc.dataclass(frozen=True)
28
+ class InstallOpts:
29
+ cli_pkg: str = DEFAULT_CLI_PKG
30
+ py_ver: str = DEFAULT_PY_VER
31
+
32
+ extras: ta.Sequence[str] = dc.field(default_factory=list)
33
+
34
+
35
+ class InstallMgr(abc.ABC):
36
+ @abc.abstractmethod
37
+ def is_available(self) -> bool:
38
+ raise NotImplementedError
39
+
40
+ @abc.abstractmethod
41
+ def uninstall(self, cli_pkg: str) -> None:
42
+ raise NotImplementedError
43
+
44
+ @abc.abstractmethod
45
+ def install(self, opts: InstallOpts) -> None:
46
+ raise NotImplementedError
47
+
48
+
49
+ class UvInstallMgr(InstallMgr):
50
+ def is_available(self) -> bool:
51
+ return bool(shutil.which('uv'))
52
+
53
+ def uninstall(self, cli_pkg: str) -> None:
54
+ out = subprocess.check_output(['uv', 'tool', 'list']).decode()
55
+
56
+ installed = {
57
+ s.partition(' ')[0]
58
+ for l in out.splitlines()
59
+ if (s := l.strip())
60
+ and not s.startswith('-')
61
+ }
62
+
63
+ if cli_pkg not in installed:
64
+ return
65
+
66
+ subprocess.check_call([
67
+ 'uv', 'tool',
68
+ 'uninstall',
69
+ cli_pkg,
70
+ ])
71
+
72
+ def install(self, opts: InstallOpts) -> None:
73
+ subprocess.check_call([
74
+ 'uv', 'tool',
75
+ 'install',
76
+ '--refresh',
77
+ '--prerelease=allow',
78
+ f'--python={opts.py_ver}',
79
+ opts.cli_pkg,
80
+ *itertools.chain.from_iterable(['--with', e] for e in (opts.extras or [])),
81
+ ])
82
+
83
+
84
+ class PipxInstallMgr(InstallMgr):
85
+ def is_available(self) -> bool:
86
+ return bool(shutil.which('pipx'))
87
+
88
+ def uninstall(self, cli_pkg: str) -> None:
89
+ out = subprocess.check_output(['pipx', 'list', '--json']).decode()
90
+
91
+ dct = json.loads(out)
92
+
93
+ if cli_pkg not in dct.get('venvs', {}):
94
+ return
95
+
96
+ subprocess.check_call([
97
+ 'pipx',
98
+ 'uninstall',
99
+ cli_pkg,
100
+ ])
101
+
102
+ def install(self, opts: InstallOpts) -> None:
103
+ subprocess.check_call([
104
+ 'pipx',
105
+ 'install',
106
+ f'--python={opts.py_ver}',
107
+ opts.cli_pkg,
108
+ *itertools.chain.from_iterable(['--preinstall', e] for e in (opts.extras or [])),
109
+ ])
110
+
111
+
112
+ INSTALL_MGRS = {
113
+ 'uv': UvInstallMgr(),
114
+ 'pipx': PipxInstallMgr(),
115
+ }
116
+
117
+
118
+ def _main() -> None:
119
+ if sys.version_info < (3, 8): # noqa
120
+ raise RuntimeError(f'Unsupported python version: {sys.version_info}')
121
+
122
+ parser = argparse.ArgumentParser()
123
+ parser.add_argument('-c', '--cli', default=DEFAULT_CLI_PKG)
124
+ parser.add_argument('-p', '--py', default=DEFAULT_PY_VER)
125
+ parser.add_argument('-m', '--mgr')
126
+ parser.add_argument('extra', nargs='*')
127
+ args = parser.parse_args()
128
+
129
+ if not (cli := args.cli):
130
+ raise ValueError(f'Must specify cli')
131
+
132
+ if not (py := args.py):
133
+ raise ValueError(f'Must specify py')
134
+
135
+ if mgr := args.mgr:
136
+ if (im := INSTALL_MGRS.get(mgr)) is None:
137
+ raise ValueError(f'Unsupported mgr: {mgr}')
138
+ if not im.is_available():
139
+ raise ValueError(f'Unavailable mgr: {mgr}')
140
+ else:
141
+ for im in INSTALL_MGRS.values():
142
+ if im.is_available():
143
+ break
144
+ else:
145
+ raise RuntimeError("Can't find install manager")
146
+
147
+ for m in INSTALL_MGRS.values():
148
+ if m.is_available():
149
+ m.uninstall(cli)
150
+
151
+ im.install(InstallOpts(
152
+ cli_pkg=cli,
153
+ py_ver=py,
154
+ extras=args.extra,
155
+ ))
156
+
157
+
158
+ if __name__ == '__main__':
159
+ _main()
omdev/tools/piptools.py CHANGED
@@ -9,6 +9,7 @@ from omlish import check
9
9
 
10
10
  from ..cli import CliModule
11
11
  from ..packaging.names import canonicalize_name
12
+ from ..packaging.requires import RequiresVariable
12
13
  from ..packaging.requires import parse_requirement
13
14
 
14
15
 
@@ -55,6 +56,7 @@ class Cli(ap.Cli):
55
56
  ap.arg('path', nargs='*'),
56
57
  )
57
58
  def list_root_dists(self) -> None:
59
+ # FIXME: track req extras - tuple[str, str] with ('pkg', '') as 'bare'?
58
60
  paths = self.args.path or sys.path
59
61
 
60
62
  dists: set[str] = set()
@@ -70,7 +72,8 @@ class Cli(ap.Cli):
70
72
  dists.add(dist_cn)
71
73
  for req_str in dist.requires or []:
72
74
  req = parse_requirement(req_str)
73
- if req.extras:
75
+
76
+ if any(v.value == 'extra' for m in req.marker or [] if isinstance(v := m[0], RequiresVariable)):
74
77
  continue
75
78
 
76
79
  req_cn = canonicalize_name(req.name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev37
3
+ Version: 0.0.0.dev39
4
4
  Summary: omdev
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: ~=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omlish ==0.0.0.dev37
15
+ Requires-Dist: omlish ==0.0.0.dev39
16
16
  Provides-Extra: all
17
17
  Requires-Dist: pycparser ~=2.22 ; extra == 'all'
18
18
  Requires-Dist: cffi ~=1.17 ; extra == 'all'
@@ -1,4 +1,4 @@
1
- omdev/.manifests.json,sha256=Rb0JnDKfdMCMgojZmR1CfzyvnjPrToEaRJ3Pa4Tr0_E,2595
1
+ omdev/.manifests.json,sha256=X-jJNWiAfaldoc7wO3STlzuU0GxQDqZecTg7Lcp-IrI,2848
2
2
  omdev/__about__.py,sha256=LqSNNFFcT84xW3W8fIOJ78kPYJKFLIXZyDX-AJREvN0,1005
3
3
  omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  omdev/bracepy.py,sha256=HwBK5XmlOsF_juTel25fRLJK9vHSJCWXuCc-OZlevRQ,2619
@@ -55,6 +55,8 @@ omdev/cexts/_distutils/compilers/options.py,sha256=H7r5IcLvga5Fs3jjXWIT-6ap3JBdu
55
55
  omdev/cexts/_distutils/compilers/unixccompiler.py,sha256=o1h8QuyupLntv4F21_XjzAZmCiwwxJuTmOirvBSL-Qw,15419
56
56
  omdev/cli/__init__.py,sha256=V_l6VP1SZMlJbO-8CJwSuO9TThOy2S_oaPepNYgIrbE,37
57
57
  omdev/cli/__main__.py,sha256=d23loR_cKfTYZwYiqpt_CmKI7dd5WcYFgIYzqMep75E,68
58
+ omdev/cli/_version.py,sha256=coRbrHd53G7GLE3lg1KzG0GajUwEIr5kGzeJ_ABvPFc,217
59
+ omdev/cli/install.py,sha256=9YegrJLDQYFYof6uB0S3ttAVvGCwtfMJypkFFkH63qI,3930
58
60
  omdev/cli/main.py,sha256=0Wq2tlaRDelpSEUZDKwOginpBrdcE3hgWQqD6syaIvE,1413
59
61
  omdev/cli/types.py,sha256=rYM5jogfZqC3tpWLOHSDL6iaV3XWGWM1hJYd11I-ImA,107
60
62
  omdev/interp/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
@@ -105,12 +107,12 @@ omdev/tools/dockertools.py,sha256=x00GV8j1KReMXwxJ641GlcsVwHoWeuzdIKVBp36BqwU,52
105
107
  omdev/tools/gittools.py,sha256=s_-cxh-4Nv2a_bJtHZ6AiKF8kx2IjDrt_GOH8Wjz-3M,669
106
108
  omdev/tools/importscan.py,sha256=XRLiasVSaTIp-jnO0-Nfhi0t6gnv_hVy5j2nVfEvuMI,3831
107
109
  omdev/tools/importtrace.py,sha256=oDry9CwIv5h96wSaTVKJ0qQ5vMGxYE5oBtfF-GYNLJs,13430
108
- omdev/tools/piptools.py,sha256=ANlJTM6ozbSkI6KPNNg7LIVg8wDc2OoK-M8GhjnFTiw,2559
110
+ omdev/tools/piptools.py,sha256=lhwzGXD-v0KFEQNyvzvdO2Kw1OA_2AfGPBs_rIkz8iE,2772
109
111
  omdev/tools/rst.py,sha256=6dWk8QZHoGiLSuBw3TKsXZjjFK6wWBEtPi9krdCLKKg,977
110
112
  omdev/tools/sqlrepl.py,sha256=tmFZh80-xsGM62dyQ7_UGLebChrj7IHbIPYBWDJMgVk,5741
111
- omdev-0.0.0.dev37.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
112
- omdev-0.0.0.dev37.dist-info/METADATA,sha256=IQuSit_OCW_wTB9O_EGapsmDJd8tGiZRG5b8X1qzmog,1252
113
- omdev-0.0.0.dev37.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
114
- omdev-0.0.0.dev37.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
115
- omdev-0.0.0.dev37.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
116
- omdev-0.0.0.dev37.dist-info/RECORD,,
113
+ omdev-0.0.0.dev39.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
114
+ omdev-0.0.0.dev39.dist-info/METADATA,sha256=t9mSly9pUKgpLgRdHoRVQrvCKyOPRW7s8m3dc-Y_wTM,1252
115
+ omdev-0.0.0.dev39.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
116
+ omdev-0.0.0.dev39.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
117
+ omdev-0.0.0.dev39.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
118
+ omdev-0.0.0.dev39.dist-info/RECORD,,