ominfra 0.0.0.dev178__py3-none-any.whl → 0.0.0.dev179__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- ominfra/manage/deploy/driver.py +7 -16
- ominfra/manage/deploy/inject.py +53 -19
- ominfra/manage/deploy/interp.py +2 -2
- ominfra/manage/deploy/venvs.py +2 -2
- ominfra/scripts/manage.py +788 -653
- ominfra/scripts/supervisor.py +31 -30
- {ominfra-0.0.0.dev178.dist-info → ominfra-0.0.0.dev179.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev178.dist-info → ominfra-0.0.0.dev179.dist-info}/RECORD +12 -12
- {ominfra-0.0.0.dev178.dist-info → ominfra-0.0.0.dev179.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev178.dist-info → ominfra-0.0.0.dev179.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev178.dist-info → ominfra-0.0.0.dev179.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev178.dist-info → ominfra-0.0.0.dev179.dist-info}/top_level.txt +0 -0
ominfra/manage/deploy/driver.py
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
# ruff: noqa: UP006 UP007
|
2
|
-
import os.path
|
3
2
|
import typing as ta
|
4
3
|
|
5
|
-
from omlish.lite.check import check
|
6
4
|
from omlish.lite.typing import Func1
|
7
5
|
|
8
6
|
from .apps import DeployAppManager
|
9
|
-
from .deploy import DeployManager
|
10
7
|
from .paths.manager import DeployPathsManager
|
11
8
|
from .specs import DeploySpec
|
12
9
|
from .tags import DeployAppRev
|
13
10
|
from .tags import DeployTagMap
|
11
|
+
from .tags import DeployTime
|
14
12
|
from .types import DeployHome
|
15
13
|
|
16
14
|
|
@@ -23,16 +21,18 @@ class DeployDriver:
|
|
23
21
|
self,
|
24
22
|
*,
|
25
23
|
spec: DeploySpec,
|
24
|
+
home: DeployHome,
|
25
|
+
time: DeployTime,
|
26
26
|
|
27
|
-
deploys: DeployManager,
|
28
27
|
paths: DeployPathsManager,
|
29
28
|
apps: DeployAppManager,
|
30
29
|
) -> None:
|
31
30
|
super().__init__()
|
32
31
|
|
33
32
|
self._spec = spec
|
33
|
+
self._home = home
|
34
|
+
self._time = time
|
34
35
|
|
35
|
-
self._deploys = deploys
|
36
36
|
self._paths = paths
|
37
37
|
self._apps = apps
|
38
38
|
|
@@ -41,17 +41,8 @@ class DeployDriver:
|
|
41
41
|
|
42
42
|
#
|
43
43
|
|
44
|
-
hs = check.non_empty_str(self._spec.home)
|
45
|
-
hs = os.path.expanduser(hs)
|
46
|
-
hs = os.path.realpath(hs)
|
47
|
-
hs = os.path.abspath(hs)
|
48
|
-
|
49
|
-
home = DeployHome(hs)
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
44
|
deploy_tags = DeployTagMap(
|
54
|
-
self.
|
45
|
+
self._time,
|
55
46
|
self._spec.key(),
|
56
47
|
)
|
57
48
|
|
@@ -66,6 +57,6 @@ class DeployDriver:
|
|
66
57
|
|
67
58
|
await self._apps.prepare_app(
|
68
59
|
app,
|
69
|
-
|
60
|
+
self._home,
|
70
61
|
app_tags,
|
71
62
|
)
|
ominfra/manage/deploy/inject.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# ruff: noqa: UP006 UP007
|
2
2
|
import contextlib
|
3
|
+
import os.path
|
3
4
|
import typing as ta
|
4
5
|
|
6
|
+
from omlish.lite.check import check
|
5
7
|
from omlish.lite.inject import ContextvarInjectorScope
|
6
8
|
from omlish.lite.inject import Injector
|
7
9
|
from omlish.lite.inject import InjectorBindingOrBindings
|
@@ -23,15 +25,64 @@ from .interp import InterpCommandExecutor
|
|
23
25
|
from .paths.inject import bind_deploy_paths
|
24
26
|
from .paths.owners import DeployPathOwner
|
25
27
|
from .specs import DeploySpec
|
28
|
+
from .tags import DeployTime
|
26
29
|
from .tmp import DeployHomeAtomics
|
27
30
|
from .tmp import DeployTmpManager
|
31
|
+
from .types import DeployHome
|
28
32
|
from .venvs import DeployVenvManager
|
29
33
|
|
30
34
|
|
35
|
+
##
|
36
|
+
|
37
|
+
|
31
38
|
class DeployInjectorScope(ContextvarInjectorScope):
|
32
39
|
pass
|
33
40
|
|
34
41
|
|
42
|
+
def bind_deploy_scope() -> InjectorBindings:
|
43
|
+
lst: ta.List[InjectorBindingOrBindings] = [
|
44
|
+
inj.bind_scope(DeployInjectorScope),
|
45
|
+
inj.bind_scope_seed(DeploySpec, DeployInjectorScope),
|
46
|
+
|
47
|
+
inj.bind(DeployDriver, in_=DeployInjectorScope),
|
48
|
+
]
|
49
|
+
|
50
|
+
#
|
51
|
+
|
52
|
+
def provide_deploy_driver_factory(injector: Injector, sc: DeployInjectorScope) -> DeployDriverFactory:
|
53
|
+
@contextlib.contextmanager
|
54
|
+
def factory(spec: DeploySpec) -> ta.Iterator[DeployDriver]:
|
55
|
+
with sc.enter({
|
56
|
+
inj.as_key(DeploySpec): spec,
|
57
|
+
}):
|
58
|
+
yield injector[DeployDriver]
|
59
|
+
return DeployDriverFactory(factory)
|
60
|
+
lst.append(inj.bind(provide_deploy_driver_factory, singleton=True))
|
61
|
+
|
62
|
+
#
|
63
|
+
|
64
|
+
def provide_deploy_home(deploy: DeploySpec) -> DeployHome:
|
65
|
+
hs = check.non_empty_str(deploy.home)
|
66
|
+
hs = os.path.expanduser(hs)
|
67
|
+
hs = os.path.realpath(hs)
|
68
|
+
hs = os.path.abspath(hs)
|
69
|
+
return DeployHome(hs)
|
70
|
+
lst.append(inj.bind(provide_deploy_home, in_=DeployInjectorScope))
|
71
|
+
|
72
|
+
#
|
73
|
+
|
74
|
+
def provide_deploy_time(deploys: DeployManager) -> DeployTime:
|
75
|
+
return deploys.make_deploy_time()
|
76
|
+
lst.append(inj.bind(provide_deploy_time, in_=DeployInjectorScope))
|
77
|
+
|
78
|
+
#
|
79
|
+
|
80
|
+
return inj.as_bindings(*lst)
|
81
|
+
|
82
|
+
|
83
|
+
##
|
84
|
+
|
85
|
+
|
35
86
|
def bind_deploy(
|
36
87
|
*,
|
37
88
|
deploy_config: DeployConfig,
|
@@ -40,6 +91,8 @@ def bind_deploy(
|
|
40
91
|
inj.bind(deploy_config),
|
41
92
|
|
42
93
|
bind_deploy_paths(),
|
94
|
+
|
95
|
+
bind_deploy_scope(),
|
43
96
|
]
|
44
97
|
|
45
98
|
#
|
@@ -75,25 +128,6 @@ def bind_deploy(
|
|
75
128
|
|
76
129
|
#
|
77
130
|
|
78
|
-
def provide_deploy_driver_factory(injector: Injector, sc: DeployInjectorScope) -> DeployDriverFactory:
|
79
|
-
@contextlib.contextmanager
|
80
|
-
def factory(spec: DeploySpec) -> ta.Iterator[DeployDriver]:
|
81
|
-
with sc.enter({
|
82
|
-
inj.as_key(DeploySpec): spec,
|
83
|
-
}):
|
84
|
-
yield injector[DeployDriver]
|
85
|
-
return DeployDriverFactory(factory)
|
86
|
-
lst.append(inj.bind(provide_deploy_driver_factory, singleton=True))
|
87
|
-
|
88
|
-
lst.extend([
|
89
|
-
inj.bind_scope(DeployInjectorScope),
|
90
|
-
inj.bind_scope_seed(DeploySpec, DeployInjectorScope),
|
91
|
-
|
92
|
-
inj.bind(DeployDriver, in_=DeployInjectorScope),
|
93
|
-
])
|
94
|
-
|
95
|
-
#
|
96
|
-
|
97
131
|
lst.extend([
|
98
132
|
bind_command(DeployCommand, DeployCommandExecutor),
|
99
133
|
bind_command(InterpCommand, InterpCommandExecutor),
|
ominfra/manage/deploy/interp.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ruff: noqa: UP006 UP007
|
2
2
|
import dataclasses as dc
|
3
3
|
|
4
|
-
from omdev.interp.
|
4
|
+
from omdev.interp.default import get_default_interp_resolver
|
5
5
|
from omdev.interp.types import InterpOpts
|
6
6
|
from omdev.interp.types import InterpSpecifier
|
7
7
|
from omlish.lite.check import check
|
@@ -28,7 +28,7 @@ class InterpCommand(Command['InterpCommand.Output']):
|
|
28
28
|
class InterpCommandExecutor(CommandExecutor[InterpCommand, InterpCommand.Output]):
|
29
29
|
async def execute(self, cmd: InterpCommand) -> InterpCommand.Output:
|
30
30
|
i = InterpSpecifier.parse(check.not_none(cmd.spec))
|
31
|
-
o = check.not_none(await
|
31
|
+
o = check.not_none(await get_default_interp_resolver().resolve(i, install=cmd.install))
|
32
32
|
return InterpCommand.Output(
|
33
33
|
exe=o.exe,
|
34
34
|
version=str(o.version.version),
|
ominfra/manage/deploy/venvs.py
CHANGED
@@ -6,7 +6,7 @@ TODO:
|
|
6
6
|
"""
|
7
7
|
import os.path
|
8
8
|
|
9
|
-
from omdev.interp.
|
9
|
+
from omdev.interp.default import get_default_interp_resolver
|
10
10
|
from omdev.interp.types import InterpSpecifier
|
11
11
|
from omlish.asyncs.asyncio.subprocesses import asyncio_subprocesses
|
12
12
|
from omlish.lite.check import check
|
@@ -25,7 +25,7 @@ class DeployVenvManager:
|
|
25
25
|
) -> None:
|
26
26
|
if spec.interp is not None:
|
27
27
|
i = InterpSpecifier.parse(check.not_none(spec.interp))
|
28
|
-
o = check.not_none(await
|
28
|
+
o = check.not_none(await get_default_interp_resolver().resolve(i))
|
29
29
|
sys_exe = o.exe
|
30
30
|
else:
|
31
31
|
sys_exe = 'python3'
|