omdev 0.0.0.dev36__py3-none-any.whl → 0.0.0.dev38__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 +1 -1
- omdev/amalg/amalg.py +3 -1
- omdev/cli/install.py +160 -0
- omdev/interp/inspect.py +1 -1
- omdev/interp/pyenv.py +2 -2
- omdev/interp/system.py +1 -1
- omdev/interp/types.py +3 -3
- omdev/packaging/names.py +44 -0
- omdev/packaging/requires.py +484 -0
- omdev/scripts/interp.py +9 -4
- omdev/scripts/pyproject.py +1175 -1170
- omdev/tools/piptools.py +36 -0
- {omdev-0.0.0.dev36.dist-info → omdev-0.0.0.dev38.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev36.dist-info → omdev-0.0.0.dev38.dist-info}/RECORD +21 -18
- /omdev/{versioning → packaging}/__init__.py +0 -0
- /omdev/{versioning → packaging}/specifiers.py +0 -0
- /omdev/{versioning → packaging}/versions.py +0 -0
- {omdev-0.0.0.dev36.dist-info → omdev-0.0.0.dev38.dist-info}/LICENSE +0 -0
- {omdev-0.0.0.dev36.dist-info → omdev-0.0.0.dev38.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev36.dist-info → omdev-0.0.0.dev38.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev36.dist-info → omdev-0.0.0.dev38.dist-info}/top_level.txt +0 -0
omdev/.manifests.json
CHANGED
omdev/amalg/amalg.py
CHANGED
|
@@ -205,6 +205,7 @@ def make_import(
|
|
|
205
205
|
|
|
206
206
|
|
|
207
207
|
TYPE_ALIAS_COMMENT = '# ta.TypeAlias'
|
|
208
|
+
NOQA_TYPE_ALIAS_COMMENT = TYPE_ALIAS_COMMENT + ' # noqa'
|
|
208
209
|
|
|
209
210
|
|
|
210
211
|
@dc.dataclass(frozen=True, kw_only=True)
|
|
@@ -218,7 +219,8 @@ class Typing:
|
|
|
218
219
|
|
|
219
220
|
|
|
220
221
|
def _is_typing(lts: Tokens) -> bool:
|
|
221
|
-
|
|
222
|
+
es = tks.join_toks(lts).strip()
|
|
223
|
+
if any(es.endswith(sfx) for sfx in (TYPE_ALIAS_COMMENT, NOQA_TYPE_ALIAS_COMMENT)):
|
|
222
224
|
return True
|
|
223
225
|
|
|
224
226
|
wts = list(tks.ignore_ws(lts))
|
omdev/cli/install.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
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 not (mgr := args.mgr):
|
|
136
|
+
if shutil.which('uv'):
|
|
137
|
+
mgr = 'uv'
|
|
138
|
+
elif shutil.which('pipx'):
|
|
139
|
+
mgr = 'pipx'
|
|
140
|
+
else:
|
|
141
|
+
raise RuntimeError("Can't find package manager")
|
|
142
|
+
|
|
143
|
+
if (im := INSTALL_MGRS.get(mgr)) is None:
|
|
144
|
+
raise ValueError(f'Unsupported mgr: {mgr}')
|
|
145
|
+
if not im.is_available():
|
|
146
|
+
raise ValueError(f'Unavailable mgr: {mgr}')
|
|
147
|
+
|
|
148
|
+
for m in INSTALL_MGRS.values():
|
|
149
|
+
if m.is_available():
|
|
150
|
+
m.uninstall(cli)
|
|
151
|
+
|
|
152
|
+
im.install(InstallOpts(
|
|
153
|
+
cli_pkg=cli,
|
|
154
|
+
py_ver=py,
|
|
155
|
+
extras=args.extra,
|
|
156
|
+
))
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if __name__ == '__main__':
|
|
160
|
+
_main()
|
omdev/interp/inspect.py
CHANGED
|
@@ -8,7 +8,7 @@ import typing as ta
|
|
|
8
8
|
from omlish.lite.logs import log
|
|
9
9
|
from omlish.lite.subprocesses import subprocess_check_output
|
|
10
10
|
|
|
11
|
-
from ..
|
|
11
|
+
from ..packaging.versions import Version
|
|
12
12
|
from .types import InterpOpts
|
|
13
13
|
from .types import InterpVersion
|
|
14
14
|
|
omdev/interp/pyenv.py
CHANGED
|
@@ -25,8 +25,8 @@ from omlish.lite.subprocesses import subprocess_check_call
|
|
|
25
25
|
from omlish.lite.subprocesses import subprocess_check_output_str
|
|
26
26
|
from omlish.lite.subprocesses import subprocess_try_output
|
|
27
27
|
|
|
28
|
-
from ..
|
|
29
|
-
from ..
|
|
28
|
+
from ..packaging.versions import InvalidVersion
|
|
29
|
+
from ..packaging.versions import Version
|
|
30
30
|
from .inspect import INTERP_INSPECTOR
|
|
31
31
|
from .inspect import InterpInspector
|
|
32
32
|
from .providers import InterpProvider
|
omdev/interp/system.py
CHANGED
|
@@ -12,7 +12,7 @@ import typing as ta
|
|
|
12
12
|
from omlish.lite.cached import cached_nullary
|
|
13
13
|
from omlish.lite.logs import log
|
|
14
14
|
|
|
15
|
-
from ..
|
|
15
|
+
from ..packaging.versions import InvalidVersion
|
|
16
16
|
from .inspect import INTERP_INSPECTOR
|
|
17
17
|
from .inspect import InterpInspector
|
|
18
18
|
from .providers import InterpProvider
|
omdev/interp/types.py
CHANGED
|
@@ -3,9 +3,9 @@ import collections
|
|
|
3
3
|
import dataclasses as dc
|
|
4
4
|
import typing as ta
|
|
5
5
|
|
|
6
|
-
from ..
|
|
7
|
-
from ..
|
|
8
|
-
from ..
|
|
6
|
+
from ..packaging.specifiers import Specifier
|
|
7
|
+
from ..packaging.versions import InvalidVersion
|
|
8
|
+
from ..packaging.versions import Version
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
# See https://peps.python.org/pep-3149/
|
omdev/packaging/names.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Copyright (c) Donald Stufft and individual contributors.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
|
5
|
+
# following conditions are met:
|
|
6
|
+
#
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
8
|
+
# following disclaimer.
|
|
9
|
+
#
|
|
10
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
|
|
11
|
+
# following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
12
|
+
#
|
|
13
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
14
|
+
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
15
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
16
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
17
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
18
|
+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
19
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This file is dual licensed under the terms of the
|
|
20
|
+
# Apache License, Version 2.0, and the BSD License. See the LICENSE file in the root of this repository for complete
|
|
21
|
+
# details.
|
|
22
|
+
# https://github.com/pypa/packaging/blob/cf2cbe2aec28f87c6228a6fb136c27931c9af407/src/packaging/utils.py
|
|
23
|
+
import re
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Core metadata spec for `Name`
|
|
27
|
+
_CANONICAL_NAME_VALIDATE_PATTERN = re.compile(r'^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$', re.IGNORECASE)
|
|
28
|
+
_CANONICAL_NAME_CANONICALIZE_PATTERN = re.compile(r'[-_.]+')
|
|
29
|
+
_CANONICAL_NAME_NORMALIZED_PATTERN = re.compile(r'^([a-z0-9]|[a-z0-9]([a-z0-9-](?!--))*[a-z0-9])$')
|
|
30
|
+
|
|
31
|
+
# PEP 427: The build number must start with a digit.
|
|
32
|
+
_CANONICAL_NAME_BUILD_TAG_PATTERN = re.compile(r'(\d+)(.*)')
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def canonicalize_name(name: str, *, validate: bool = False) -> str:
|
|
36
|
+
if validate and not _CANONICAL_NAME_VALIDATE_PATTERN.match(name):
|
|
37
|
+
raise NameError(f'name is invalid: {name!r}')
|
|
38
|
+
# This is taken from PEP 503.
|
|
39
|
+
value = _CANONICAL_NAME_CANONICALIZE_PATTERN.sub('-', name).lower()
|
|
40
|
+
return value
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def is_normalized_name(name: str) -> bool:
|
|
44
|
+
return _CANONICAL_NAME_NORMALIZED_PATTERN.match(name) is not None
|