ominfra 0.0.0.dev177__tar.gz → 0.0.0.dev179__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. {ominfra-0.0.0.dev177/ominfra.egg-info → ominfra-0.0.0.dev179}/PKG-INFO +3 -3
  2. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/commands.py +4 -3
  3. ominfra-0.0.0.dev179/ominfra/manage/deploy/deploy.py +34 -0
  4. ominfra-0.0.0.dev179/ominfra/manage/deploy/driver.py +62 -0
  5. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/inject.py +63 -0
  6. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/interp.py +2 -2
  7. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/venvs.py +2 -2
  8. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/scripts/manage.py +964 -592
  9. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/scripts/supervisor.py +224 -29
  10. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179/ominfra.egg-info}/PKG-INFO +3 -3
  11. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra.egg-info/SOURCES.txt +1 -0
  12. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra.egg-info/requires.txt +2 -2
  13. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/pyproject.toml +3 -3
  14. ominfra-0.0.0.dev177/ominfra/manage/deploy/deploy.py +0 -84
  15. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/LICENSE +0 -0
  16. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/MANIFEST.in +0 -0
  17. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/README.rst +0 -0
  18. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/.manifests.json +0 -0
  19. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/__about__.py +0 -0
  20. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/__init__.py +0 -0
  21. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/__init__.py +0 -0
  22. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/__init__.py +0 -0
  23. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/__main__.py +0 -0
  24. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/auth.py +0 -0
  25. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/cli.py +0 -0
  26. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/dataclasses.py +0 -0
  27. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/journald2aws/__init__.py +0 -0
  28. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/journald2aws/__main__.py +0 -0
  29. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/journald2aws/cursor.py +0 -0
  30. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/journald2aws/driver.py +0 -0
  31. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/journald2aws/main.py +0 -0
  32. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/journald2aws/poster.py +0 -0
  33. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/logs.py +0 -0
  34. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/aws/metadata.py +0 -0
  35. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/gcp/__init__.py +0 -0
  36. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/clouds/gcp/auth.py +0 -0
  37. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/cmds.py +0 -0
  38. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/configs.py +0 -0
  39. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/journald/__init__.py +0 -0
  40. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/journald/fields.py +0 -0
  41. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/journald/genmessages.py +0 -0
  42. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/journald/messages.py +0 -0
  43. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/journald/tailer.py +0 -0
  44. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/__init__.py +0 -0
  45. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/__main__.py +0 -0
  46. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/bootstrap.py +0 -0
  47. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/bootstrap_.py +0 -0
  48. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/__init__.py +0 -0
  49. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/base.py +0 -0
  50. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/inject.py +0 -0
  51. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/local.py +0 -0
  52. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/marshal.py +0 -0
  53. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/ping.py +0 -0
  54. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/subprocess.py +0 -0
  55. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/commands/types.py +0 -0
  56. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/config.py +0 -0
  57. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/__init__.py +0 -0
  58. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/apps.py +0 -0
  59. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/conf.py +0 -0
  60. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/config.py +0 -0
  61. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/git.py +0 -0
  62. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/paths/__init__.py +0 -0
  63. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/paths/inject.py +0 -0
  64. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/paths/manager.py +0 -0
  65. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/paths/owners.py +0 -0
  66. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/paths/paths.py +0 -0
  67. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/paths/types.py +0 -0
  68. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/specs.py +0 -0
  69. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/tags.py +0 -0
  70. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/tmp.py +0 -0
  71. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/deploy/types.py +0 -0
  72. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/inject.py +0 -0
  73. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/main.py +0 -0
  74. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/marshal.py +0 -0
  75. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/__init__.py +0 -0
  76. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/_main.py +0 -0
  77. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/channel.py +0 -0
  78. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/config.py +0 -0
  79. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/connection.py +0 -0
  80. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/execution.py +0 -0
  81. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/inject.py +0 -0
  82. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/payload.py +0 -0
  83. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/remote/spawning.py +0 -0
  84. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/system/__init__.py +0 -0
  85. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/system/commands.py +0 -0
  86. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/system/config.py +0 -0
  87. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/system/inject.py +0 -0
  88. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/system/packages.py +0 -0
  89. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/system/platforms.py +0 -0
  90. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/targets/__init__.py +0 -0
  91. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/targets/bestpython.py +0 -0
  92. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/targets/bestpython.sh +0 -0
  93. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/targets/connection.py +0 -0
  94. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/targets/inject.py +0 -0
  95. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/manage/targets/targets.py +0 -0
  96. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/pyremote.py +0 -0
  97. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/scripts/__init__.py +0 -0
  98. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/scripts/journald2aws.py +0 -0
  99. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/ssh.py +0 -0
  100. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/LICENSE.txt +0 -0
  101. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/__init__.py +0 -0
  102. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/__main__.py +0 -0
  103. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/configs.py +0 -0
  104. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/dispatchers.py +0 -0
  105. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/dispatchersimpl.py +0 -0
  106. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/events.py +0 -0
  107. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/exceptions.py +0 -0
  108. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/groups.py +0 -0
  109. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/groupsimpl.py +0 -0
  110. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/http.py +0 -0
  111. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/inject.py +0 -0
  112. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/io.py +0 -0
  113. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/main.py +0 -0
  114. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/pipes.py +0 -0
  115. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/privileges.py +0 -0
  116. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/process.py +0 -0
  117. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/processimpl.py +0 -0
  118. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/setup.py +0 -0
  119. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/setupimpl.py +0 -0
  120. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/signals.py +0 -0
  121. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/spawning.py +0 -0
  122. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/spawningimpl.py +0 -0
  123. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/states.py +0 -0
  124. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/supervisor.py +0 -0
  125. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/types.py +0 -0
  126. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/__init__.py +0 -0
  127. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/collections.py +0 -0
  128. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/diag.py +0 -0
  129. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/fds.py +0 -0
  130. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/fs.py +0 -0
  131. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/os.py +0 -0
  132. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/ostypes.py +0 -0
  133. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/signals.py +0 -0
  134. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/strings.py +0 -0
  135. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/supervisor/utils/users.py +0 -0
  136. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/tailscale/__init__.py +0 -0
  137. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/tailscale/api.py +0 -0
  138. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/tailscale/cli.py +0 -0
  139. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/threadworkers.py +0 -0
  140. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/tools/__init__.py +0 -0
  141. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra/tools/listresources.py +0 -0
  142. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra.egg-info/dependency_links.txt +0 -0
  143. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra.egg-info/entry_points.txt +0 -0
  144. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/ominfra.egg-info/top_level.txt +0 -0
  145. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev179}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev177
3
+ Version: 0.0.0.dev179
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ 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: omdev==0.0.0.dev177
16
- Requires-Dist: omlish==0.0.0.dev177
15
+ Requires-Dist: omdev==0.0.0.dev179
16
+ Requires-Dist: omlish==0.0.0.dev179
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -5,7 +5,7 @@ from omlish.lite.logs import log
5
5
 
6
6
  from ..commands.base import Command
7
7
  from ..commands.base import CommandExecutor
8
- from .deploy import DeployManager
8
+ from .driver import DeployDriverFactory
9
9
  from .specs import DeploySpec
10
10
 
11
11
 
@@ -23,11 +23,12 @@ class DeployCommand(Command['DeployCommand.Output']):
23
23
 
24
24
  @dc.dataclass(frozen=True)
25
25
  class DeployCommandExecutor(CommandExecutor[DeployCommand, DeployCommand.Output]):
26
- _deploy: DeployManager
26
+ _driver_factory: DeployDriverFactory
27
27
 
28
28
  async def execute(self, cmd: DeployCommand) -> DeployCommand.Output:
29
29
  log.info('Deploying! %r', cmd.spec)
30
30
 
31
- await self._deploy.run_deploy(cmd.spec)
31
+ with self._driver_factory(cmd.spec) as driver:
32
+ await driver.drive_deploy()
32
33
 
33
34
  return DeployCommand.Output()
@@ -0,0 +1,34 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import datetime
3
+ import typing as ta
4
+
5
+ from omlish.lite.typing import Func0
6
+
7
+ from .tags import DeployTime
8
+
9
+
10
+ DEPLOY_TAG_DATETIME_FMT = '%Y%m%dT%H%M%SZ'
11
+
12
+
13
+ DeployManagerUtcClock = ta.NewType('DeployManagerUtcClock', Func0[datetime.datetime])
14
+
15
+
16
+ class DeployManager:
17
+ def __init__(
18
+ self,
19
+ *,
20
+
21
+ utc_clock: ta.Optional[DeployManagerUtcClock] = None,
22
+ ):
23
+ super().__init__()
24
+
25
+ self._utc_clock = utc_clock
26
+
27
+ def _utc_now(self) -> datetime.datetime:
28
+ if self._utc_clock is not None:
29
+ return self._utc_clock() # noqa
30
+ else:
31
+ return datetime.datetime.now(tz=datetime.timezone.utc) # noqa
32
+
33
+ def make_deploy_time(self) -> DeployTime:
34
+ return DeployTime(self._utc_now().strftime(DEPLOY_TAG_DATETIME_FMT))
@@ -0,0 +1,62 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import typing as ta
3
+
4
+ from omlish.lite.typing import Func1
5
+
6
+ from .apps import DeployAppManager
7
+ from .paths.manager import DeployPathsManager
8
+ from .specs import DeploySpec
9
+ from .tags import DeployAppRev
10
+ from .tags import DeployTagMap
11
+ from .tags import DeployTime
12
+ from .types import DeployHome
13
+
14
+
15
+ class DeployDriverFactory(Func1[DeploySpec, ta.ContextManager['DeployDriver']]):
16
+ pass
17
+
18
+
19
+ class DeployDriver:
20
+ def __init__(
21
+ self,
22
+ *,
23
+ spec: DeploySpec,
24
+ home: DeployHome,
25
+ time: DeployTime,
26
+
27
+ paths: DeployPathsManager,
28
+ apps: DeployAppManager,
29
+ ) -> None:
30
+ super().__init__()
31
+
32
+ self._spec = spec
33
+ self._home = home
34
+ self._time = time
35
+
36
+ self._paths = paths
37
+ self._apps = apps
38
+
39
+ async def drive_deploy(self) -> None:
40
+ self._paths.validate_deploy_paths()
41
+
42
+ #
43
+
44
+ deploy_tags = DeployTagMap(
45
+ self._time,
46
+ self._spec.key(),
47
+ )
48
+
49
+ #
50
+
51
+ for app in self._spec.apps:
52
+ app_tags = deploy_tags.add(
53
+ app.app,
54
+ app.key(),
55
+ DeployAppRev(app.git.rev),
56
+ )
57
+
58
+ await self._apps.prepare_app(
59
+ app,
60
+ self._home,
61
+ app_tags,
62
+ )
@@ -1,6 +1,11 @@
1
1
  # ruff: noqa: UP006 UP007
2
+ import contextlib
3
+ import os.path
2
4
  import typing as ta
3
5
 
6
+ from omlish.lite.check import check
7
+ from omlish.lite.inject import ContextvarInjectorScope
8
+ from omlish.lite.inject import Injector
4
9
  from omlish.lite.inject import InjectorBindingOrBindings
5
10
  from omlish.lite.inject import InjectorBindings
6
11
  from omlish.lite.inject import inj
@@ -12,16 +17,72 @@ from .commands import DeployCommandExecutor
12
17
  from .conf import DeployConfManager
13
18
  from .config import DeployConfig
14
19
  from .deploy import DeployManager
20
+ from .driver import DeployDriver
21
+ from .driver import DeployDriverFactory
15
22
  from .git import DeployGitManager
16
23
  from .interp import InterpCommand
17
24
  from .interp import InterpCommandExecutor
18
25
  from .paths.inject import bind_deploy_paths
19
26
  from .paths.owners import DeployPathOwner
27
+ from .specs import DeploySpec
28
+ from .tags import DeployTime
20
29
  from .tmp import DeployHomeAtomics
21
30
  from .tmp import DeployTmpManager
31
+ from .types import DeployHome
22
32
  from .venvs import DeployVenvManager
23
33
 
24
34
 
35
+ ##
36
+
37
+
38
+ class DeployInjectorScope(ContextvarInjectorScope):
39
+ pass
40
+
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
+
25
86
  def bind_deploy(
26
87
  *,
27
88
  deploy_config: DeployConfig,
@@ -30,6 +91,8 @@ def bind_deploy(
30
91
  inj.bind(deploy_config),
31
92
 
32
93
  bind_deploy_paths(),
94
+
95
+ bind_deploy_scope(),
33
96
  ]
34
97
 
35
98
  #
@@ -1,7 +1,7 @@
1
1
  # ruff: noqa: UP006 UP007
2
2
  import dataclasses as dc
3
3
 
4
- from omdev.interp.resolvers import DEFAULT_INTERP_RESOLVER
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 DEFAULT_INTERP_RESOLVER.resolve(i, install=cmd.install))
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),
@@ -6,7 +6,7 @@ TODO:
6
6
  """
7
7
  import os.path
8
8
 
9
- from omdev.interp.resolvers import DEFAULT_INTERP_RESOLVER
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 DEFAULT_INTERP_RESOLVER.resolve(i))
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'