omdev 0.0.0.dev18__py3-none-any.whl → 0.0.0.dev20__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/__about__.py +4 -0
- omdev/interp/cli.py +2 -1
- omdev/interp/providers.py +1 -0
- omdev/interp/pyenv.py +49 -15
- omdev/interp/resolvers.py +36 -5
- omdev/interp/types.py +3 -0
- omdev/pyproject/cli.py +6 -2
- omdev/pyproject/pkg.py +9 -1
- omdev/pyproject/reqs.py +78 -0
- omdev/scripts/bumpversion.py +43 -0
- omdev/scripts/interp.py +91 -23
- omdev/scripts/pyproject.py +182 -25
- omdev/tools/rst.py +44 -0
- {omdev-0.0.0.dev18.dist-info → omdev-0.0.0.dev20.dist-info}/METADATA +5 -2
- {omdev-0.0.0.dev18.dist-info → omdev-0.0.0.dev20.dist-info}/RECORD +18 -15
- {omdev-0.0.0.dev18.dist-info → omdev-0.0.0.dev20.dist-info}/LICENSE +0 -0
- {omdev-0.0.0.dev18.dist-info → omdev-0.0.0.dev20.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev18.dist-info → omdev-0.0.0.dev20.dist-info}/top_level.txt +0 -0
omdev/__about__.py
CHANGED
omdev/interp/cli.py
CHANGED
|
@@ -10,6 +10,7 @@ TODO:
|
|
|
10
10
|
import argparse
|
|
11
11
|
import typing as ta
|
|
12
12
|
|
|
13
|
+
from omlish.lite.check import check_not_none
|
|
13
14
|
from omlish.lite.logs import configure_standard_logging
|
|
14
15
|
from omlish.lite.runtime import check_runtime_version
|
|
15
16
|
|
|
@@ -26,7 +27,7 @@ def _list_cmd(args) -> None:
|
|
|
26
27
|
def _resolve_cmd(args) -> None:
|
|
27
28
|
r = DEFAULT_INTERP_RESOLVER
|
|
28
29
|
s = InterpSpecifier.parse(args.version)
|
|
29
|
-
print(r.resolve(s).exe)
|
|
30
|
+
print(check_not_none(r.resolve(s)).exe)
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
def _build_parser() -> argparse.ArgumentParser:
|
omdev/interp/providers.py
CHANGED
omdev/interp/pyenv.py
CHANGED
|
@@ -116,6 +116,7 @@ class PyenvInstallOpts:
|
|
|
116
116
|
|
|
117
117
|
DEFAULT_PYENV_INSTALL_OPTS = PyenvInstallOpts(opts=['-s', '-v'])
|
|
118
118
|
DEBUG_PYENV_INSTALL_OPTS = PyenvInstallOpts(opts=['-g'])
|
|
119
|
+
THREADED_PYENV_INSTALL_OPTS = PyenvInstallOpts(conf_opts=['--disable-gil'])
|
|
119
120
|
|
|
120
121
|
|
|
121
122
|
#
|
|
@@ -176,19 +177,19 @@ class DarwinPyenvInstallOpts(PyenvInstallOptsProvider):
|
|
|
176
177
|
f"--with-tcltk-libs='-L{tcl_tk_prefix}/lib -ltcl{tcl_tk_ver} -ltk{tcl_tk_ver}'",
|
|
177
178
|
])
|
|
178
179
|
|
|
179
|
-
@cached_nullary
|
|
180
|
-
def brew_ssl_opts(self) -> PyenvInstallOpts:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
# @cached_nullary
|
|
181
|
+
# def brew_ssl_opts(self) -> PyenvInstallOpts:
|
|
182
|
+
# pkg_config_path = subprocess_check_output_str('brew', '--prefix', 'openssl')
|
|
183
|
+
# if 'PKG_CONFIG_PATH' in os.environ:
|
|
184
|
+
# pkg_config_path += ':' + os.environ['PKG_CONFIG_PATH']
|
|
185
|
+
# return PyenvInstallOpts(env={'PKG_CONFIG_PATH': pkg_config_path})
|
|
185
186
|
|
|
186
187
|
def opts(self) -> PyenvInstallOpts:
|
|
187
188
|
return PyenvInstallOpts().merge(
|
|
188
189
|
self.framework_opts(),
|
|
189
190
|
self.brew_deps_opts(),
|
|
190
191
|
self.brew_tcl_opts(),
|
|
191
|
-
self.brew_ssl_opts(),
|
|
192
|
+
# self.brew_ssl_opts(),
|
|
192
193
|
)
|
|
193
194
|
|
|
194
195
|
|
|
@@ -202,27 +203,39 @@ PLATFORM_PYENV_INSTALL_OPTS: ta.Dict[str, PyenvInstallOptsProvider] = {
|
|
|
202
203
|
|
|
203
204
|
|
|
204
205
|
class PyenvVersionInstaller:
|
|
206
|
+
"""
|
|
207
|
+
Messy: can install freethreaded build with a 't' suffixed version str _or_ by THREADED_PYENV_INSTALL_OPTS - need
|
|
208
|
+
latter to build custom interp with ft, need former to use canned / blessed interps. Muh.
|
|
209
|
+
"""
|
|
205
210
|
|
|
206
211
|
def __init__(
|
|
207
212
|
self,
|
|
208
213
|
version: str,
|
|
209
214
|
opts: ta.Optional[PyenvInstallOpts] = None,
|
|
215
|
+
interp_opts: InterpOpts = InterpOpts(),
|
|
210
216
|
*,
|
|
211
|
-
|
|
217
|
+
no_default_opts: bool = False,
|
|
212
218
|
pyenv: Pyenv = Pyenv(),
|
|
213
219
|
) -> None:
|
|
214
220
|
super().__init__()
|
|
215
221
|
|
|
216
|
-
if
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
if no_default_opts:
|
|
223
|
+
if opts is None:
|
|
224
|
+
opts = PyenvInstallOpts()
|
|
225
|
+
else:
|
|
226
|
+
lst = [opts if opts is not None else DEFAULT_PYENV_INSTALL_OPTS]
|
|
227
|
+
if interp_opts.debug:
|
|
219
228
|
lst.append(DEBUG_PYENV_INSTALL_OPTS)
|
|
229
|
+
if interp_opts.threaded:
|
|
230
|
+
lst.append(THREADED_PYENV_INSTALL_OPTS)
|
|
220
231
|
lst.append(PLATFORM_PYENV_INSTALL_OPTS[sys.platform].opts())
|
|
221
232
|
opts = PyenvInstallOpts().merge(*lst)
|
|
222
233
|
|
|
223
234
|
self._version = version
|
|
224
235
|
self._opts = opts
|
|
225
|
-
self.
|
|
236
|
+
self._interp_opts = interp_opts
|
|
237
|
+
|
|
238
|
+
self._no_default_opts = no_default_opts
|
|
226
239
|
self._pyenv = pyenv
|
|
227
240
|
|
|
228
241
|
@property
|
|
@@ -235,7 +248,7 @@ class PyenvVersionInstaller:
|
|
|
235
248
|
|
|
236
249
|
@cached_nullary
|
|
237
250
|
def install_name(self) -> str:
|
|
238
|
-
return self._version + ('-debug' if self.
|
|
251
|
+
return self._version + ('-debug' if self._interp_opts.debug else '')
|
|
239
252
|
|
|
240
253
|
@cached_nullary
|
|
241
254
|
def install_dir(self) -> str:
|
|
@@ -243,7 +256,7 @@ class PyenvVersionInstaller:
|
|
|
243
256
|
|
|
244
257
|
@cached_nullary
|
|
245
258
|
def install(self) -> str:
|
|
246
|
-
env =
|
|
259
|
+
env = {**os.environ, **self._opts.env}
|
|
247
260
|
for k, l in [
|
|
248
261
|
('CFLAGS', self._opts.cflags),
|
|
249
262
|
('LDFLAGS', self._opts.ldflags),
|
|
@@ -254,7 +267,13 @@ class PyenvVersionInstaller:
|
|
|
254
267
|
v += ' ' + os.environ[k]
|
|
255
268
|
env[k] = v
|
|
256
269
|
|
|
257
|
-
subprocess_check_call(
|
|
270
|
+
subprocess_check_call(
|
|
271
|
+
self._pyenv.exe(),
|
|
272
|
+
'install',
|
|
273
|
+
*self._opts.opts,
|
|
274
|
+
self._version,
|
|
275
|
+
env=env,
|
|
276
|
+
)
|
|
258
277
|
|
|
259
278
|
exe = os.path.join(self.install_dir(), 'bin', 'python')
|
|
260
279
|
if not os.path.isfile(exe):
|
|
@@ -355,3 +374,18 @@ class PyenvInterpProvider(InterpProvider):
|
|
|
355
374
|
for d in [False, True]:
|
|
356
375
|
lst.append(dc.replace(iv, opts=dc.replace(iv.opts, debug=d)))
|
|
357
376
|
return lst
|
|
377
|
+
|
|
378
|
+
def install_version(self, version: InterpVersion) -> Interp:
|
|
379
|
+
inst_version = str(version.version)
|
|
380
|
+
inst_opts = version.opts
|
|
381
|
+
if inst_opts.threaded:
|
|
382
|
+
inst_version += 't'
|
|
383
|
+
inst_opts = dc.replace(inst_opts, threaded=False)
|
|
384
|
+
|
|
385
|
+
installer = PyenvVersionInstaller(
|
|
386
|
+
inst_version,
|
|
387
|
+
interp_opts=inst_opts,
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
exe = installer.install()
|
|
391
|
+
return Interp(exe, version)
|
omdev/interp/resolvers.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006
|
|
1
|
+
# ruff: noqa: UP006 UP007
|
|
2
2
|
import abc
|
|
3
3
|
import collections
|
|
4
4
|
import typing as ta
|
|
@@ -11,6 +11,7 @@ from .pyenv import PyenvInterpProvider
|
|
|
11
11
|
from .system import SystemInterpProvider
|
|
12
12
|
from .types import Interp
|
|
13
13
|
from .types import InterpSpecifier
|
|
14
|
+
from .types import InterpVersion
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
INTERP_PROVIDER_TYPES_BY_NAME: ta.Mapping[str, ta.Type[InterpProvider]] = {
|
|
@@ -26,17 +27,47 @@ class InterpResolver:
|
|
|
26
27
|
super().__init__()
|
|
27
28
|
self._providers: ta.Mapping[str, InterpProvider] = collections.OrderedDict(providers)
|
|
28
29
|
|
|
29
|
-
def
|
|
30
|
+
def _resolve_installed(self, spec: InterpSpecifier) -> ta.Optional[ta.Tuple[InterpProvider, InterpVersion]]:
|
|
30
31
|
lst = [
|
|
31
32
|
(i, si)
|
|
32
33
|
for i, p in enumerate(self._providers.values())
|
|
33
34
|
for si in p.get_installed_versions(spec)
|
|
34
35
|
if spec.contains(si)
|
|
35
36
|
]
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
slst = sorted(lst, key=lambda t: (-t[0], t[1]))
|
|
39
|
+
if not slst:
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
bi, bv = slst[-1]
|
|
38
43
|
bp = list(self._providers.values())[bi]
|
|
39
|
-
return bp
|
|
44
|
+
return (bp, bv)
|
|
45
|
+
|
|
46
|
+
def resolve(
|
|
47
|
+
self,
|
|
48
|
+
spec: InterpSpecifier,
|
|
49
|
+
*,
|
|
50
|
+
install: bool = False,
|
|
51
|
+
) -> ta.Optional[Interp]:
|
|
52
|
+
tup = self._resolve_installed(spec)
|
|
53
|
+
if tup is not None:
|
|
54
|
+
bp, bv = tup
|
|
55
|
+
return bp.get_installed_version(bv)
|
|
56
|
+
|
|
57
|
+
if not install:
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
tp = list(self._providers.values())[0] # noqa
|
|
61
|
+
|
|
62
|
+
sv = sorted(
|
|
63
|
+
[s for s in tp.get_installable_versions(spec) if s in spec],
|
|
64
|
+
key=lambda s: s.version,
|
|
65
|
+
)
|
|
66
|
+
if not sv:
|
|
67
|
+
return None
|
|
68
|
+
|
|
69
|
+
bv = sv[-1]
|
|
70
|
+
return tp.install_version(bv)
|
|
40
71
|
|
|
41
72
|
def list(self, spec: InterpSpecifier) -> None:
|
|
42
73
|
print('installed:')
|
omdev/interp/types.py
CHANGED
|
@@ -85,6 +85,9 @@ class InterpSpecifier:
|
|
|
85
85
|
def contains(self, iv: InterpVersion) -> bool:
|
|
86
86
|
return self.specifier.contains(iv.version) and self.opts == iv.opts
|
|
87
87
|
|
|
88
|
+
def __contains__(self, iv: InterpVersion) -> bool:
|
|
89
|
+
return self.contains(iv)
|
|
90
|
+
|
|
88
91
|
|
|
89
92
|
@dc.dataclass(frozen=True)
|
|
90
93
|
class Interp:
|
omdev/pyproject/cli.py
CHANGED
|
@@ -8,6 +8,7 @@ TODO:
|
|
|
8
8
|
- build / package / publish / version roll
|
|
9
9
|
- {pkg_name: [src_dirs]}, default excludes, generate MANIFST.in, ...
|
|
10
10
|
- env vars - PYTHONPATH
|
|
11
|
+
- optional uv backend
|
|
11
12
|
|
|
12
13
|
lookit:
|
|
13
14
|
- https://pdm-project.org/en/latest/
|
|
@@ -48,6 +49,7 @@ from .configs import PyprojectConfig
|
|
|
48
49
|
from .configs import PyprojectConfigPreparer
|
|
49
50
|
from .configs import VenvConfig
|
|
50
51
|
from .pkg import PyprojectPackageGenerator
|
|
52
|
+
from .reqs import RequirementsRewriter
|
|
51
53
|
|
|
52
54
|
|
|
53
55
|
##
|
|
@@ -121,7 +123,7 @@ class Venv:
|
|
|
121
123
|
@cached_nullary
|
|
122
124
|
def interp_exe(self) -> str:
|
|
123
125
|
i = InterpSpecifier.parse(check_not_none(self._cfg.interp))
|
|
124
|
-
return DEFAULT_INTERP_RESOLVER.resolve(i).exe
|
|
126
|
+
return check_not_none(DEFAULT_INTERP_RESOLVER.resolve(i, install=True)).exe
|
|
125
127
|
|
|
126
128
|
@cached_nullary
|
|
127
129
|
def exe(self) -> str:
|
|
@@ -152,11 +154,13 @@ class Venv:
|
|
|
152
154
|
)
|
|
153
155
|
|
|
154
156
|
if (sr := self._cfg.requires):
|
|
157
|
+
rr = RequirementsRewriter(self._name)
|
|
158
|
+
reqs = [rr.rewrite(req) for req in sr]
|
|
155
159
|
subprocess_check_call(
|
|
156
160
|
ve,
|
|
157
161
|
'-m', 'pip',
|
|
158
162
|
'install', '-v',
|
|
159
|
-
*
|
|
163
|
+
*reqs,
|
|
160
164
|
)
|
|
161
165
|
|
|
162
166
|
return True
|
omdev/pyproject/pkg.py
CHANGED
|
@@ -4,6 +4,14 @@ TODO:
|
|
|
4
4
|
- __revision__
|
|
5
5
|
- entry_points
|
|
6
6
|
|
|
7
|
+
** NOTE **
|
|
8
|
+
setuptools now (2024/09/02) has experimental support for extensions in pure pyproject.toml - but we still want a
|
|
9
|
+
separate '-cext' package
|
|
10
|
+
https://setuptools.pypa.io/en/latest/userguide/ext_modules.html
|
|
11
|
+
https://github.com/pypa/setuptools/commit/1a9d87308dc0d8aabeaae0dce989b35dfb7699f0#diff-61d113525e9cc93565799a4bb8b34a68e2945b8a3f7d90c81380614a4ea39542R7-R8
|
|
12
|
+
|
|
13
|
+
--
|
|
14
|
+
|
|
7
15
|
https://setuptools.pypa.io/en/latest/references/keywords.html
|
|
8
16
|
https://packaging.python.org/en/latest/specifications/pyproject-toml
|
|
9
17
|
|
|
@@ -15,7 +23,7 @@ https://github.com/pypa/sampleproject/blob/db5806e0a3204034c51b1c00dde7d5eb3fa25
|
|
|
15
23
|
https://pip.pypa.io/en/stable/cli/pip_install/#vcs-support
|
|
16
24
|
vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir
|
|
17
25
|
'git+https://github.com/wrmsr/omlish@master#subdirectory=.pip/omlish'
|
|
18
|
-
"""
|
|
26
|
+
""" # noqa
|
|
19
27
|
# ruff: noqa: UP006 UP007
|
|
20
28
|
import abc
|
|
21
29
|
import dataclasses as dc
|
omdev/pyproject/reqs.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TODO:
|
|
3
|
+
- embed pip._internal.req.parse_requirements, add additional env stuff? breaks compat with raw pip
|
|
4
|
+
"""
|
|
5
|
+
# ruff: noqa: UP007
|
|
6
|
+
import os.path
|
|
7
|
+
import tempfile
|
|
8
|
+
import typing as ta
|
|
9
|
+
|
|
10
|
+
from omlish.lite.cached import cached_nullary
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RequirementsRewriter:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
venv: ta.Optional[str] = None,
|
|
17
|
+
) -> None:
|
|
18
|
+
super().__init__()
|
|
19
|
+
self._venv = venv
|
|
20
|
+
|
|
21
|
+
@cached_nullary
|
|
22
|
+
def _tmp_dir(self) -> str:
|
|
23
|
+
return tempfile.mkdtemp('-omlish-reqs')
|
|
24
|
+
|
|
25
|
+
VENV_MAGIC = '# @omdev-venv'
|
|
26
|
+
|
|
27
|
+
def rewrite_file(self, in_file: str) -> str:
|
|
28
|
+
with open(in_file) as f:
|
|
29
|
+
src = f.read()
|
|
30
|
+
|
|
31
|
+
in_lines = src.splitlines(keepends=True)
|
|
32
|
+
out_lines = []
|
|
33
|
+
|
|
34
|
+
for l in in_lines:
|
|
35
|
+
if self.VENV_MAGIC in l:
|
|
36
|
+
lp, _, rp = l.partition(self.VENV_MAGIC)
|
|
37
|
+
rp = rp.partition('#')[0]
|
|
38
|
+
omit = False
|
|
39
|
+
for v in rp.split():
|
|
40
|
+
if v[0] == '!':
|
|
41
|
+
if self._venv is not None and self._venv == v[1:]:
|
|
42
|
+
omit = True
|
|
43
|
+
break
|
|
44
|
+
else:
|
|
45
|
+
raise NotImplementedError
|
|
46
|
+
|
|
47
|
+
if omit:
|
|
48
|
+
out_lines.append('# OMITTED: ' + l)
|
|
49
|
+
continue
|
|
50
|
+
|
|
51
|
+
out_req = self.rewrite(l.rstrip('\n'), for_file=True)
|
|
52
|
+
out_lines.append(out_req + '\n')
|
|
53
|
+
|
|
54
|
+
out_file = os.path.join(self._tmp_dir(), os.path.basename(in_file))
|
|
55
|
+
if os.path.exists(out_file):
|
|
56
|
+
raise Exception(f'file exists: {out_file}')
|
|
57
|
+
|
|
58
|
+
with open(out_file, 'w') as f:
|
|
59
|
+
f.write(''.join(out_lines))
|
|
60
|
+
return out_file
|
|
61
|
+
|
|
62
|
+
def rewrite(self, in_req: str, *, for_file: bool = False) -> str:
|
|
63
|
+
if in_req.strip().startswith('-r'):
|
|
64
|
+
l = in_req.strip()
|
|
65
|
+
lp, _, rp = l.partition(' ')
|
|
66
|
+
if lp == '-r':
|
|
67
|
+
inc_in_file, _, rest = rp.partition(' ')
|
|
68
|
+
else:
|
|
69
|
+
inc_in_file, rest = lp[2:], rp
|
|
70
|
+
|
|
71
|
+
inc_out_file = self.rewrite_file(inc_in_file)
|
|
72
|
+
if for_file:
|
|
73
|
+
return ' '.join(['-r ', inc_out_file, rest])
|
|
74
|
+
else:
|
|
75
|
+
return '-r' + inc_out_file
|
|
76
|
+
|
|
77
|
+
else:
|
|
78
|
+
return in_req
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# @omlish-lite
|
|
3
|
+
# @omlish-script
|
|
4
|
+
import argparse
|
|
5
|
+
import re
|
|
6
|
+
import string
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
_VERSION_PAT = re.compile(r"__version__ = '(?P<version>[^\']+)'")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _main() -> None:
|
|
13
|
+
parser = argparse.ArgumentParser()
|
|
14
|
+
|
|
15
|
+
parser.add_argument('file')
|
|
16
|
+
parser.add_argument('-w', '--write', action='store_true')
|
|
17
|
+
args = parser.parse_args()
|
|
18
|
+
|
|
19
|
+
with open(args.file) as f:
|
|
20
|
+
src = f.read()
|
|
21
|
+
|
|
22
|
+
lines = src.splitlines(keepends=True)
|
|
23
|
+
for i, l in enumerate(lines):
|
|
24
|
+
if (m := _VERSION_PAT.fullmatch(l.strip())) is None:
|
|
25
|
+
continue
|
|
26
|
+
parts = m.groupdict()['version'].split('.')
|
|
27
|
+
rp = parts[-1]
|
|
28
|
+
ni = [i for i in range(len(rp)) if rp[i] not in string.digits][-1] + 1
|
|
29
|
+
tp, np = rp[:ni], rp[ni:]
|
|
30
|
+
n = int(np)
|
|
31
|
+
nv = '.'.join([*parts[:-1], tp + str(n + 1)])
|
|
32
|
+
lines[i] = f"__version__ = '{nv}'\n"
|
|
33
|
+
new_src = ''.join(lines)
|
|
34
|
+
|
|
35
|
+
if args.write:
|
|
36
|
+
with open(args.file, 'w') as f:
|
|
37
|
+
f.write(new_src)
|
|
38
|
+
else:
|
|
39
|
+
print(new_src)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == '__main__':
|
|
43
|
+
_main()
|
omdev/scripts/interp.py
CHANGED
|
@@ -1206,8 +1206,8 @@ class JsonLogFormatter(logging.Formatter):
|
|
|
1206
1206
|
STANDARD_LOG_FORMAT_PARTS = [
|
|
1207
1207
|
('asctime', '%(asctime)-15s'),
|
|
1208
1208
|
('process', 'pid=%(process)-6s'),
|
|
1209
|
-
('thread', 'tid=%(thread)
|
|
1210
|
-
('levelname', '%(levelname)
|
|
1209
|
+
('thread', 'tid=%(thread)x'),
|
|
1210
|
+
('levelname', '%(levelname)s'),
|
|
1211
1211
|
('name', '%(name)s'),
|
|
1212
1212
|
('separator', '::'),
|
|
1213
1213
|
('message', '%(message)s'),
|
|
@@ -1358,6 +1358,9 @@ class InterpSpecifier:
|
|
|
1358
1358
|
def contains(self, iv: InterpVersion) -> bool:
|
|
1359
1359
|
return self.specifier.contains(iv.version) and self.opts == iv.opts
|
|
1360
1360
|
|
|
1361
|
+
def __contains__(self, iv: InterpVersion) -> bool:
|
|
1362
|
+
return self.contains(iv)
|
|
1363
|
+
|
|
1361
1364
|
|
|
1362
1365
|
@dc.dataclass(frozen=True)
|
|
1363
1366
|
class Interp:
|
|
@@ -1576,6 +1579,7 @@ TODO:
|
|
|
1576
1579
|
- backends
|
|
1577
1580
|
- local builds
|
|
1578
1581
|
- deadsnakes?
|
|
1582
|
+
- uv
|
|
1579
1583
|
- loose versions
|
|
1580
1584
|
"""
|
|
1581
1585
|
|
|
@@ -1725,6 +1729,7 @@ class PyenvInstallOpts:
|
|
|
1725
1729
|
|
|
1726
1730
|
DEFAULT_PYENV_INSTALL_OPTS = PyenvInstallOpts(opts=['-s', '-v'])
|
|
1727
1731
|
DEBUG_PYENV_INSTALL_OPTS = PyenvInstallOpts(opts=['-g'])
|
|
1732
|
+
THREADED_PYENV_INSTALL_OPTS = PyenvInstallOpts(conf_opts=['--disable-gil'])
|
|
1728
1733
|
|
|
1729
1734
|
|
|
1730
1735
|
#
|
|
@@ -1785,19 +1790,19 @@ class DarwinPyenvInstallOpts(PyenvInstallOptsProvider):
|
|
|
1785
1790
|
f"--with-tcltk-libs='-L{tcl_tk_prefix}/lib -ltcl{tcl_tk_ver} -ltk{tcl_tk_ver}'",
|
|
1786
1791
|
])
|
|
1787
1792
|
|
|
1788
|
-
@cached_nullary
|
|
1789
|
-
def brew_ssl_opts(self) -> PyenvInstallOpts:
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1793
|
+
# @cached_nullary
|
|
1794
|
+
# def brew_ssl_opts(self) -> PyenvInstallOpts:
|
|
1795
|
+
# pkg_config_path = subprocess_check_output_str('brew', '--prefix', 'openssl')
|
|
1796
|
+
# if 'PKG_CONFIG_PATH' in os.environ:
|
|
1797
|
+
# pkg_config_path += ':' + os.environ['PKG_CONFIG_PATH']
|
|
1798
|
+
# return PyenvInstallOpts(env={'PKG_CONFIG_PATH': pkg_config_path})
|
|
1794
1799
|
|
|
1795
1800
|
def opts(self) -> PyenvInstallOpts:
|
|
1796
1801
|
return PyenvInstallOpts().merge(
|
|
1797
1802
|
self.framework_opts(),
|
|
1798
1803
|
self.brew_deps_opts(),
|
|
1799
1804
|
self.brew_tcl_opts(),
|
|
1800
|
-
self.brew_ssl_opts(),
|
|
1805
|
+
# self.brew_ssl_opts(),
|
|
1801
1806
|
)
|
|
1802
1807
|
|
|
1803
1808
|
|
|
@@ -1811,27 +1816,39 @@ PLATFORM_PYENV_INSTALL_OPTS: ta.Dict[str, PyenvInstallOptsProvider] = {
|
|
|
1811
1816
|
|
|
1812
1817
|
|
|
1813
1818
|
class PyenvVersionInstaller:
|
|
1819
|
+
"""
|
|
1820
|
+
Messy: can install freethreaded build with a 't' suffixed version str _or_ by THREADED_PYENV_INSTALL_OPTS - need
|
|
1821
|
+
latter to build custom interp with ft, need former to use canned / blessed interps. Muh.
|
|
1822
|
+
"""
|
|
1814
1823
|
|
|
1815
1824
|
def __init__(
|
|
1816
1825
|
self,
|
|
1817
1826
|
version: str,
|
|
1818
1827
|
opts: ta.Optional[PyenvInstallOpts] = None,
|
|
1828
|
+
interp_opts: InterpOpts = InterpOpts(),
|
|
1819
1829
|
*,
|
|
1820
|
-
|
|
1830
|
+
no_default_opts: bool = False,
|
|
1821
1831
|
pyenv: Pyenv = Pyenv(),
|
|
1822
1832
|
) -> None:
|
|
1823
1833
|
super().__init__()
|
|
1824
1834
|
|
|
1825
|
-
if
|
|
1826
|
-
|
|
1827
|
-
|
|
1835
|
+
if no_default_opts:
|
|
1836
|
+
if opts is None:
|
|
1837
|
+
opts = PyenvInstallOpts()
|
|
1838
|
+
else:
|
|
1839
|
+
lst = [opts if opts is not None else DEFAULT_PYENV_INSTALL_OPTS]
|
|
1840
|
+
if interp_opts.debug:
|
|
1828
1841
|
lst.append(DEBUG_PYENV_INSTALL_OPTS)
|
|
1842
|
+
if interp_opts.threaded:
|
|
1843
|
+
lst.append(THREADED_PYENV_INSTALL_OPTS)
|
|
1829
1844
|
lst.append(PLATFORM_PYENV_INSTALL_OPTS[sys.platform].opts())
|
|
1830
1845
|
opts = PyenvInstallOpts().merge(*lst)
|
|
1831
1846
|
|
|
1832
1847
|
self._version = version
|
|
1833
1848
|
self._opts = opts
|
|
1834
|
-
self.
|
|
1849
|
+
self._interp_opts = interp_opts
|
|
1850
|
+
|
|
1851
|
+
self._no_default_opts = no_default_opts
|
|
1835
1852
|
self._pyenv = pyenv
|
|
1836
1853
|
|
|
1837
1854
|
@property
|
|
@@ -1844,7 +1861,7 @@ class PyenvVersionInstaller:
|
|
|
1844
1861
|
|
|
1845
1862
|
@cached_nullary
|
|
1846
1863
|
def install_name(self) -> str:
|
|
1847
|
-
return self._version + ('-debug' if self.
|
|
1864
|
+
return self._version + ('-debug' if self._interp_opts.debug else '')
|
|
1848
1865
|
|
|
1849
1866
|
@cached_nullary
|
|
1850
1867
|
def install_dir(self) -> str:
|
|
@@ -1852,7 +1869,7 @@ class PyenvVersionInstaller:
|
|
|
1852
1869
|
|
|
1853
1870
|
@cached_nullary
|
|
1854
1871
|
def install(self) -> str:
|
|
1855
|
-
env =
|
|
1872
|
+
env = {**os.environ, **self._opts.env}
|
|
1856
1873
|
for k, l in [
|
|
1857
1874
|
('CFLAGS', self._opts.cflags),
|
|
1858
1875
|
('LDFLAGS', self._opts.ldflags),
|
|
@@ -1863,7 +1880,13 @@ class PyenvVersionInstaller:
|
|
|
1863
1880
|
v += ' ' + os.environ[k]
|
|
1864
1881
|
env[k] = v
|
|
1865
1882
|
|
|
1866
|
-
subprocess_check_call(
|
|
1883
|
+
subprocess_check_call(
|
|
1884
|
+
self._pyenv.exe(),
|
|
1885
|
+
'install',
|
|
1886
|
+
*self._opts.opts,
|
|
1887
|
+
self._version,
|
|
1888
|
+
env=env,
|
|
1889
|
+
)
|
|
1867
1890
|
|
|
1868
1891
|
exe = os.path.join(self.install_dir(), 'bin', 'python')
|
|
1869
1892
|
if not os.path.isfile(exe):
|
|
@@ -1965,6 +1988,21 @@ class PyenvInterpProvider(InterpProvider):
|
|
|
1965
1988
|
lst.append(dc.replace(iv, opts=dc.replace(iv.opts, debug=d)))
|
|
1966
1989
|
return lst
|
|
1967
1990
|
|
|
1991
|
+
def install_version(self, version: InterpVersion) -> Interp:
|
|
1992
|
+
inst_version = str(version.version)
|
|
1993
|
+
inst_opts = version.opts
|
|
1994
|
+
if inst_opts.threaded:
|
|
1995
|
+
inst_version += 't'
|
|
1996
|
+
inst_opts = dc.replace(inst_opts, threaded=False)
|
|
1997
|
+
|
|
1998
|
+
installer = PyenvVersionInstaller(
|
|
1999
|
+
inst_version,
|
|
2000
|
+
interp_opts=inst_opts,
|
|
2001
|
+
)
|
|
2002
|
+
|
|
2003
|
+
exe = installer.install()
|
|
2004
|
+
return Interp(exe, version)
|
|
2005
|
+
|
|
1968
2006
|
|
|
1969
2007
|
########################################
|
|
1970
2008
|
# ../system.py
|
|
@@ -2082,7 +2120,7 @@ class SystemInterpProvider(InterpProvider):
|
|
|
2082
2120
|
|
|
2083
2121
|
########################################
|
|
2084
2122
|
# ../resolvers.py
|
|
2085
|
-
# ruff: noqa: UP006
|
|
2123
|
+
# ruff: noqa: UP006 UP007
|
|
2086
2124
|
|
|
2087
2125
|
|
|
2088
2126
|
INTERP_PROVIDER_TYPES_BY_NAME: ta.Mapping[str, ta.Type[InterpProvider]] = {
|
|
@@ -2098,17 +2136,47 @@ class InterpResolver:
|
|
|
2098
2136
|
super().__init__()
|
|
2099
2137
|
self._providers: ta.Mapping[str, InterpProvider] = collections.OrderedDict(providers)
|
|
2100
2138
|
|
|
2101
|
-
def
|
|
2139
|
+
def _resolve_installed(self, spec: InterpSpecifier) -> ta.Optional[ta.Tuple[InterpProvider, InterpVersion]]:
|
|
2102
2140
|
lst = [
|
|
2103
2141
|
(i, si)
|
|
2104
2142
|
for i, p in enumerate(self._providers.values())
|
|
2105
2143
|
for si in p.get_installed_versions(spec)
|
|
2106
2144
|
if spec.contains(si)
|
|
2107
2145
|
]
|
|
2108
|
-
|
|
2109
|
-
|
|
2146
|
+
|
|
2147
|
+
slst = sorted(lst, key=lambda t: (-t[0], t[1]))
|
|
2148
|
+
if not slst:
|
|
2149
|
+
return None
|
|
2150
|
+
|
|
2151
|
+
bi, bv = slst[-1]
|
|
2110
2152
|
bp = list(self._providers.values())[bi]
|
|
2111
|
-
return bp
|
|
2153
|
+
return (bp, bv)
|
|
2154
|
+
|
|
2155
|
+
def resolve(
|
|
2156
|
+
self,
|
|
2157
|
+
spec: InterpSpecifier,
|
|
2158
|
+
*,
|
|
2159
|
+
install: bool = False,
|
|
2160
|
+
) -> ta.Optional[Interp]:
|
|
2161
|
+
tup = self._resolve_installed(spec)
|
|
2162
|
+
if tup is not None:
|
|
2163
|
+
bp, bv = tup
|
|
2164
|
+
return bp.get_installed_version(bv)
|
|
2165
|
+
|
|
2166
|
+
if not install:
|
|
2167
|
+
return None
|
|
2168
|
+
|
|
2169
|
+
tp = list(self._providers.values())[0] # noqa
|
|
2170
|
+
|
|
2171
|
+
sv = sorted(
|
|
2172
|
+
[s for s in tp.get_installable_versions(spec) if s in spec],
|
|
2173
|
+
key=lambda s: s.version,
|
|
2174
|
+
)
|
|
2175
|
+
if not sv:
|
|
2176
|
+
return None
|
|
2177
|
+
|
|
2178
|
+
bv = sv[-1]
|
|
2179
|
+
return tp.install_version(bv)
|
|
2112
2180
|
|
|
2113
2181
|
def list(self, spec: InterpSpecifier) -> None:
|
|
2114
2182
|
print('installed:')
|
|
@@ -2161,7 +2229,7 @@ def _list_cmd(args) -> None:
|
|
|
2161
2229
|
def _resolve_cmd(args) -> None:
|
|
2162
2230
|
r = DEFAULT_INTERP_RESOLVER
|
|
2163
2231
|
s = InterpSpecifier.parse(args.version)
|
|
2164
|
-
print(r.resolve(s).exe)
|
|
2232
|
+
print(check_not_none(r.resolve(s)).exe)
|
|
2165
2233
|
|
|
2166
2234
|
|
|
2167
2235
|
def _build_parser() -> argparse.ArgumentParser:
|
omdev/scripts/pyproject.py
CHANGED
|
@@ -11,6 +11,7 @@ TODO:
|
|
|
11
11
|
- build / package / publish / version roll
|
|
12
12
|
- {pkg_name: [src_dirs]}, default excludes, generate MANIFST.in, ...
|
|
13
13
|
- env vars - PYTHONPATH
|
|
14
|
+
- optional uv backend
|
|
14
15
|
|
|
15
16
|
lookit:
|
|
16
17
|
- https://pdm-project.org/en/latest/
|
|
@@ -55,6 +56,7 @@ import string
|
|
|
55
56
|
import subprocess
|
|
56
57
|
import sys
|
|
57
58
|
import tarfile
|
|
59
|
+
import tempfile
|
|
58
60
|
import threading
|
|
59
61
|
import time
|
|
60
62
|
import types
|
|
@@ -1883,6 +1885,83 @@ def is_sunder(name: str) -> bool:
|
|
|
1883
1885
|
)
|
|
1884
1886
|
|
|
1885
1887
|
|
|
1888
|
+
########################################
|
|
1889
|
+
# ../reqs.py
|
|
1890
|
+
"""
|
|
1891
|
+
TODO:
|
|
1892
|
+
- embed pip._internal.req.parse_requirements, add additional env stuff? breaks compat with raw pip
|
|
1893
|
+
"""
|
|
1894
|
+
# ruff: noqa: UP007
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
class RequirementsRewriter:
|
|
1898
|
+
def __init__(
|
|
1899
|
+
self,
|
|
1900
|
+
venv: ta.Optional[str] = None,
|
|
1901
|
+
) -> None:
|
|
1902
|
+
super().__init__()
|
|
1903
|
+
self._venv = venv
|
|
1904
|
+
|
|
1905
|
+
@cached_nullary
|
|
1906
|
+
def _tmp_dir(self) -> str:
|
|
1907
|
+
return tempfile.mkdtemp('-omlish-reqs')
|
|
1908
|
+
|
|
1909
|
+
VENV_MAGIC = '# @omdev-venv'
|
|
1910
|
+
|
|
1911
|
+
def rewrite_file(self, in_file: str) -> str:
|
|
1912
|
+
with open(in_file) as f:
|
|
1913
|
+
src = f.read()
|
|
1914
|
+
|
|
1915
|
+
in_lines = src.splitlines(keepends=True)
|
|
1916
|
+
out_lines = []
|
|
1917
|
+
|
|
1918
|
+
for l in in_lines:
|
|
1919
|
+
if self.VENV_MAGIC in l:
|
|
1920
|
+
lp, _, rp = l.partition(self.VENV_MAGIC)
|
|
1921
|
+
rp = rp.partition('#')[0]
|
|
1922
|
+
omit = False
|
|
1923
|
+
for v in rp.split():
|
|
1924
|
+
if v[0] == '!':
|
|
1925
|
+
if self._venv is not None and self._venv == v[1:]:
|
|
1926
|
+
omit = True
|
|
1927
|
+
break
|
|
1928
|
+
else:
|
|
1929
|
+
raise NotImplementedError
|
|
1930
|
+
|
|
1931
|
+
if omit:
|
|
1932
|
+
out_lines.append('# OMITTED: ' + l)
|
|
1933
|
+
continue
|
|
1934
|
+
|
|
1935
|
+
out_req = self.rewrite(l.rstrip('\n'), for_file=True)
|
|
1936
|
+
out_lines.append(out_req + '\n')
|
|
1937
|
+
|
|
1938
|
+
out_file = os.path.join(self._tmp_dir(), os.path.basename(in_file))
|
|
1939
|
+
if os.path.exists(out_file):
|
|
1940
|
+
raise Exception(f'file exists: {out_file}')
|
|
1941
|
+
|
|
1942
|
+
with open(out_file, 'w') as f:
|
|
1943
|
+
f.write(''.join(out_lines))
|
|
1944
|
+
return out_file
|
|
1945
|
+
|
|
1946
|
+
def rewrite(self, in_req: str, *, for_file: bool = False) -> str:
|
|
1947
|
+
if in_req.strip().startswith('-r'):
|
|
1948
|
+
l = in_req.strip()
|
|
1949
|
+
lp, _, rp = l.partition(' ')
|
|
1950
|
+
if lp == '-r':
|
|
1951
|
+
inc_in_file, _, rest = rp.partition(' ')
|
|
1952
|
+
else:
|
|
1953
|
+
inc_in_file, rest = lp[2:], rp
|
|
1954
|
+
|
|
1955
|
+
inc_out_file = self.rewrite_file(inc_in_file)
|
|
1956
|
+
if for_file:
|
|
1957
|
+
return ' '.join(['-r ', inc_out_file, rest])
|
|
1958
|
+
else:
|
|
1959
|
+
return '-r' + inc_out_file
|
|
1960
|
+
|
|
1961
|
+
else:
|
|
1962
|
+
return in_req
|
|
1963
|
+
|
|
1964
|
+
|
|
1886
1965
|
########################################
|
|
1887
1966
|
# ../../versioning/specifiers.py
|
|
1888
1967
|
# Copyright (c) Donald Stufft and individual contributors.
|
|
@@ -2473,8 +2552,8 @@ class JsonLogFormatter(logging.Formatter):
|
|
|
2473
2552
|
STANDARD_LOG_FORMAT_PARTS = [
|
|
2474
2553
|
('asctime', '%(asctime)-15s'),
|
|
2475
2554
|
('process', 'pid=%(process)-6s'),
|
|
2476
|
-
('thread', 'tid=%(thread)
|
|
2477
|
-
('levelname', '%(levelname)
|
|
2555
|
+
('thread', 'tid=%(thread)x'),
|
|
2556
|
+
('levelname', '%(levelname)s'),
|
|
2478
2557
|
('name', '%(name)s'),
|
|
2479
2558
|
('separator', '::'),
|
|
2480
2559
|
('message', '%(message)s'),
|
|
@@ -2926,6 +3005,9 @@ class InterpSpecifier:
|
|
|
2926
3005
|
def contains(self, iv: InterpVersion) -> bool:
|
|
2927
3006
|
return self.specifier.contains(iv.version) and self.opts == iv.opts
|
|
2928
3007
|
|
|
3008
|
+
def __contains__(self, iv: InterpVersion) -> bool:
|
|
3009
|
+
return self.contains(iv)
|
|
3010
|
+
|
|
2929
3011
|
|
|
2930
3012
|
@dc.dataclass(frozen=True)
|
|
2931
3013
|
class Interp:
|
|
@@ -3388,6 +3470,14 @@ TODO:
|
|
|
3388
3470
|
- __revision__
|
|
3389
3471
|
- entry_points
|
|
3390
3472
|
|
|
3473
|
+
** NOTE **
|
|
3474
|
+
setuptools now (2024/09/02) has experimental support for extensions in pure pyproject.toml - but we still want a
|
|
3475
|
+
separate '-cext' package
|
|
3476
|
+
https://setuptools.pypa.io/en/latest/userguide/ext_modules.html
|
|
3477
|
+
https://github.com/pypa/setuptools/commit/1a9d87308dc0d8aabeaae0dce989b35dfb7699f0#diff-61d113525e9cc93565799a4bb8b34a68e2945b8a3f7d90c81380614a4ea39542R7-R8
|
|
3478
|
+
|
|
3479
|
+
--
|
|
3480
|
+
|
|
3391
3481
|
https://setuptools.pypa.io/en/latest/references/keywords.html
|
|
3392
3482
|
https://packaging.python.org/en/latest/specifications/pyproject-toml
|
|
3393
3483
|
|
|
@@ -3399,7 +3489,7 @@ https://github.com/pypa/sampleproject/blob/db5806e0a3204034c51b1c00dde7d5eb3fa25
|
|
|
3399
3489
|
https://pip.pypa.io/en/stable/cli/pip_install/#vcs-support
|
|
3400
3490
|
vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir
|
|
3401
3491
|
'git+https://github.com/wrmsr/omlish@master#subdirectory=.pip/omlish'
|
|
3402
|
-
"""
|
|
3492
|
+
""" # noqa
|
|
3403
3493
|
# ruff: noqa: UP006 UP007
|
|
3404
3494
|
|
|
3405
3495
|
|
|
@@ -3754,6 +3844,7 @@ TODO:
|
|
|
3754
3844
|
- backends
|
|
3755
3845
|
- local builds
|
|
3756
3846
|
- deadsnakes?
|
|
3847
|
+
- uv
|
|
3757
3848
|
- loose versions
|
|
3758
3849
|
"""
|
|
3759
3850
|
|
|
@@ -3903,6 +3994,7 @@ class PyenvInstallOpts:
|
|
|
3903
3994
|
|
|
3904
3995
|
DEFAULT_PYENV_INSTALL_OPTS = PyenvInstallOpts(opts=['-s', '-v'])
|
|
3905
3996
|
DEBUG_PYENV_INSTALL_OPTS = PyenvInstallOpts(opts=['-g'])
|
|
3997
|
+
THREADED_PYENV_INSTALL_OPTS = PyenvInstallOpts(conf_opts=['--disable-gil'])
|
|
3906
3998
|
|
|
3907
3999
|
|
|
3908
4000
|
#
|
|
@@ -3963,19 +4055,19 @@ class DarwinPyenvInstallOpts(PyenvInstallOptsProvider):
|
|
|
3963
4055
|
f"--with-tcltk-libs='-L{tcl_tk_prefix}/lib -ltcl{tcl_tk_ver} -ltk{tcl_tk_ver}'",
|
|
3964
4056
|
])
|
|
3965
4057
|
|
|
3966
|
-
@cached_nullary
|
|
3967
|
-
def brew_ssl_opts(self) -> PyenvInstallOpts:
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
4058
|
+
# @cached_nullary
|
|
4059
|
+
# def brew_ssl_opts(self) -> PyenvInstallOpts:
|
|
4060
|
+
# pkg_config_path = subprocess_check_output_str('brew', '--prefix', 'openssl')
|
|
4061
|
+
# if 'PKG_CONFIG_PATH' in os.environ:
|
|
4062
|
+
# pkg_config_path += ':' + os.environ['PKG_CONFIG_PATH']
|
|
4063
|
+
# return PyenvInstallOpts(env={'PKG_CONFIG_PATH': pkg_config_path})
|
|
3972
4064
|
|
|
3973
4065
|
def opts(self) -> PyenvInstallOpts:
|
|
3974
4066
|
return PyenvInstallOpts().merge(
|
|
3975
4067
|
self.framework_opts(),
|
|
3976
4068
|
self.brew_deps_opts(),
|
|
3977
4069
|
self.brew_tcl_opts(),
|
|
3978
|
-
self.brew_ssl_opts(),
|
|
4070
|
+
# self.brew_ssl_opts(),
|
|
3979
4071
|
)
|
|
3980
4072
|
|
|
3981
4073
|
|
|
@@ -3989,27 +4081,39 @@ PLATFORM_PYENV_INSTALL_OPTS: ta.Dict[str, PyenvInstallOptsProvider] = {
|
|
|
3989
4081
|
|
|
3990
4082
|
|
|
3991
4083
|
class PyenvVersionInstaller:
|
|
4084
|
+
"""
|
|
4085
|
+
Messy: can install freethreaded build with a 't' suffixed version str _or_ by THREADED_PYENV_INSTALL_OPTS - need
|
|
4086
|
+
latter to build custom interp with ft, need former to use canned / blessed interps. Muh.
|
|
4087
|
+
"""
|
|
3992
4088
|
|
|
3993
4089
|
def __init__(
|
|
3994
4090
|
self,
|
|
3995
4091
|
version: str,
|
|
3996
4092
|
opts: ta.Optional[PyenvInstallOpts] = None,
|
|
4093
|
+
interp_opts: InterpOpts = InterpOpts(),
|
|
3997
4094
|
*,
|
|
3998
|
-
|
|
4095
|
+
no_default_opts: bool = False,
|
|
3999
4096
|
pyenv: Pyenv = Pyenv(),
|
|
4000
4097
|
) -> None:
|
|
4001
4098
|
super().__init__()
|
|
4002
4099
|
|
|
4003
|
-
if
|
|
4004
|
-
|
|
4005
|
-
|
|
4100
|
+
if no_default_opts:
|
|
4101
|
+
if opts is None:
|
|
4102
|
+
opts = PyenvInstallOpts()
|
|
4103
|
+
else:
|
|
4104
|
+
lst = [opts if opts is not None else DEFAULT_PYENV_INSTALL_OPTS]
|
|
4105
|
+
if interp_opts.debug:
|
|
4006
4106
|
lst.append(DEBUG_PYENV_INSTALL_OPTS)
|
|
4107
|
+
if interp_opts.threaded:
|
|
4108
|
+
lst.append(THREADED_PYENV_INSTALL_OPTS)
|
|
4007
4109
|
lst.append(PLATFORM_PYENV_INSTALL_OPTS[sys.platform].opts())
|
|
4008
4110
|
opts = PyenvInstallOpts().merge(*lst)
|
|
4009
4111
|
|
|
4010
4112
|
self._version = version
|
|
4011
4113
|
self._opts = opts
|
|
4012
|
-
self.
|
|
4114
|
+
self._interp_opts = interp_opts
|
|
4115
|
+
|
|
4116
|
+
self._no_default_opts = no_default_opts
|
|
4013
4117
|
self._pyenv = pyenv
|
|
4014
4118
|
|
|
4015
4119
|
@property
|
|
@@ -4022,7 +4126,7 @@ class PyenvVersionInstaller:
|
|
|
4022
4126
|
|
|
4023
4127
|
@cached_nullary
|
|
4024
4128
|
def install_name(self) -> str:
|
|
4025
|
-
return self._version + ('-debug' if self.
|
|
4129
|
+
return self._version + ('-debug' if self._interp_opts.debug else '')
|
|
4026
4130
|
|
|
4027
4131
|
@cached_nullary
|
|
4028
4132
|
def install_dir(self) -> str:
|
|
@@ -4030,7 +4134,7 @@ class PyenvVersionInstaller:
|
|
|
4030
4134
|
|
|
4031
4135
|
@cached_nullary
|
|
4032
4136
|
def install(self) -> str:
|
|
4033
|
-
env =
|
|
4137
|
+
env = {**os.environ, **self._opts.env}
|
|
4034
4138
|
for k, l in [
|
|
4035
4139
|
('CFLAGS', self._opts.cflags),
|
|
4036
4140
|
('LDFLAGS', self._opts.ldflags),
|
|
@@ -4041,7 +4145,13 @@ class PyenvVersionInstaller:
|
|
|
4041
4145
|
v += ' ' + os.environ[k]
|
|
4042
4146
|
env[k] = v
|
|
4043
4147
|
|
|
4044
|
-
subprocess_check_call(
|
|
4148
|
+
subprocess_check_call(
|
|
4149
|
+
self._pyenv.exe(),
|
|
4150
|
+
'install',
|
|
4151
|
+
*self._opts.opts,
|
|
4152
|
+
self._version,
|
|
4153
|
+
env=env,
|
|
4154
|
+
)
|
|
4045
4155
|
|
|
4046
4156
|
exe = os.path.join(self.install_dir(), 'bin', 'python')
|
|
4047
4157
|
if not os.path.isfile(exe):
|
|
@@ -4143,6 +4253,21 @@ class PyenvInterpProvider(InterpProvider):
|
|
|
4143
4253
|
lst.append(dc.replace(iv, opts=dc.replace(iv.opts, debug=d)))
|
|
4144
4254
|
return lst
|
|
4145
4255
|
|
|
4256
|
+
def install_version(self, version: InterpVersion) -> Interp:
|
|
4257
|
+
inst_version = str(version.version)
|
|
4258
|
+
inst_opts = version.opts
|
|
4259
|
+
if inst_opts.threaded:
|
|
4260
|
+
inst_version += 't'
|
|
4261
|
+
inst_opts = dc.replace(inst_opts, threaded=False)
|
|
4262
|
+
|
|
4263
|
+
installer = PyenvVersionInstaller(
|
|
4264
|
+
inst_version,
|
|
4265
|
+
interp_opts=inst_opts,
|
|
4266
|
+
)
|
|
4267
|
+
|
|
4268
|
+
exe = installer.install()
|
|
4269
|
+
return Interp(exe, version)
|
|
4270
|
+
|
|
4146
4271
|
|
|
4147
4272
|
########################################
|
|
4148
4273
|
# ../../interp/system.py
|
|
@@ -4260,7 +4385,7 @@ class SystemInterpProvider(InterpProvider):
|
|
|
4260
4385
|
|
|
4261
4386
|
########################################
|
|
4262
4387
|
# ../../interp/resolvers.py
|
|
4263
|
-
# ruff: noqa: UP006
|
|
4388
|
+
# ruff: noqa: UP006 UP007
|
|
4264
4389
|
|
|
4265
4390
|
|
|
4266
4391
|
INTERP_PROVIDER_TYPES_BY_NAME: ta.Mapping[str, ta.Type[InterpProvider]] = {
|
|
@@ -4276,17 +4401,47 @@ class InterpResolver:
|
|
|
4276
4401
|
super().__init__()
|
|
4277
4402
|
self._providers: ta.Mapping[str, InterpProvider] = collections.OrderedDict(providers)
|
|
4278
4403
|
|
|
4279
|
-
def
|
|
4404
|
+
def _resolve_installed(self, spec: InterpSpecifier) -> ta.Optional[ta.Tuple[InterpProvider, InterpVersion]]:
|
|
4280
4405
|
lst = [
|
|
4281
4406
|
(i, si)
|
|
4282
4407
|
for i, p in enumerate(self._providers.values())
|
|
4283
4408
|
for si in p.get_installed_versions(spec)
|
|
4284
4409
|
if spec.contains(si)
|
|
4285
4410
|
]
|
|
4286
|
-
|
|
4287
|
-
|
|
4411
|
+
|
|
4412
|
+
slst = sorted(lst, key=lambda t: (-t[0], t[1]))
|
|
4413
|
+
if not slst:
|
|
4414
|
+
return None
|
|
4415
|
+
|
|
4416
|
+
bi, bv = slst[-1]
|
|
4288
4417
|
bp = list(self._providers.values())[bi]
|
|
4289
|
-
return bp
|
|
4418
|
+
return (bp, bv)
|
|
4419
|
+
|
|
4420
|
+
def resolve(
|
|
4421
|
+
self,
|
|
4422
|
+
spec: InterpSpecifier,
|
|
4423
|
+
*,
|
|
4424
|
+
install: bool = False,
|
|
4425
|
+
) -> ta.Optional[Interp]:
|
|
4426
|
+
tup = self._resolve_installed(spec)
|
|
4427
|
+
if tup is not None:
|
|
4428
|
+
bp, bv = tup
|
|
4429
|
+
return bp.get_installed_version(bv)
|
|
4430
|
+
|
|
4431
|
+
if not install:
|
|
4432
|
+
return None
|
|
4433
|
+
|
|
4434
|
+
tp = list(self._providers.values())[0] # noqa
|
|
4435
|
+
|
|
4436
|
+
sv = sorted(
|
|
4437
|
+
[s for s in tp.get_installable_versions(spec) if s in spec],
|
|
4438
|
+
key=lambda s: s.version,
|
|
4439
|
+
)
|
|
4440
|
+
if not sv:
|
|
4441
|
+
return None
|
|
4442
|
+
|
|
4443
|
+
bv = sv[-1]
|
|
4444
|
+
return tp.install_version(bv)
|
|
4290
4445
|
|
|
4291
4446
|
def list(self, spec: InterpSpecifier) -> None:
|
|
4292
4447
|
print('installed:')
|
|
@@ -4401,7 +4556,7 @@ class Venv:
|
|
|
4401
4556
|
@cached_nullary
|
|
4402
4557
|
def interp_exe(self) -> str:
|
|
4403
4558
|
i = InterpSpecifier.parse(check_not_none(self._cfg.interp))
|
|
4404
|
-
return DEFAULT_INTERP_RESOLVER.resolve(i).exe
|
|
4559
|
+
return check_not_none(DEFAULT_INTERP_RESOLVER.resolve(i, install=True)).exe
|
|
4405
4560
|
|
|
4406
4561
|
@cached_nullary
|
|
4407
4562
|
def exe(self) -> str:
|
|
@@ -4432,11 +4587,13 @@ class Venv:
|
|
|
4432
4587
|
)
|
|
4433
4588
|
|
|
4434
4589
|
if (sr := self._cfg.requires):
|
|
4590
|
+
rr = RequirementsRewriter(self._name)
|
|
4591
|
+
reqs = [rr.rewrite(req) for req in sr]
|
|
4435
4592
|
subprocess_check_call(
|
|
4436
4593
|
ve,
|
|
4437
4594
|
'-m', 'pip',
|
|
4438
4595
|
'install', '-v',
|
|
4439
|
-
*
|
|
4596
|
+
*reqs,
|
|
4440
4597
|
)
|
|
4441
4598
|
|
|
4442
4599
|
return True
|
omdev/tools/rst.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import contextlib
|
|
3
|
+
import io
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import docutils.core
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def rst2html(rst, report_level=None):
|
|
10
|
+
kwargs = {
|
|
11
|
+
'writer_name': 'html',
|
|
12
|
+
'settings_overrides': {
|
|
13
|
+
'_disable_config': True,
|
|
14
|
+
'report_level': int(report_level) if report_level else 0,
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
target = io.StringIO()
|
|
19
|
+
with contextlib.redirect_stderr(target):
|
|
20
|
+
parts = docutils.core.publish_parts(rst, **kwargs) # type: ignore
|
|
21
|
+
html = parts['html_body']
|
|
22
|
+
warning = target.getvalue().strip()
|
|
23
|
+
return html, warning
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _main() -> None:
|
|
27
|
+
parser = argparse.ArgumentParser()
|
|
28
|
+
parser.add_argument('input', nargs='?')
|
|
29
|
+
args = parser.parse_args()
|
|
30
|
+
|
|
31
|
+
if args.input:
|
|
32
|
+
with open(args.input) as f:
|
|
33
|
+
src = f.read()
|
|
34
|
+
else:
|
|
35
|
+
src = sys.stdin.read()
|
|
36
|
+
|
|
37
|
+
html, warning = rst2html(src)
|
|
38
|
+
if warning:
|
|
39
|
+
sys.stderr.write(warning)
|
|
40
|
+
print(html)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == '__main__':
|
|
44
|
+
_main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: omdev
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev20
|
|
4
4
|
Summary: omdev
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -12,11 +12,12 @@ 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.dev20
|
|
16
16
|
Provides-Extra: all
|
|
17
17
|
Requires-Dist: pycparser ~=2.22 ; extra == 'all'
|
|
18
18
|
Requires-Dist: cffi ~=1.17 ; extra == 'all'
|
|
19
19
|
Requires-Dist: pcpp ~=1.30 ; extra == 'all'
|
|
20
|
+
Requires-Dist: docutils ~=0.21 ; extra == 'all'
|
|
20
21
|
Requires-Dist: mypy ~=1.11 ; extra == 'all'
|
|
21
22
|
Requires-Dist: tokenize-rt ~=6.0 ; extra == 'all'
|
|
22
23
|
Requires-Dist: wheel ~=0.44 ; extra == 'all'
|
|
@@ -24,6 +25,8 @@ Provides-Extra: c
|
|
|
24
25
|
Requires-Dist: pycparser ~=2.22 ; extra == 'c'
|
|
25
26
|
Requires-Dist: cffi ~=1.17 ; extra == 'c'
|
|
26
27
|
Requires-Dist: pcpp ~=1.30 ; extra == 'c'
|
|
28
|
+
Provides-Extra: docutils
|
|
29
|
+
Requires-Dist: docutils ~=0.21 ; extra == 'docutils'
|
|
27
30
|
Provides-Extra: mypy
|
|
28
31
|
Requires-Dist: mypy ~=1.11 ; extra == 'mypy'
|
|
29
32
|
Provides-Extra: tokens
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
omdev/__about__.py,sha256=
|
|
1
|
+
omdev/__about__.py,sha256=788lo_UuOSYF74y1RBiNlWkDdPnRFcmBAV5qYkaFJzE,868
|
|
2
2
|
omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
omdev/bracepy.py,sha256=HwBK5XmlOsF_juTel25fRLJK9vHSJCWXuCc-OZlevRQ,2619
|
|
4
4
|
omdev/classdot.py,sha256=urN5Pzd2ooAwnfkH0z-muQxdO90IMo-sX2WB-A37lVU,1533
|
|
@@ -33,14 +33,14 @@ omdev/cexts/_distutils/compilers/options.py,sha256=H7r5IcLvga5Fs3jjXWIT-6ap3JBdu
|
|
|
33
33
|
omdev/cexts/_distutils/compilers/unixccompiler.py,sha256=o1h8QuyupLntv4F21_XjzAZmCiwwxJuTmOirvBSL-Qw,15419
|
|
34
34
|
omdev/interp/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
|
35
35
|
omdev/interp/__main__.py,sha256=gFhR9DikwDZk0LqgdR3qq_aXQHThUOPllDmHDOfnFAU,67
|
|
36
|
-
omdev/interp/cli.py,sha256=
|
|
36
|
+
omdev/interp/cli.py,sha256=8T3qLXTC2mni5FXDHkHN3mZG9_BnjkDMXYy6EYbAYR8,1679
|
|
37
37
|
omdev/interp/inspect.py,sha256=SI4jQmWfXCnlceFTxlVRfTlEYYCjO_X12wuG5e74yto,2849
|
|
38
|
-
omdev/interp/providers.py,sha256=
|
|
39
|
-
omdev/interp/pyenv.py,sha256=
|
|
40
|
-
omdev/interp/resolvers.py,sha256=
|
|
38
|
+
omdev/interp/providers.py,sha256=PFEjozW0c33eqg8sno-GHMKbhVUzQF9jrAx-M0uQimk,1787
|
|
39
|
+
omdev/interp/pyenv.py,sha256=oxwvX7fpM4VMVeqq09JHHweifPI5l4uFAa3V_V9z5Yg,11774
|
|
40
|
+
omdev/interp/resolvers.py,sha256=e8H8WcVC0Du3nCWrghsbVLJuP3ABaiH_DexZhjZITpQ,3007
|
|
41
41
|
omdev/interp/standalone.py,sha256=XcltiL7ypcfV89C82_3knQ3Kx7aW4wnnxf2056ZXC3A,7731
|
|
42
42
|
omdev/interp/system.py,sha256=UFHfMR0CHCEnNx5fhrze8esAwigpRrJUA33ftq6nA0I,3514
|
|
43
|
-
omdev/interp/types.py,sha256=
|
|
43
|
+
omdev/interp/types.py,sha256=2nM3MJaOU8O1XA8DrvwyOjBWSboBn16kgFIy5JVkDck,2440
|
|
44
44
|
omdev/mypy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
45
|
omdev/mypy/debug.py,sha256=WcZw-3Z1njg_KFGqi3DB6RuqbBa3dLArJnjVCuY1Mn0,3003
|
|
46
46
|
omdev/precheck/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -49,13 +49,15 @@ omdev/precheck/precheck.py,sha256=2yTjNGvjPYf3QxUBbCbehBYYuB8gDR_dYSTrlNCs9qU,83
|
|
|
49
49
|
omdev/pyproject/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
|
50
50
|
omdev/pyproject/__main__.py,sha256=gFhR9DikwDZk0LqgdR3qq_aXQHThUOPllDmHDOfnFAU,67
|
|
51
51
|
omdev/pyproject/cexts.py,sha256=x13piOOnNrYbA17qZLDVuR0p1sqhgEwpk4FtImX-klM,4281
|
|
52
|
-
omdev/pyproject/cli.py,sha256=
|
|
52
|
+
omdev/pyproject/cli.py,sha256=6KrZrrsEVPEiZHEFp0WieDy5r0cfCbTlHl8AvvDzIRM,10199
|
|
53
53
|
omdev/pyproject/configs.py,sha256=MFHnmpMjlwxw74-SyX1Q1qNQ4ptwTXEzDGkeUcGY0mA,2822
|
|
54
|
-
omdev/pyproject/pkg.py,sha256=
|
|
54
|
+
omdev/pyproject/pkg.py,sha256=_uPJNU9i3zbtZ8yw6h0ZTEGtEVJp07EacdHFs3jMMHM,9862
|
|
55
|
+
omdev/pyproject/reqs.py,sha256=coq21cdWQIPs06-iuRnwc6F2Sf-IxpqoT6DEMhol2kA,2298
|
|
55
56
|
omdev/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
|
+
omdev/scripts/bumpversion.py,sha256=Kn7fo73Hs8uJh3Hi3EIyLOlzLPWAC6dwuD_lZ3cIzuY,1064
|
|
56
58
|
omdev/scripts/execrss.py,sha256=HzDNmwXOO8fMwIRXw9q8CUnVfLFCQASyU2tfY_y2Vf8,324
|
|
57
|
-
omdev/scripts/interp.py,sha256=
|
|
58
|
-
omdev/scripts/pyproject.py,sha256=
|
|
59
|
+
omdev/scripts/interp.py,sha256=i0Mq1ryZOTPOchV4liGjUiWNv0xLkoRWWIRb5BUH36s,65122
|
|
60
|
+
omdev/scripts/pyproject.py,sha256=dPq7pk4PAYQumFqvH3Ig_02W3S6gK09rYO9dfGHD4UI,144198
|
|
59
61
|
omdev/toml/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
|
60
62
|
omdev/toml/parser.py,sha256=84bn09uhYHwQGyfww6Rw6y1RxPAE_HDltODOSakcqDM,29186
|
|
61
63
|
omdev/toml/writer.py,sha256=dwz_Qw8z5Z_nmWpXqch63W6S_j6n256erb7AGFTVzB4,2872
|
|
@@ -63,13 +65,14 @@ omdev/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
63
65
|
omdev/tools/dockertools.py,sha256=3844AhUst6kYo2xKNn-2Npi-f6r4rocxEOx0tHjE0dk,2063
|
|
64
66
|
omdev/tools/gittools.py,sha256=zPy2D5WDs-CbwT86_T_hbaq5yCuss5e-ouUccXC6xlg,578
|
|
65
67
|
omdev/tools/revisions.py,sha256=pJBHRdgImLnFSo9h6pPsdX-Xbam3UnFOapWrY4U49-A,5393
|
|
68
|
+
omdev/tools/rst.py,sha256=6dWk8QZHoGiLSuBw3TKsXZjjFK6wWBEtPi9krdCLKKg,977
|
|
66
69
|
omdev/tools/sqlrepl.py,sha256=v9uVQ4nvquSXcQVYIFq34ikumSILvKqzD6lUKLcncCE,5646
|
|
67
70
|
omdev/tools/traceimport.py,sha256=oDry9CwIv5h96wSaTVKJ0qQ5vMGxYE5oBtfF-GYNLJs,13430
|
|
68
71
|
omdev/versioning/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
|
69
72
|
omdev/versioning/specifiers.py,sha256=6Odf9e6farwlPRsD_YqwTfYKG-BXn_dIcKtqfkhfodI,17432
|
|
70
73
|
omdev/versioning/versions.py,sha256=ei2eopEsJq3zSMJmezK1nzZgikgCdxFtnF3f69nCRZQ,12246
|
|
71
|
-
omdev-0.0.0.
|
|
72
|
-
omdev-0.0.0.
|
|
73
|
-
omdev-0.0.0.
|
|
74
|
-
omdev-0.0.0.
|
|
75
|
-
omdev-0.0.0.
|
|
74
|
+
omdev-0.0.0.dev20.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
75
|
+
omdev-0.0.0.dev20.dist-info/METADATA,sha256=dXX3XKNo3x_K4TJHqehI9HHc7n9DV2Ov07GaGbMVw9U,1252
|
|
76
|
+
omdev-0.0.0.dev20.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
77
|
+
omdev-0.0.0.dev20.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
|
78
|
+
omdev-0.0.0.dev20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|