omdev 0.0.0.dev180__py3-none-any.whl → 0.0.0.dev182__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.
- omdev/interp/inject.py +1 -1
- omdev/interp/inspect.py +9 -4
- omdev/interp/providers/system.py +5 -2
- omdev/interp/pyenv/inject.py +1 -1
- omdev/interp/pyenv/install.py +251 -0
- omdev/interp/pyenv/provider.py +144 -0
- omdev/interp/pyenv/pyenv.py +0 -380
- omdev/interp/venvs.py +114 -0
- omdev/pyproject/configs.py +3 -4
- omdev/pyproject/inject.py +12 -0
- omdev/pyproject/venvs.py +16 -52
- omdev/scripts/interp.py +121 -114
- omdev/scripts/pyproject.py +477 -343
- {omdev-0.0.0.dev180.dist-info → omdev-0.0.0.dev182.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev180.dist-info → omdev-0.0.0.dev182.dist-info}/RECORD +19 -15
- {omdev-0.0.0.dev180.dist-info → omdev-0.0.0.dev182.dist-info}/LICENSE +0 -0
- {omdev-0.0.0.dev180.dist-info → omdev-0.0.0.dev182.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev180.dist-info → omdev-0.0.0.dev182.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev180.dist-info → omdev-0.0.0.dev182.dist-info}/top_level.txt +0 -0
omdev/scripts/interp.py
CHANGED
@@ -1050,13 +1050,6 @@ json_dump_compact: ta.Callable[..., bytes] = functools.partial(json.dump, **JSON
|
|
1050
1050
|
json_dumps_compact: ta.Callable[..., str] = functools.partial(json.dumps, **JSON_COMPACT_KWARGS)
|
1051
1051
|
|
1052
1052
|
|
1053
|
-
########################################
|
1054
|
-
# ../../../omlish/lite/logs.py
|
1055
|
-
|
1056
|
-
|
1057
|
-
log = logging.getLogger(__name__)
|
1058
|
-
|
1059
|
-
|
1060
1053
|
########################################
|
1061
1054
|
# ../../../omlish/lite/maybes.py
|
1062
1055
|
|
@@ -4205,9 +4198,15 @@ class InterpInspection:
|
|
4205
4198
|
|
4206
4199
|
|
4207
4200
|
class InterpInspector:
|
4208
|
-
def __init__(
|
4201
|
+
def __init__(
|
4202
|
+
self,
|
4203
|
+
*,
|
4204
|
+
log: ta.Optional[logging.Logger] = None,
|
4205
|
+
) -> None:
|
4209
4206
|
super().__init__()
|
4210
4207
|
|
4208
|
+
self._log = log
|
4209
|
+
|
4211
4210
|
self._cache: ta.Dict[str, ta.Optional[InterpInspection]] = {}
|
4212
4211
|
|
4213
4212
|
_RAW_INSPECTION_CODE = """
|
@@ -4256,13 +4255,95 @@ class InterpInspector:
|
|
4256
4255
|
try:
|
4257
4256
|
ret = await self._inspect(exe)
|
4258
4257
|
except Exception as e: # noqa
|
4259
|
-
if
|
4260
|
-
|
4258
|
+
if self._log is not None and self._log.isEnabledFor(logging.DEBUG):
|
4259
|
+
self._log.exception('Failed to inspect interp: %s', exe)
|
4261
4260
|
ret = None
|
4262
4261
|
self._cache[exe] = ret
|
4263
4262
|
return ret
|
4264
4263
|
|
4265
4264
|
|
4265
|
+
########################################
|
4266
|
+
# ../pyenv/pyenv.py
|
4267
|
+
"""
|
4268
|
+
TODO:
|
4269
|
+
- custom tags
|
4270
|
+
- 'aliases'
|
4271
|
+
- https://github.com/pyenv/pyenv/pull/2966
|
4272
|
+
- https://github.com/pyenv/pyenv/issues/218 (lol)
|
4273
|
+
- probably need custom (temp?) definition file
|
4274
|
+
- *or* python-build directly just into the versions dir?
|
4275
|
+
- optionally install / upgrade pyenv itself
|
4276
|
+
- new vers dont need these custom mac opts, only run on old vers
|
4277
|
+
"""
|
4278
|
+
|
4279
|
+
|
4280
|
+
class Pyenv:
|
4281
|
+
def __init__(
|
4282
|
+
self,
|
4283
|
+
*,
|
4284
|
+
root: ta.Optional[str] = None,
|
4285
|
+
) -> None:
|
4286
|
+
if root is not None and not (isinstance(root, str) and root):
|
4287
|
+
raise ValueError(f'pyenv_root: {root!r}')
|
4288
|
+
|
4289
|
+
super().__init__()
|
4290
|
+
|
4291
|
+
self._root_kw = root
|
4292
|
+
|
4293
|
+
@async_cached_nullary
|
4294
|
+
async def root(self) -> ta.Optional[str]:
|
4295
|
+
if self._root_kw is not None:
|
4296
|
+
return self._root_kw
|
4297
|
+
|
4298
|
+
if shutil.which('pyenv'):
|
4299
|
+
return await asyncio_subprocesses.check_output_str('pyenv', 'root')
|
4300
|
+
|
4301
|
+
d = os.path.expanduser('~/.pyenv')
|
4302
|
+
if os.path.isdir(d) and os.path.isfile(os.path.join(d, 'bin', 'pyenv')):
|
4303
|
+
return d
|
4304
|
+
|
4305
|
+
return None
|
4306
|
+
|
4307
|
+
@async_cached_nullary
|
4308
|
+
async def exe(self) -> str:
|
4309
|
+
return os.path.join(check.not_none(await self.root()), 'bin', 'pyenv')
|
4310
|
+
|
4311
|
+
async def version_exes(self) -> ta.List[ta.Tuple[str, str]]:
|
4312
|
+
if (root := await self.root()) is None:
|
4313
|
+
return []
|
4314
|
+
ret = []
|
4315
|
+
vp = os.path.join(root, 'versions')
|
4316
|
+
if os.path.isdir(vp):
|
4317
|
+
for dn in os.listdir(vp):
|
4318
|
+
ep = os.path.join(vp, dn, 'bin', 'python')
|
4319
|
+
if not os.path.isfile(ep):
|
4320
|
+
continue
|
4321
|
+
ret.append((dn, ep))
|
4322
|
+
return ret
|
4323
|
+
|
4324
|
+
async def installable_versions(self) -> ta.List[str]:
|
4325
|
+
if await self.root() is None:
|
4326
|
+
return []
|
4327
|
+
ret = []
|
4328
|
+
s = await asyncio_subprocesses.check_output_str(await self.exe(), 'install', '--list')
|
4329
|
+
for l in s.splitlines():
|
4330
|
+
if not l.startswith(' '):
|
4331
|
+
continue
|
4332
|
+
l = l.strip()
|
4333
|
+
if not l:
|
4334
|
+
continue
|
4335
|
+
ret.append(l)
|
4336
|
+
return ret
|
4337
|
+
|
4338
|
+
async def update(self) -> bool:
|
4339
|
+
if (root := await self.root()) is None:
|
4340
|
+
return False
|
4341
|
+
if not os.path.isdir(os.path.join(root, '.git')):
|
4342
|
+
return False
|
4343
|
+
await asyncio_subprocesses.check_call('git', 'pull', cwd=root)
|
4344
|
+
return True
|
4345
|
+
|
4346
|
+
|
4266
4347
|
########################################
|
4267
4348
|
# ../resolvers.py
|
4268
4349
|
|
@@ -4397,12 +4478,14 @@ class SystemInterpProvider(InterpProvider):
|
|
4397
4478
|
options: Options = Options(),
|
4398
4479
|
*,
|
4399
4480
|
inspector: ta.Optional[InterpInspector] = None,
|
4481
|
+
log: ta.Optional[logging.Logger] = None,
|
4400
4482
|
) -> None:
|
4401
4483
|
super().__init__()
|
4402
4484
|
|
4403
4485
|
self._options = options
|
4404
4486
|
|
4405
4487
|
self._inspector = inspector
|
4488
|
+
self._log = log
|
4406
4489
|
|
4407
4490
|
#
|
4408
4491
|
|
@@ -4476,7 +4559,8 @@ class SystemInterpProvider(InterpProvider):
|
|
4476
4559
|
lst = []
|
4477
4560
|
for e in self.exes():
|
4478
4561
|
if (ev := await self.get_exe_version(e)) is None:
|
4479
|
-
|
4562
|
+
if self._log is not None:
|
4563
|
+
self._log.debug('Invalid system version: %s', e)
|
4480
4564
|
continue
|
4481
4565
|
lst.append((e, ev))
|
4482
4566
|
return lst
|
@@ -4498,88 +4582,7 @@ class SystemInterpProvider(InterpProvider):
|
|
4498
4582
|
|
4499
4583
|
|
4500
4584
|
########################################
|
4501
|
-
# ../pyenv/
|
4502
|
-
"""
|
4503
|
-
TODO:
|
4504
|
-
- custom tags
|
4505
|
-
- 'aliases'
|
4506
|
-
- https://github.com/pyenv/pyenv/pull/2966
|
4507
|
-
- https://github.com/pyenv/pyenv/issues/218 (lol)
|
4508
|
-
- probably need custom (temp?) definition file
|
4509
|
-
- *or* python-build directly just into the versions dir?
|
4510
|
-
- optionally install / upgrade pyenv itself
|
4511
|
-
- new vers dont need these custom mac opts, only run on old vers
|
4512
|
-
"""
|
4513
|
-
|
4514
|
-
|
4515
|
-
##
|
4516
|
-
|
4517
|
-
|
4518
|
-
class Pyenv:
|
4519
|
-
def __init__(
|
4520
|
-
self,
|
4521
|
-
*,
|
4522
|
-
root: ta.Optional[str] = None,
|
4523
|
-
) -> None:
|
4524
|
-
if root is not None and not (isinstance(root, str) and root):
|
4525
|
-
raise ValueError(f'pyenv_root: {root!r}')
|
4526
|
-
|
4527
|
-
super().__init__()
|
4528
|
-
|
4529
|
-
self._root_kw = root
|
4530
|
-
|
4531
|
-
@async_cached_nullary
|
4532
|
-
async def root(self) -> ta.Optional[str]:
|
4533
|
-
if self._root_kw is not None:
|
4534
|
-
return self._root_kw
|
4535
|
-
|
4536
|
-
if shutil.which('pyenv'):
|
4537
|
-
return await asyncio_subprocesses.check_output_str('pyenv', 'root')
|
4538
|
-
|
4539
|
-
d = os.path.expanduser('~/.pyenv')
|
4540
|
-
if os.path.isdir(d) and os.path.isfile(os.path.join(d, 'bin', 'pyenv')):
|
4541
|
-
return d
|
4542
|
-
|
4543
|
-
return None
|
4544
|
-
|
4545
|
-
@async_cached_nullary
|
4546
|
-
async def exe(self) -> str:
|
4547
|
-
return os.path.join(check.not_none(await self.root()), 'bin', 'pyenv')
|
4548
|
-
|
4549
|
-
async def version_exes(self) -> ta.List[ta.Tuple[str, str]]:
|
4550
|
-
if (root := await self.root()) is None:
|
4551
|
-
return []
|
4552
|
-
ret = []
|
4553
|
-
vp = os.path.join(root, 'versions')
|
4554
|
-
if os.path.isdir(vp):
|
4555
|
-
for dn in os.listdir(vp):
|
4556
|
-
ep = os.path.join(vp, dn, 'bin', 'python')
|
4557
|
-
if not os.path.isfile(ep):
|
4558
|
-
continue
|
4559
|
-
ret.append((dn, ep))
|
4560
|
-
return ret
|
4561
|
-
|
4562
|
-
async def installable_versions(self) -> ta.List[str]:
|
4563
|
-
if await self.root() is None:
|
4564
|
-
return []
|
4565
|
-
ret = []
|
4566
|
-
s = await asyncio_subprocesses.check_output_str(await self.exe(), 'install', '--list')
|
4567
|
-
for l in s.splitlines():
|
4568
|
-
if not l.startswith(' '):
|
4569
|
-
continue
|
4570
|
-
l = l.strip()
|
4571
|
-
if not l:
|
4572
|
-
continue
|
4573
|
-
ret.append(l)
|
4574
|
-
return ret
|
4575
|
-
|
4576
|
-
async def update(self) -> bool:
|
4577
|
-
if (root := await self.root()) is None:
|
4578
|
-
return False
|
4579
|
-
if not os.path.isdir(os.path.join(root, '.git')):
|
4580
|
-
return False
|
4581
|
-
await asyncio_subprocesses.check_call('git', 'pull', cwd=root)
|
4582
|
-
return True
|
4585
|
+
# ../pyenv/install.py
|
4583
4586
|
|
4584
4587
|
|
4585
4588
|
##
|
@@ -4817,7 +4820,27 @@ class PyenvVersionInstaller:
|
|
4817
4820
|
return exe
|
4818
4821
|
|
4819
4822
|
|
4820
|
-
|
4823
|
+
########################################
|
4824
|
+
# ../providers/inject.py
|
4825
|
+
|
4826
|
+
|
4827
|
+
def bind_interp_providers() -> InjectorBindings:
|
4828
|
+
lst: ta.List[InjectorBindingOrBindings] = [
|
4829
|
+
inj.bind_array(InterpProvider),
|
4830
|
+
inj.bind_array_type(InterpProvider, InterpProviders),
|
4831
|
+
|
4832
|
+
inj.bind(RunningInterpProvider, singleton=True),
|
4833
|
+
inj.bind(InterpProvider, to_key=RunningInterpProvider, array=True),
|
4834
|
+
|
4835
|
+
inj.bind(SystemInterpProvider, singleton=True),
|
4836
|
+
inj.bind(InterpProvider, to_key=SystemInterpProvider, array=True),
|
4837
|
+
]
|
4838
|
+
|
4839
|
+
return inj.as_bindings(*lst)
|
4840
|
+
|
4841
|
+
|
4842
|
+
########################################
|
4843
|
+
# ../pyenv/provider.py
|
4821
4844
|
|
4822
4845
|
|
4823
4846
|
class PyenvInterpProvider(InterpProvider):
|
@@ -4833,6 +4856,7 @@ class PyenvInterpProvider(InterpProvider):
|
|
4833
4856
|
*,
|
4834
4857
|
pyenv: Pyenv,
|
4835
4858
|
inspector: InterpInspector,
|
4859
|
+
log: ta.Optional[logging.Logger] = None,
|
4836
4860
|
) -> None:
|
4837
4861
|
super().__init__()
|
4838
4862
|
|
@@ -4840,6 +4864,7 @@ class PyenvInterpProvider(InterpProvider):
|
|
4840
4864
|
|
4841
4865
|
self._pyenv = pyenv
|
4842
4866
|
self._inspector = inspector
|
4867
|
+
self._log = log
|
4843
4868
|
|
4844
4869
|
#
|
4845
4870
|
|
@@ -4884,7 +4909,8 @@ class PyenvInterpProvider(InterpProvider):
|
|
4884
4909
|
ret: ta.List[PyenvInterpProvider.Installed] = []
|
4885
4910
|
for vn, ep in await self._pyenv.version_exes():
|
4886
4911
|
if (i := await self._make_installed(vn, ep)) is None:
|
4887
|
-
|
4912
|
+
if self._log is not None:
|
4913
|
+
self._log.debug('Invalid pyenv version: %s', vn)
|
4888
4914
|
continue
|
4889
4915
|
ret.append(i)
|
4890
4916
|
return ret
|
@@ -4944,25 +4970,6 @@ class PyenvInterpProvider(InterpProvider):
|
|
4944
4970
|
return Interp(exe, version)
|
4945
4971
|
|
4946
4972
|
|
4947
|
-
########################################
|
4948
|
-
# ../providers/inject.py
|
4949
|
-
|
4950
|
-
|
4951
|
-
def bind_interp_providers() -> InjectorBindings:
|
4952
|
-
lst: ta.List[InjectorBindingOrBindings] = [
|
4953
|
-
inj.bind_array(InterpProvider),
|
4954
|
-
inj.bind_array_type(InterpProvider, InterpProviders),
|
4955
|
-
|
4956
|
-
inj.bind(RunningInterpProvider, singleton=True),
|
4957
|
-
inj.bind(InterpProvider, to_key=RunningInterpProvider, array=True),
|
4958
|
-
|
4959
|
-
inj.bind(SystemInterpProvider, singleton=True),
|
4960
|
-
inj.bind(InterpProvider, to_key=SystemInterpProvider, array=True),
|
4961
|
-
]
|
4962
|
-
|
4963
|
-
return inj.as_bindings(*lst)
|
4964
|
-
|
4965
|
-
|
4966
4973
|
########################################
|
4967
4974
|
# ../pyenv/inject.py
|
4968
4975
|
|