omdev 0.0.0.dev59__tar.gz → 0.0.0.dev60__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.
Potentially problematic release.
This version of omdev might be problematic. Click here for more details.
- {omdev-0.0.0.dev59/omdev.egg-info → omdev-0.0.0.dev60}/PKG-INFO +2 -2
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/.manifests.json +1 -1
- omdev-0.0.0.dev60/omdev/cli/__main__.py +6 -0
- omdev-0.0.0.dev60/omdev/cli/main.py +155 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/gittools.py +24 -14
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60/omdev.egg-info}/PKG-INFO +2 -2
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev.egg-info/requires.txt +1 -1
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/pyproject.toml +2 -2
- omdev-0.0.0.dev59/omdev/cli/__main__.py +0 -4
- omdev-0.0.0.dev59/omdev/cli/main.py +0 -121
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/LICENSE +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/MANIFEST.in +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/README.rst +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/__about__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/amalg/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/amalg/__main__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/amalg/amalg.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/antlr/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/antlr/_antlr/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/antlr/consts.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/antlr/gen.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/bracepy.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/cache.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/contexts.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/currents.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/fns.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/resolvers.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/storage.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/compute/types.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/data/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/data/actions.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/data/cache.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/data/consts.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/data/defaults.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/data/manifests.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cache/data/specs.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_boilerplate.cc +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/LICENSE +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/build_ext.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/compilers/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/compilers/ccompiler.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/compilers/options.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/compilers/unixccompiler.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/dir_util.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/errors.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/extension.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/file_util.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/modified.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/spawn.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/sysconfig.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/util.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/_distutils/version.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/build.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/cmake.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/importhook.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/magic.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cexts/scan.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/classdot.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cli/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cli/clicli.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cli/install.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cli/managers.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cli/types.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/cmake.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/findimports.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/findmagic.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/git.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/__main__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/cli.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/inspect.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/providers.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/pyenv.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/resolvers.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/standalone.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/system.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/interp/types.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/manifests/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/manifests/build.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/manifests/load.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/manifests/types.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/mypy/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/mypy/debug.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/packaging/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/packaging/names.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/packaging/requires.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/packaging/specifiers.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/packaging/versions.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/precheck/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/precheck/__main__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/precheck/base.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/precheck/git.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/precheck/lite.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/precheck/precheck.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/precheck/scripts.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/pyproject/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/pyproject/__main__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/pyproject/cexts.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/pyproject/cli.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/pyproject/configs.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/pyproject/pkg.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/pyproject/reqs.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/revisions.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/scripts/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/scripts/bumpversion.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/scripts/execrss.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/scripts/exectime.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/scripts/importtrace.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/scripts/interp.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/scripts/pyproject.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/secrets.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tokens.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/toml/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/toml/parser.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/toml/writer.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/__init__.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/dockertools.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/importscan.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/mkrelimp.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/nbtools.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/piptools.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/proftools.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/rst.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/tools/sqlrepl.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev/wheelfile.py +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev.egg-info/SOURCES.txt +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev.egg-info/dependency_links.txt +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev.egg-info/entry_points.txt +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/omdev.egg-info/top_level.txt +0 -0
- {omdev-0.0.0.dev59 → omdev-0.0.0.dev60}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: omdev
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev60
|
|
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.
|
|
15
|
+
Requires-Dist: omlish==0.0.0.dev60
|
|
16
16
|
Provides-Extra: all
|
|
17
17
|
Requires-Dist: pycparser~=2.22; extra == "all"
|
|
18
18
|
Requires-Dist: cffi~=1.17; extra == "all"
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TODO:
|
|
3
|
+
- cache ldr.discover() somehow if in uvx/pipx - very slow
|
|
4
|
+
- <venv-root>/.omdev-cli-manifest-cache.json - {pkg_name: manifests_json}
|
|
5
|
+
- allow manually specifying manifest packages
|
|
6
|
+
"""
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
import runpy
|
|
10
|
+
import sys
|
|
11
|
+
import typing as ta
|
|
12
|
+
|
|
13
|
+
from omlish import check
|
|
14
|
+
|
|
15
|
+
from ..manifests.load import ManifestLoader
|
|
16
|
+
from .types import CliCmd
|
|
17
|
+
from .types import CliFunc
|
|
18
|
+
from .types import CliModule
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _post_install(cli_pkg: str) -> None:
|
|
25
|
+
from .managers import setup_install_manager
|
|
26
|
+
|
|
27
|
+
setup_install_manager(cli_pkg)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
_CLI_FUNCS: ta.Sequence[CliFunc] = [
|
|
34
|
+
CliFunc('_post_install', _post_install),
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
##
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _build_arg_parser() -> argparse.ArgumentParser:
|
|
42
|
+
parser = argparse.ArgumentParser()
|
|
43
|
+
parser.add_argument('--cli-pkg-root', action='append')
|
|
44
|
+
parser.add_argument('cmd', nargs='?')
|
|
45
|
+
parser.add_argument('args', nargs=argparse.REMAINDER)
|
|
46
|
+
return parser
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _build_cmd_dct(args: ta.Any) -> ta.Mapping[str, CliCmd]:
|
|
50
|
+
ccs: list[CliCmd] = []
|
|
51
|
+
|
|
52
|
+
ldr = ManifestLoader.from_entry_point(globals())
|
|
53
|
+
|
|
54
|
+
pkgs: list[str] = []
|
|
55
|
+
|
|
56
|
+
def scan_pkg_root(r: str) -> None:
|
|
57
|
+
r = os.path.expanduser(r)
|
|
58
|
+
for n in os.listdir(r):
|
|
59
|
+
if os.path.isdir(p := os.path.join(r, n)) and os.path.exists(os.path.join(p, '__init__.py')):
|
|
60
|
+
pkgs.append(n)
|
|
61
|
+
|
|
62
|
+
if args.cli_pkg_root:
|
|
63
|
+
for r in args.cli_pkg_root:
|
|
64
|
+
scan_pkg_root(r)
|
|
65
|
+
|
|
66
|
+
else:
|
|
67
|
+
pkgs.extend(ldr.discover())
|
|
68
|
+
|
|
69
|
+
if not pkgs:
|
|
70
|
+
scan_pkg_root(os.getcwd())
|
|
71
|
+
|
|
72
|
+
for m in ldr.load(*pkgs, only=[CliModule]):
|
|
73
|
+
ccs.append(check.isinstance(m.value, CliModule))
|
|
74
|
+
|
|
75
|
+
ccs.extend(_CLI_FUNCS)
|
|
76
|
+
|
|
77
|
+
dct: dict[str, CliCmd] = {}
|
|
78
|
+
for cc in ccs:
|
|
79
|
+
for cn in [cc.cmd_name] if isinstance(cc.cmd_name, str) else cc.cmd_name:
|
|
80
|
+
if cn in dct:
|
|
81
|
+
raise NameError(cc)
|
|
82
|
+
dct[cn] = cc
|
|
83
|
+
|
|
84
|
+
return dct
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _select_cmd(args: ta.Any, cmds: ta.Mapping[str, CliCmd]) -> CliCmd | int:
|
|
88
|
+
cmd = args.cmd
|
|
89
|
+
if cmd and cmd in cmds:
|
|
90
|
+
return cmds[cmd]
|
|
91
|
+
|
|
92
|
+
def print_err(*args, **kwargs): # noqa
|
|
93
|
+
print(*args, **kwargs, file=sys.stderr)
|
|
94
|
+
|
|
95
|
+
if cmd:
|
|
96
|
+
print_err(f'Invalid command: {cmd}\n')
|
|
97
|
+
rc = 1
|
|
98
|
+
else:
|
|
99
|
+
rc = 0
|
|
100
|
+
|
|
101
|
+
mset = set()
|
|
102
|
+
mdct: dict = {}
|
|
103
|
+
for cc in cmds.values():
|
|
104
|
+
if id(cc) in mset:
|
|
105
|
+
continue
|
|
106
|
+
mset.add(id(cc))
|
|
107
|
+
if isinstance(cc.cmd_name, str) and cc.cmd_name[0] == '_':
|
|
108
|
+
continue
|
|
109
|
+
if isinstance(cc, CliFunc):
|
|
110
|
+
mdct.setdefault('-', []).append(cc)
|
|
111
|
+
elif isinstance(cc, CliModule):
|
|
112
|
+
mdct.setdefault(cc.mod_name.partition('.')[0], []).append(cc)
|
|
113
|
+
else:
|
|
114
|
+
raise TypeError(cc)
|
|
115
|
+
|
|
116
|
+
print_err('Subcommands:\n')
|
|
117
|
+
for m, l in sorted(mdct.items(), key=lambda t: (t[0] == '-', t[0])):
|
|
118
|
+
print_err(f' {m}')
|
|
119
|
+
for cc in sorted(l, key=lambda c: c.primary_name):
|
|
120
|
+
if isinstance(cc.cmd_name, str):
|
|
121
|
+
print_err(f' {cc.cmd_name}')
|
|
122
|
+
else:
|
|
123
|
+
print_err(
|
|
124
|
+
f' {cc.cmd_name[0]}'
|
|
125
|
+
f'{(" (" + ", ".join(cc.cmd_name[1:]) + ")") if len(cc.cmd_name) > 1 else ""}',
|
|
126
|
+
)
|
|
127
|
+
print_err()
|
|
128
|
+
|
|
129
|
+
return rc
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _main() -> ta.Any:
|
|
133
|
+
parser = _build_arg_parser()
|
|
134
|
+
args = parser.parse_args()
|
|
135
|
+
cmds = _build_cmd_dct(args)
|
|
136
|
+
sel = _select_cmd(args, cmds)
|
|
137
|
+
|
|
138
|
+
match sel:
|
|
139
|
+
case int():
|
|
140
|
+
return sel
|
|
141
|
+
|
|
142
|
+
case CliModule() as cm:
|
|
143
|
+
sys.argv = [args.cmd, *(args.args or ())]
|
|
144
|
+
runpy._run_module_as_main(cm.mod_name) # type: ignore # noqa
|
|
145
|
+
return 0
|
|
146
|
+
|
|
147
|
+
case CliFunc() as cf:
|
|
148
|
+
return cf.fn(*(args.args or ()))
|
|
149
|
+
|
|
150
|
+
case _:
|
|
151
|
+
raise TypeError(sel)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
if __name__ == '__main__':
|
|
155
|
+
sys.exit(rc if isinstance(rc := _main(), int) else 0)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
3
|
import subprocess
|
|
4
|
+
import urllib.parse
|
|
4
5
|
|
|
5
6
|
from omlish import argparse as ap
|
|
6
7
|
from omlish import logs
|
|
@@ -36,29 +37,38 @@ class Cli(ap.Cli):
|
|
|
36
37
|
accepts_unknown=True,
|
|
37
38
|
)
|
|
38
39
|
def clone(self) -> None:
|
|
39
|
-
|
|
40
|
+
out_dir: str
|
|
41
|
+
|
|
42
|
+
if (m := self._GITHUB_PAT.fullmatch(self.args.repo)):
|
|
43
|
+
user = m.group('user')
|
|
44
|
+
repo = m.group('repo')
|
|
45
|
+
|
|
46
|
+
os.makedirs(user, 0o755, exist_ok=True)
|
|
47
|
+
|
|
40
48
|
subprocess.check_call([
|
|
41
49
|
'git',
|
|
42
50
|
'clone',
|
|
43
51
|
*self.unknown_args,
|
|
44
52
|
*self.args.args,
|
|
45
|
-
|
|
53
|
+
f'https://github.com/{user}/{repo}.git',
|
|
54
|
+
os.path.join(user, repo),
|
|
46
55
|
])
|
|
47
|
-
return
|
|
48
56
|
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
out_dir = os.path.join(user, repo)
|
|
58
|
+
|
|
59
|
+
else:
|
|
60
|
+
parsed = urllib.parse.urlparse(self.args.repo)
|
|
61
|
+
out_dir = parsed.path.split('/')[-1]
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
subprocess.check_call([
|
|
64
|
+
'git',
|
|
65
|
+
'clone',
|
|
66
|
+
*self.unknown_args,
|
|
67
|
+
*self.args.args,
|
|
68
|
+
self.args.repo,
|
|
69
|
+
])
|
|
53
70
|
|
|
54
|
-
|
|
55
|
-
'git',
|
|
56
|
-
'clone',
|
|
57
|
-
*self.unknown_args,
|
|
58
|
-
*self.args.args,
|
|
59
|
-
f'https://github.com/{user}/{repo}.git',
|
|
60
|
-
os.path.join(user, repo),
|
|
61
|
-
])
|
|
71
|
+
print(out_dir)
|
|
62
72
|
|
|
63
73
|
|
|
64
74
|
# @omlish-manifest
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: omdev
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev60
|
|
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.
|
|
15
|
+
Requires-Dist: omlish==0.0.0.dev60
|
|
16
16
|
Provides-Extra: all
|
|
17
17
|
Requires-Dist: pycparser~=2.22; extra == "all"
|
|
18
18
|
Requires-Dist: cffi~=1.17; extra == "all"
|
|
@@ -12,7 +12,7 @@ authors = [
|
|
|
12
12
|
urls = {source = 'https://github.com/wrmsr/omlish'}
|
|
13
13
|
license = {text = 'BSD-3-Clause'}
|
|
14
14
|
requires-python = '~=3.12'
|
|
15
|
-
version = '0.0.0.
|
|
15
|
+
version = '0.0.0.dev60'
|
|
16
16
|
classifiers = [
|
|
17
17
|
'License :: OSI Approved :: BSD License',
|
|
18
18
|
'Development Status :: 2 - Pre-Alpha',
|
|
@@ -22,7 +22,7 @@ classifiers = [
|
|
|
22
22
|
]
|
|
23
23
|
description = 'omdev'
|
|
24
24
|
dependencies = [
|
|
25
|
-
'omlish == 0.0.0.
|
|
25
|
+
'omlish == 0.0.0.dev60',
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
[project.optional-dependencies]
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
TODO:
|
|
3
|
-
- cache ldr.discover() somehow if in uvx/pipx - very slow
|
|
4
|
-
- <venv-root>/.omdev-cli-manifest-cache.json - {pkg_name: manifests_json}
|
|
5
|
-
- allow manually specifying manifest packages
|
|
6
|
-
"""
|
|
7
|
-
import argparse
|
|
8
|
-
import os
|
|
9
|
-
import runpy
|
|
10
|
-
import sys
|
|
11
|
-
import typing as ta
|
|
12
|
-
|
|
13
|
-
from omlish import check
|
|
14
|
-
|
|
15
|
-
from ..manifests.load import ManifestLoader
|
|
16
|
-
from .types import CliCmd
|
|
17
|
-
from .types import CliFunc
|
|
18
|
-
from .types import CliModule
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def _post_install(cli_pkg: str) -> None:
|
|
25
|
-
from .managers import setup_install_manager
|
|
26
|
-
|
|
27
|
-
setup_install_manager(cli_pkg)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_CLI_FUNCS: ta.Sequence[CliFunc] = [
|
|
34
|
-
CliFunc('_post_install', _post_install),
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def _main() -> None:
|
|
42
|
-
ccs: list[CliCmd] = []
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
ldr = ManifestLoader.from_entry_point(globals())
|
|
47
|
-
|
|
48
|
-
pkgs = ldr.discover()
|
|
49
|
-
|
|
50
|
-
if not pkgs:
|
|
51
|
-
pkgs = []
|
|
52
|
-
for n in os.listdir(os.getcwd()):
|
|
53
|
-
if os.path.isdir(n) and os.path.exists(os.path.join(n, '__init__.py')):
|
|
54
|
-
pkgs.append(n)
|
|
55
|
-
|
|
56
|
-
for m in ldr.load(*pkgs, only=[CliModule]):
|
|
57
|
-
ccs.append(check.isinstance(m.value, CliModule))
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
|
|
61
|
-
ccs.extend(_CLI_FUNCS)
|
|
62
|
-
|
|
63
|
-
#
|
|
64
|
-
|
|
65
|
-
dct: dict[str, CliCmd] = {}
|
|
66
|
-
for cc in ccs:
|
|
67
|
-
for cn in [cc.cmd_name] if isinstance(cc.cmd_name, str) else cc.cmd_name:
|
|
68
|
-
if cn in dct:
|
|
69
|
-
raise NameError(cc)
|
|
70
|
-
dct[cn] = cc
|
|
71
|
-
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
parser = argparse.ArgumentParser()
|
|
75
|
-
parser.add_argument('cmd', nargs='?', choices=dct.keys())
|
|
76
|
-
parser.add_argument('args', nargs=argparse.REMAINDER)
|
|
77
|
-
|
|
78
|
-
args = parser.parse_args()
|
|
79
|
-
if not args.cmd:
|
|
80
|
-
mdct: dict = {}
|
|
81
|
-
for cc in ccs:
|
|
82
|
-
if isinstance(cc.cmd_name, str) and cc.cmd_name[0] == '_':
|
|
83
|
-
continue
|
|
84
|
-
if isinstance(cc, CliFunc):
|
|
85
|
-
mdct.setdefault('-', []).append(cc)
|
|
86
|
-
elif isinstance(cc, CliModule):
|
|
87
|
-
mdct.setdefault(cc.mod_name.partition('.')[0], []).append(cc)
|
|
88
|
-
else:
|
|
89
|
-
raise TypeError(cc)
|
|
90
|
-
|
|
91
|
-
print('Subcommands:\n')
|
|
92
|
-
for m, l in sorted(mdct.items(), key=lambda t: (t[0] == '-', t[0])):
|
|
93
|
-
print(f' {m}')
|
|
94
|
-
for cc in sorted(l, key=lambda c: c.primary_name):
|
|
95
|
-
if isinstance(cc.cmd_name, str):
|
|
96
|
-
print(f' {cc.cmd_name}')
|
|
97
|
-
else:
|
|
98
|
-
print(
|
|
99
|
-
f' {cc.cmd_name[0]}'
|
|
100
|
-
f'{(" (" + ", ".join(cc.cmd_name[1:]) + ")") if len(cc.cmd_name) > 1 else ""}',
|
|
101
|
-
)
|
|
102
|
-
print()
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
#
|
|
106
|
-
|
|
107
|
-
cc = dct[args.cmd]
|
|
108
|
-
|
|
109
|
-
if isinstance(cc, CliModule):
|
|
110
|
-
sys.argv = [args.cmd, *(args.args or ())]
|
|
111
|
-
runpy._run_module_as_main(cc.mod_name) # type: ignore # noqa
|
|
112
|
-
|
|
113
|
-
elif isinstance(cc, CliFunc):
|
|
114
|
-
cc.fn(*(args.args or ()))
|
|
115
|
-
|
|
116
|
-
else:
|
|
117
|
-
raise TypeError(cc)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if __name__ == '__main__':
|
|
121
|
-
_main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|