protoprimer 0.0.2.dev1__tar.gz → 0.0.2.dev2__tar.gz
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.
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/PKG-INFO +1 -1
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/main/protoprimer/primer_kernel.py +108 -75
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/protoprimer.egg-info/PKG-INFO +1 -1
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/main/protoprimer/__init__.py +0 -0
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/protoprimer.egg-info/SOURCES.txt +0 -0
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/protoprimer.egg-info/dependency_links.txt +0 -0
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/protoprimer.egg-info/requires.txt +0 -0
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/protoprimer.egg-info/top_level.txt +0 -0
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/pyproject.toml +0 -0
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/setup.cfg +0 -0
- {protoprimer-0.0.2.dev1 → protoprimer-0.0.2.dev2}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: protoprimer
|
|
3
|
-
Version: 0.0.2.
|
|
3
|
+
Version: 0.0.2.dev2
|
|
4
4
|
Summary: universal multi-stage `python` environment initializer & bootstrapper (primer) via a stand-alone automatic (proto) script
|
|
5
5
|
Author: uvsmtid
|
|
6
6
|
Author-email: uvsmtid@gmail.com
|
|
@@ -35,7 +35,7 @@ import venv
|
|
|
35
35
|
|
|
36
36
|
# Implements this (using the single script directly without a separate `_version.py` file):
|
|
37
37
|
# https://stackoverflow.com/a/7071358/441652
|
|
38
|
-
__version__ = "0.0.2.
|
|
38
|
+
__version__ = "0.0.2.dev2"
|
|
39
39
|
|
|
40
40
|
from typing import (
|
|
41
41
|
Any,
|
|
@@ -95,54 +95,50 @@ def init_arg_parser():
|
|
|
95
95
|
)
|
|
96
96
|
|
|
97
97
|
arg_parser.add_argument(
|
|
98
|
-
|
|
99
|
-
"--context_phase",
|
|
98
|
+
ArgConst.arg_context_phase,
|
|
100
99
|
type=str,
|
|
101
100
|
choices=[context_phase.name for context_phase in PrimerPhase],
|
|
102
|
-
default=PrimerPhase.
|
|
101
|
+
default=PrimerPhase.phase_proto.name,
|
|
103
102
|
help=f"Select `{PrimerPhase.__name__}`.",
|
|
104
103
|
)
|
|
105
104
|
arg_parser.add_argument(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"--silent",
|
|
105
|
+
ArgConst.arg_s,
|
|
106
|
+
ArgConst.arg_silent,
|
|
109
107
|
action="store_true",
|
|
110
|
-
dest=
|
|
108
|
+
dest=ArgConst.dest_silent,
|
|
111
109
|
# In the case of exceptions, stack traces are still printed:
|
|
112
|
-
help="Do not log
|
|
110
|
+
help="Do not log (set only non-zero exit code on error).",
|
|
113
111
|
)
|
|
114
112
|
arg_parser.add_argument(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"--quiet",
|
|
113
|
+
ArgConst.arg_q,
|
|
114
|
+
ArgConst.arg_quiet,
|
|
118
115
|
action="store_true",
|
|
119
|
-
dest=
|
|
116
|
+
dest=ArgConst.dest_quiet,
|
|
120
117
|
help="Log errors messages only.",
|
|
121
118
|
)
|
|
122
119
|
arg_parser.add_argument(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"--verbose",
|
|
120
|
+
ArgConst.arg_v,
|
|
121
|
+
ArgConst.arg_verbose,
|
|
126
122
|
action="count",
|
|
127
|
-
dest=
|
|
123
|
+
dest=ArgConst.dest_verbose,
|
|
128
124
|
default=0,
|
|
129
|
-
help="
|
|
125
|
+
help="Increase log verbosity level.",
|
|
130
126
|
)
|
|
131
127
|
arg_parser.add_argument(
|
|
132
|
-
|
|
133
|
-
"--run_mode",
|
|
128
|
+
ArgConst.arg_run_mode,
|
|
134
129
|
type=str,
|
|
135
130
|
choices=[run_mode.name for run_mode in RunMode],
|
|
136
131
|
default=RunMode.bootstrap_env.name,
|
|
137
|
-
help="Select
|
|
132
|
+
help=f"Select {RunMode.__name__}.",
|
|
138
133
|
)
|
|
139
134
|
arg_parser.add_argument(
|
|
140
|
-
|
|
141
|
-
"--state_name",
|
|
135
|
+
ArgConst.arg_state_name,
|
|
142
136
|
type=str,
|
|
137
|
+
# TODO: Provide choices?
|
|
138
|
+
# TODO: Provide default?
|
|
143
139
|
default=None,
|
|
144
140
|
# TODO: Compute universal sink:
|
|
145
|
-
help="Select
|
|
141
|
+
help=f"Select target {EnvState.__name__}.",
|
|
146
142
|
)
|
|
147
143
|
# TODO: use it with special `--init_repo` flag (otherwise, do not allow):
|
|
148
144
|
arg_parser.add_argument(
|
|
@@ -156,7 +152,7 @@ def init_arg_parser():
|
|
|
156
152
|
type=str,
|
|
157
153
|
choices=[py_exec.name for py_exec in PythonExecutable],
|
|
158
154
|
default=PythonExecutable.py_exec_unknown.name,
|
|
159
|
-
help="Used internally:
|
|
155
|
+
help=f"Used internally: override {PythonExecutable.__name__}.",
|
|
160
156
|
)
|
|
161
157
|
# TODO: use it with special `--init_repo` flag (otherwise, do not allow):
|
|
162
158
|
arg_parser.add_argument(
|
|
@@ -303,9 +299,9 @@ class PrimerPhase(enum.Enum):
|
|
|
303
299
|
See: FS_14_52_73_23.primer_phase.md
|
|
304
300
|
"""
|
|
305
301
|
|
|
306
|
-
|
|
302
|
+
phase_proto = enum.auto()
|
|
307
303
|
|
|
308
|
-
|
|
304
|
+
phase_venv = enum.auto()
|
|
309
305
|
|
|
310
306
|
|
|
311
307
|
class RunMode(enum.Enum):
|
|
@@ -1258,22 +1254,6 @@ class Bootstrapper_state_py_exec_selected(
|
|
|
1258
1254
|
f"to re-create it automatically. "
|
|
1259
1255
|
)
|
|
1260
1256
|
|
|
1261
|
-
def switch_to_required_python():
|
|
1262
|
-
assert state_py_exec_specified == PythonExecutable.py_exec_unknown
|
|
1263
|
-
self.env_ctx.py_exec = PythonExecutable.py_exec_arbitrary
|
|
1264
|
-
logger.info(
|
|
1265
|
-
f"switching from current `python` interpreter [{path_to_curr_python}] to required one [{state_env_path_to_python}]"
|
|
1266
|
-
)
|
|
1267
|
-
os.execv(
|
|
1268
|
-
state_env_path_to_python,
|
|
1269
|
-
[
|
|
1270
|
-
state_env_path_to_python,
|
|
1271
|
-
*sys.argv,
|
|
1272
|
-
ArgConst.arg_py_exec,
|
|
1273
|
-
PythonExecutable.py_exec_required.name,
|
|
1274
|
-
],
|
|
1275
|
-
)
|
|
1276
|
-
|
|
1277
1257
|
venv_path_to_python = os.path.join(
|
|
1278
1258
|
state_env_path_to_venv,
|
|
1279
1259
|
ConfConstGeneral.file_rel_path_venv_python,
|
|
@@ -1281,8 +1261,15 @@ class Bootstrapper_state_py_exec_selected(
|
|
|
1281
1261
|
path_to_curr_python = get_path_to_curr_python()
|
|
1282
1262
|
if is_sub_path(path_to_curr_python, state_env_path_to_venv):
|
|
1283
1263
|
if path_to_curr_python != venv_path_to_python:
|
|
1264
|
+
assert state_py_exec_specified == PythonExecutable.py_exec_unknown
|
|
1265
|
+
self.env_ctx.py_exec = PythonExecutable.py_exec_arbitrary
|
|
1284
1266
|
# Ensure `python` is from the correct `venv` path
|
|
1285
|
-
|
|
1267
|
+
self.env_ctx.switch_python(
|
|
1268
|
+
curr_py_exec=state_py_exec_specified,
|
|
1269
|
+
curr_python_path=path_to_curr_python,
|
|
1270
|
+
next_py_exec=PythonExecutable.py_exec_required,
|
|
1271
|
+
next_python_path=state_env_path_to_python,
|
|
1272
|
+
)
|
|
1286
1273
|
else:
|
|
1287
1274
|
# If already under `venv` with the expected path, nothing to do.
|
|
1288
1275
|
assert (
|
|
@@ -1296,7 +1283,14 @@ class Bootstrapper_state_py_exec_selected(
|
|
|
1296
1283
|
self.env_ctx.py_exec = state_py_exec_specified
|
|
1297
1284
|
else:
|
|
1298
1285
|
if path_to_curr_python != state_env_path_to_python:
|
|
1299
|
-
|
|
1286
|
+
assert state_py_exec_specified == PythonExecutable.py_exec_unknown
|
|
1287
|
+
self.env_ctx.py_exec = PythonExecutable.py_exec_arbitrary
|
|
1288
|
+
self.env_ctx.switch_python(
|
|
1289
|
+
curr_py_exec=state_py_exec_specified,
|
|
1290
|
+
curr_python_path=path_to_curr_python,
|
|
1291
|
+
next_py_exec=PythonExecutable.py_exec_required,
|
|
1292
|
+
next_python_path=state_env_path_to_python,
|
|
1293
|
+
)
|
|
1300
1294
|
else:
|
|
1301
1295
|
assert (
|
|
1302
1296
|
state_py_exec_specified == PythonExecutable.py_exec_unknown
|
|
@@ -1311,17 +1305,11 @@ class Bootstrapper_state_py_exec_selected(
|
|
|
1311
1305
|
)
|
|
1312
1306
|
else:
|
|
1313
1307
|
logger.info(f"reusing existing `venv` [{state_env_path_to_venv}]")
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
venv_path_to_python,
|
|
1319
|
-
[
|
|
1320
|
-
venv_path_to_python,
|
|
1321
|
-
*sys.argv,
|
|
1322
|
-
ArgConst.arg_py_exec,
|
|
1323
|
-
PythonExecutable.py_exec_venv.name,
|
|
1324
|
-
],
|
|
1308
|
+
self.env_ctx.switch_python(
|
|
1309
|
+
curr_py_exec=state_py_exec_specified,
|
|
1310
|
+
curr_python_path=state_env_path_to_python,
|
|
1311
|
+
next_py_exec=PythonExecutable.py_exec_venv,
|
|
1312
|
+
next_python_path=venv_path_to_python,
|
|
1325
1313
|
)
|
|
1326
1314
|
|
|
1327
1315
|
return self.env_ctx.py_exec
|
|
@@ -1435,17 +1423,15 @@ class Bootstrapper_state_py_exec_updated_protoprimer_package_reached(
|
|
|
1435
1423
|
< PythonExecutable.py_exec_updated_protoprimer_package.value
|
|
1436
1424
|
):
|
|
1437
1425
|
self.env_ctx.py_exec = PythonExecutable.py_exec_updated_protoprimer_package
|
|
1438
|
-
|
|
1426
|
+
# TODO: maybe add this reason to `switch_python` as an arg?
|
|
1427
|
+
logger.debug(
|
|
1439
1428
|
f"restarting current `python` interpreter [{venv_path_to_python}] to make [{EnvState.state_protoprimer_package_installed.name}] effective"
|
|
1440
1429
|
)
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
ArgConst.arg_py_exec,
|
|
1447
|
-
PythonExecutable.py_exec_updated_protoprimer_package.name,
|
|
1448
|
-
],
|
|
1430
|
+
self.env_ctx.switch_python(
|
|
1431
|
+
curr_py_exec=state_py_exec_specified,
|
|
1432
|
+
curr_python_path=venv_path_to_python,
|
|
1433
|
+
next_py_exec=PythonExecutable.py_exec_updated_protoprimer_package,
|
|
1434
|
+
next_python_path=venv_path_to_python,
|
|
1449
1435
|
)
|
|
1450
1436
|
else:
|
|
1451
1437
|
# Successfully reached end goal:
|
|
@@ -1569,17 +1555,15 @@ class Bootstrapper_state_py_exec_updated_proto_kernel_code(
|
|
|
1569
1555
|
< PythonExecutable.py_exec_updated_proto_kernel_code.value
|
|
1570
1556
|
):
|
|
1571
1557
|
self.env_ctx.py_exec = PythonExecutable.py_exec_updated_proto_kernel_code
|
|
1572
|
-
|
|
1558
|
+
# TODO: maybe add this reason to `switch_python` as an arg?
|
|
1559
|
+
logger.debug(
|
|
1573
1560
|
f"restarting current `python` interpreter [{venv_path_to_python}] to make [{EnvState.state_proto_kernel_updated.name}] effective"
|
|
1574
1561
|
)
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
ArgConst.arg_py_exec,
|
|
1581
|
-
PythonExecutable.py_exec_updated_proto_kernel_code.name,
|
|
1582
|
-
],
|
|
1562
|
+
self.env_ctx.switch_python(
|
|
1563
|
+
curr_py_exec=state_py_exec_specified,
|
|
1564
|
+
curr_python_path=venv_path_to_python,
|
|
1565
|
+
next_py_exec=PythonExecutable.py_exec_updated_proto_kernel_code,
|
|
1566
|
+
next_python_path=venv_path_to_python,
|
|
1583
1567
|
)
|
|
1584
1568
|
else:
|
|
1585
1569
|
# Successfully reached end goal:
|
|
@@ -1763,16 +1747,45 @@ class TargetState:
|
|
|
1763
1747
|
|
|
1764
1748
|
class ArgConst:
|
|
1765
1749
|
|
|
1766
|
-
# TODO: decide on convention for pure `arg_name` and `--arg_name`:
|
|
1767
1750
|
name_conf_env_path = "conf_env_path"
|
|
1768
1751
|
name_recursion_flag = "recursion_flag"
|
|
1769
1752
|
name_client_dir_path = "client_dir_path"
|
|
1770
1753
|
name_py_exec = "py_exec"
|
|
1754
|
+
name_context_phase = "context_phase"
|
|
1755
|
+
name_run_mode = "run_mode"
|
|
1756
|
+
name_state_name = "state_name"
|
|
1757
|
+
|
|
1758
|
+
name_s = "s"
|
|
1759
|
+
name_silent = "silent"
|
|
1760
|
+
|
|
1761
|
+
name_q = "q"
|
|
1762
|
+
name_quiet = "quiet"
|
|
1763
|
+
|
|
1764
|
+
name_v = "v"
|
|
1765
|
+
name_verbose = "verbose"
|
|
1766
|
+
|
|
1767
|
+
prefix_log_level = "log_level"
|
|
1771
1768
|
|
|
1772
1769
|
arg_conf_env_path = f"--{name_conf_env_path}"
|
|
1773
1770
|
arg_recursion_flag = f"--{name_recursion_flag}"
|
|
1774
1771
|
arg_client_dir_path = f"--{name_client_dir_path}"
|
|
1775
1772
|
arg_py_exec = f"--{name_py_exec}"
|
|
1773
|
+
arg_context_phase = f"--{name_context_phase}"
|
|
1774
|
+
arg_run_mode = f"--{name_run_mode}"
|
|
1775
|
+
arg_state_name = f"--{name_state_name}"
|
|
1776
|
+
|
|
1777
|
+
arg_s = f"-{name_s}"
|
|
1778
|
+
arg_silent = f"--{name_silent}"
|
|
1779
|
+
value_silent = f"--{name_silent}"
|
|
1780
|
+
dest_silent = f"log_level_{name_silent}"
|
|
1781
|
+
|
|
1782
|
+
arg_q = f"-{name_q}"
|
|
1783
|
+
arg_quiet = f"--{name_quiet}"
|
|
1784
|
+
dest_quiet = f"log_level_{name_quiet}"
|
|
1785
|
+
|
|
1786
|
+
arg_v = f"-{name_v}"
|
|
1787
|
+
arg_verbose = f"--{name_verbose}"
|
|
1788
|
+
dest_verbose = f"log_level_{name_verbose}"
|
|
1776
1789
|
|
|
1777
1790
|
|
|
1778
1791
|
class ConfConstGeneral:
|
|
@@ -2099,6 +2112,26 @@ class EnvContext:
|
|
|
2099
2112
|
# `generate_files`
|
|
2100
2113
|
# TODO: TODO_11_66_62_70: python_bootstrap:
|
|
2101
2114
|
|
|
2115
|
+
def switch_python(
|
|
2116
|
+
self,
|
|
2117
|
+
curr_py_exec: PythonExecutable,
|
|
2118
|
+
curr_python_path: str,
|
|
2119
|
+
next_py_exec: PythonExecutable,
|
|
2120
|
+
next_python_path: str,
|
|
2121
|
+
):
|
|
2122
|
+
logger.info(
|
|
2123
|
+
f"switching from current `python` interpreter [{curr_python_path}][{curr_py_exec.name}] to [{next_python_path}][{next_py_exec.name}]"
|
|
2124
|
+
)
|
|
2125
|
+
os.execv(
|
|
2126
|
+
next_python_path,
|
|
2127
|
+
[
|
|
2128
|
+
next_python_path,
|
|
2129
|
+
*sys.argv,
|
|
2130
|
+
ArgConst.arg_py_exec,
|
|
2131
|
+
next_py_exec.name,
|
|
2132
|
+
],
|
|
2133
|
+
)
|
|
2134
|
+
|
|
2102
2135
|
|
|
2103
2136
|
class CustomFormatter(logging.Formatter):
|
|
2104
2137
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: protoprimer
|
|
3
|
-
Version: 0.0.2.
|
|
3
|
+
Version: 0.0.2.dev2
|
|
4
4
|
Summary: universal multi-stage `python` environment initializer & bootstrapper (primer) via a stand-alone automatic (proto) script
|
|
5
5
|
Author: uvsmtid
|
|
6
6
|
Author-email: uvsmtid@gmail.com
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|