omdev 0.0.0.dev25__py3-none-any.whl → 0.0.0.dev27__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/amalg/amalg.py +60 -23
- omdev/datacache/__init__.py +19 -0
- omdev/datacache/actions.py +36 -0
- omdev/datacache/cache.py +164 -0
- omdev/datacache/consts.py +1 -0
- omdev/datacache/defaults.py +18 -0
- omdev/datacache/manifests.py +40 -0
- omdev/datacache/specs.py +93 -0
- omdev/git.py +100 -0
- omdev/manifests.py +31 -9
- omdev/pyproject/pkg.py +102 -11
- omdev/revisions.py +3 -26
- omdev/scripts/interp.py +48 -37
- omdev/scripts/pyproject.py +248 -80
- omdev/tools/dockertools.py +102 -0
- {omdev-0.0.0.dev25.dist-info → omdev-0.0.0.dev27.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev25.dist-info → omdev-0.0.0.dev27.dist-info}/RECORD +21 -13
- {omdev-0.0.0.dev25.dist-info → omdev-0.0.0.dev27.dist-info}/WHEEL +1 -1
- /omdev/{_manifests.json → .manifests.json} +0 -0
- {omdev-0.0.0.dev25.dist-info → omdev-0.0.0.dev27.dist-info}/LICENSE +0 -0
- {omdev-0.0.0.dev25.dist-info → omdev-0.0.0.dev27.dist-info}/top_level.txt +0 -0
omdev/scripts/pyproject.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# @omlish-lite
|
|
4
4
|
# @omlish-script
|
|
5
5
|
# @omdev-amalg-output ../pyproject/cli.py
|
|
6
|
-
# ruff: noqa: UP006 UP007
|
|
6
|
+
# ruff: noqa: N802 TCH003 UP006 UP007 UP036
|
|
7
7
|
"""
|
|
8
8
|
TODO:
|
|
9
9
|
- check / tests, src dir sets
|
|
@@ -66,6 +66,17 @@ import weakref # noqa
|
|
|
66
66
|
import zipfile
|
|
67
67
|
|
|
68
68
|
|
|
69
|
+
########################################
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if sys.version_info < (3, 8):
|
|
73
|
+
raise OSError(
|
|
74
|
+
f'Requires python (3, 8), got {sys.version_info} from {sys.executable}') # noqa
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
########################################
|
|
78
|
+
|
|
79
|
+
|
|
69
80
|
# ../../toml/parser.py
|
|
70
81
|
TomlParseFloat = ta.Callable[[str], ta.Any]
|
|
71
82
|
TomlKey = ta.Tuple[str, ...]
|
|
@@ -101,7 +112,6 @@ class CextMagic:
|
|
|
101
112
|
|
|
102
113
|
########################################
|
|
103
114
|
# ../../findmagic.py
|
|
104
|
-
# @omlish-script
|
|
105
115
|
|
|
106
116
|
|
|
107
117
|
def compile_magic_pat(m: str) -> re.Pattern:
|
|
@@ -160,6 +170,105 @@ def find_magic(
|
|
|
160
170
|
yield out
|
|
161
171
|
|
|
162
172
|
|
|
173
|
+
########################################
|
|
174
|
+
# ../../git.py
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def git_clone_subtree(
|
|
178
|
+
*,
|
|
179
|
+
base_dir: str,
|
|
180
|
+
repo_url: str,
|
|
181
|
+
repo_dir: str,
|
|
182
|
+
branch: ta.Optional[str] = None,
|
|
183
|
+
rev: ta.Optional[str] = None,
|
|
184
|
+
repo_subtrees: ta.Sequence[str],
|
|
185
|
+
) -> None:
|
|
186
|
+
if not bool(branch) ^ bool(rev):
|
|
187
|
+
raise ValueError('must set branch or rev')
|
|
188
|
+
|
|
189
|
+
if isinstance(repo_subtrees, str):
|
|
190
|
+
raise TypeError(repo_subtrees)
|
|
191
|
+
|
|
192
|
+
git_opts = [
|
|
193
|
+
'-c', 'advice.detachedHead=false',
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
subprocess.check_call(
|
|
197
|
+
[
|
|
198
|
+
'git',
|
|
199
|
+
*git_opts,
|
|
200
|
+
'clone',
|
|
201
|
+
'-n',
|
|
202
|
+
'--depth=1',
|
|
203
|
+
'--filter=tree:0',
|
|
204
|
+
*(['-b', branch] if branch else []),
|
|
205
|
+
'--single-branch',
|
|
206
|
+
repo_url,
|
|
207
|
+
repo_dir,
|
|
208
|
+
],
|
|
209
|
+
cwd=base_dir,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
rd = os.path.join(base_dir, repo_dir)
|
|
213
|
+
subprocess.check_call(
|
|
214
|
+
[
|
|
215
|
+
'git',
|
|
216
|
+
*git_opts,
|
|
217
|
+
'sparse-checkout',
|
|
218
|
+
'set',
|
|
219
|
+
'--no-cone',
|
|
220
|
+
*repo_subtrees,
|
|
221
|
+
],
|
|
222
|
+
cwd=rd,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
subprocess.check_call(
|
|
226
|
+
[
|
|
227
|
+
'git',
|
|
228
|
+
*git_opts,
|
|
229
|
+
'checkout',
|
|
230
|
+
*([rev] if rev else []),
|
|
231
|
+
],
|
|
232
|
+
cwd=rd,
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def get_git_revision(
|
|
237
|
+
*,
|
|
238
|
+
cwd: ta.Optional[str] = None,
|
|
239
|
+
) -> ta.Optional[str]:
|
|
240
|
+
subprocess.check_output(['git', '--version'])
|
|
241
|
+
|
|
242
|
+
if cwd is None:
|
|
243
|
+
cwd = os.getcwd()
|
|
244
|
+
|
|
245
|
+
if subprocess.run([ # noqa
|
|
246
|
+
'git',
|
|
247
|
+
'rev-parse',
|
|
248
|
+
'--is-inside-work-tree',
|
|
249
|
+
], stderr=subprocess.PIPE).returncode:
|
|
250
|
+
return None
|
|
251
|
+
|
|
252
|
+
has_untracked = bool(subprocess.check_output([
|
|
253
|
+
'git',
|
|
254
|
+
'ls-files',
|
|
255
|
+
'.',
|
|
256
|
+
'--exclude-standard',
|
|
257
|
+
'--others',
|
|
258
|
+
], cwd=cwd).decode().strip())
|
|
259
|
+
|
|
260
|
+
dirty_rev = subprocess.check_output([
|
|
261
|
+
'git',
|
|
262
|
+
'describe',
|
|
263
|
+
'--match=NeVeRmAtCh',
|
|
264
|
+
'--always',
|
|
265
|
+
'--abbrev=40',
|
|
266
|
+
'--dirty',
|
|
267
|
+
], cwd=cwd).decode().strip()
|
|
268
|
+
|
|
269
|
+
return dirty_rev + ('-untracked' if has_untracked else '')
|
|
270
|
+
|
|
271
|
+
|
|
163
272
|
########################################
|
|
164
273
|
# ../../toml/parser.py
|
|
165
274
|
# SPDX-License-Identifier: MIT
|
|
@@ -203,7 +312,6 @@ def find_magic(
|
|
|
203
312
|
# License Agreement.
|
|
204
313
|
#
|
|
205
314
|
# https://github.com/python/cpython/blob/f5009b69e0cd94b990270e04e65b9d4d2b365844/Lib/tomllib/_parser.py
|
|
206
|
-
# ruff: noqa: UP006 UP007
|
|
207
315
|
|
|
208
316
|
|
|
209
317
|
##
|
|
@@ -1109,7 +1217,6 @@ class TomlWriter:
|
|
|
1109
1217
|
# Apache License, Version 2.0, and the BSD License. See the LICENSE file in the root of this repository for complete
|
|
1110
1218
|
# details.
|
|
1111
1219
|
# https://github.com/pypa/packaging/blob/2c885fe91a54559e2382902dce28428ad2887be5/src/packaging/version.py
|
|
1112
|
-
# ruff: noqa: UP006 UP007
|
|
1113
1220
|
|
|
1114
1221
|
|
|
1115
1222
|
##
|
|
@@ -1495,7 +1602,6 @@ def canonicalize_version(
|
|
|
1495
1602
|
|
|
1496
1603
|
########################################
|
|
1497
1604
|
# ../../wheelfile.py
|
|
1498
|
-
# ruff: noqa: UP006 UP007
|
|
1499
1605
|
# https://github.com/pypa/wheel/blob/7bb46d7727e6e89fe56b3c78297b3af2672bbbe2/src/wheel/wheelfile.py
|
|
1500
1606
|
# MIT License
|
|
1501
1607
|
#
|
|
@@ -1755,7 +1861,6 @@ class cached_nullary: # noqa
|
|
|
1755
1861
|
|
|
1756
1862
|
########################################
|
|
1757
1863
|
# ../../../omlish/lite/check.py
|
|
1758
|
-
# ruff: noqa: UP006 UP007
|
|
1759
1864
|
|
|
1760
1865
|
|
|
1761
1866
|
def check_isinstance(v: T, spec: ta.Union[ta.Type[T], tuple]) -> T:
|
|
@@ -1782,6 +1887,12 @@ def check_not(v: ta.Any) -> None:
|
|
|
1782
1887
|
return v
|
|
1783
1888
|
|
|
1784
1889
|
|
|
1890
|
+
def check_non_empty_str(v: ta.Optional[str]) -> str:
|
|
1891
|
+
if not v:
|
|
1892
|
+
raise ValueError
|
|
1893
|
+
return v
|
|
1894
|
+
|
|
1895
|
+
|
|
1785
1896
|
########################################
|
|
1786
1897
|
# ../../../omlish/lite/json.py
|
|
1787
1898
|
|
|
@@ -1815,7 +1926,6 @@ json_dumps_compact: ta.Callable[..., str] = functools.partial(json.dumps, **JSON
|
|
|
1815
1926
|
|
|
1816
1927
|
########################################
|
|
1817
1928
|
# ../../../omlish/lite/reflect.py
|
|
1818
|
-
# ruff: noqa: UP006
|
|
1819
1929
|
|
|
1820
1930
|
|
|
1821
1931
|
_GENERIC_ALIAS_TYPES = (
|
|
@@ -1898,7 +2008,6 @@ def is_sunder(name: str) -> bool:
|
|
|
1898
2008
|
TODO:
|
|
1899
2009
|
- embed pip._internal.req.parse_requirements, add additional env stuff? breaks compat with raw pip
|
|
1900
2010
|
"""
|
|
1901
|
-
# ruff: noqa: UP007
|
|
1902
2011
|
|
|
1903
2012
|
|
|
1904
2013
|
class RequirementsRewriter:
|
|
@@ -1993,7 +2102,6 @@ class RequirementsRewriter:
|
|
|
1993
2102
|
# Apache License, Version 2.0, and the BSD License. See the LICENSE file in the root of this repository for complete
|
|
1994
2103
|
# details.
|
|
1995
2104
|
# https://github.com/pypa/packaging/blob/2c885fe91a54559e2382902dce28428ad2887be5/src/packaging/specifiers.py
|
|
1996
|
-
# ruff: noqa: UP006 UP007
|
|
1997
2105
|
|
|
1998
2106
|
|
|
1999
2107
|
##
|
|
@@ -2499,7 +2607,6 @@ TODO:
|
|
|
2499
2607
|
- translate json keys
|
|
2500
2608
|
- debug
|
|
2501
2609
|
"""
|
|
2502
|
-
# ruff: noqa: UP006 UP007 N802
|
|
2503
2610
|
|
|
2504
2611
|
|
|
2505
2612
|
log = logging.getLogger(__name__)
|
|
@@ -2698,46 +2805,51 @@ def configure_standard_logging(
|
|
|
2698
2805
|
*,
|
|
2699
2806
|
json: bool = False,
|
|
2700
2807
|
target: ta.Optional[logging.Logger] = None,
|
|
2701
|
-
|
|
2808
|
+
force: bool = False,
|
|
2702
2809
|
) -> ta.Optional[StandardLogHandler]:
|
|
2703
|
-
|
|
2704
|
-
|
|
2810
|
+
logging._acquireLock() # type: ignore # noqa
|
|
2811
|
+
try:
|
|
2812
|
+
if target is None:
|
|
2813
|
+
target = logging.root
|
|
2705
2814
|
|
|
2706
|
-
|
|
2815
|
+
#
|
|
2707
2816
|
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2817
|
+
if not force:
|
|
2818
|
+
if any(isinstance(h, StandardLogHandler) for h in list(target.handlers)):
|
|
2819
|
+
return None
|
|
2711
2820
|
|
|
2712
|
-
|
|
2821
|
+
#
|
|
2713
2822
|
|
|
2714
|
-
|
|
2823
|
+
handler = logging.StreamHandler()
|
|
2715
2824
|
|
|
2716
|
-
|
|
2825
|
+
#
|
|
2717
2826
|
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2827
|
+
formatter: logging.Formatter
|
|
2828
|
+
if json:
|
|
2829
|
+
formatter = JsonLogFormatter()
|
|
2830
|
+
else:
|
|
2831
|
+
formatter = StandardLogFormatter(StandardLogFormatter.build_log_format(STANDARD_LOG_FORMAT_PARTS))
|
|
2832
|
+
handler.setFormatter(formatter)
|
|
2724
2833
|
|
|
2725
|
-
|
|
2834
|
+
#
|
|
2726
2835
|
|
|
2727
|
-
|
|
2836
|
+
handler.addFilter(TidLogFilter())
|
|
2728
2837
|
|
|
2729
|
-
|
|
2838
|
+
#
|
|
2730
2839
|
|
|
2731
|
-
|
|
2840
|
+
target.addHandler(handler)
|
|
2732
2841
|
|
|
2733
|
-
|
|
2842
|
+
#
|
|
2734
2843
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2844
|
+
if level is not None:
|
|
2845
|
+
target.setLevel(level)
|
|
2737
2846
|
|
|
2738
|
-
|
|
2847
|
+
#
|
|
2848
|
+
|
|
2849
|
+
return StandardLogHandler(handler)
|
|
2739
2850
|
|
|
2740
|
-
|
|
2851
|
+
finally:
|
|
2852
|
+
logging._releaseLock() # type: ignore # noqa
|
|
2741
2853
|
|
|
2742
2854
|
|
|
2743
2855
|
########################################
|
|
@@ -2747,7 +2859,6 @@ TODO:
|
|
|
2747
2859
|
- pickle stdlib objs? have to pin to 3.8 pickle protocol, will be cross-version
|
|
2748
2860
|
- nonstrict toggle
|
|
2749
2861
|
"""
|
|
2750
|
-
# ruff: noqa: UP006 UP007
|
|
2751
2862
|
|
|
2752
2863
|
|
|
2753
2864
|
##
|
|
@@ -3063,7 +3174,6 @@ def check_runtime_version() -> None:
|
|
|
3063
3174
|
|
|
3064
3175
|
########################################
|
|
3065
3176
|
# ../../interp/types.py
|
|
3066
|
-
# ruff: noqa: UP006
|
|
3067
3177
|
|
|
3068
3178
|
|
|
3069
3179
|
# See https://peps.python.org/pep-3149/
|
|
@@ -3155,7 +3265,6 @@ class Interp:
|
|
|
3155
3265
|
|
|
3156
3266
|
########################################
|
|
3157
3267
|
# ../configs.py
|
|
3158
|
-
# ruff: noqa: UP006 UP007
|
|
3159
3268
|
|
|
3160
3269
|
|
|
3161
3270
|
@dc.dataclass(frozen=True)
|
|
@@ -3259,31 +3368,6 @@ TODO:
|
|
|
3259
3368
|
- omlish-lite, move to pyproject/
|
|
3260
3369
|
- vendor-lite wheel.wheelfile
|
|
3261
3370
|
"""
|
|
3262
|
-
# ruff: noqa: TCH003 UP006 UP007
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
##
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
def get_git_revision() -> str:
|
|
3269
|
-
has_untracked = bool(subprocess.check_output([
|
|
3270
|
-
'git',
|
|
3271
|
-
'ls-files',
|
|
3272
|
-
'.',
|
|
3273
|
-
'--exclude-standard',
|
|
3274
|
-
'--others',
|
|
3275
|
-
]).decode().strip())
|
|
3276
|
-
|
|
3277
|
-
dirty_rev = subprocess.check_output([
|
|
3278
|
-
'git',
|
|
3279
|
-
'describe',
|
|
3280
|
-
'--match=NeVeRmAtCh',
|
|
3281
|
-
'--always',
|
|
3282
|
-
'--abbrev=40',
|
|
3283
|
-
'--dirty',
|
|
3284
|
-
]).decode().strip()
|
|
3285
|
-
|
|
3286
|
-
return dirty_rev + ('-untracked' if has_untracked else '')
|
|
3287
3371
|
|
|
3288
3372
|
|
|
3289
3373
|
##
|
|
@@ -3303,7 +3387,7 @@ class GitRevisionAdder:
|
|
|
3303
3387
|
def revision(self) -> str:
|
|
3304
3388
|
if self._given_revision is not None:
|
|
3305
3389
|
return self._given_revision
|
|
3306
|
-
return get_git_revision()
|
|
3390
|
+
return check_non_empty_str(get_git_revision())
|
|
3307
3391
|
|
|
3308
3392
|
REVISION_ATTR = '__revision__'
|
|
3309
3393
|
|
|
@@ -3399,7 +3483,6 @@ class GitRevisionAdder:
|
|
|
3399
3483
|
|
|
3400
3484
|
########################################
|
|
3401
3485
|
# ../../../omlish/lite/subprocesses.py
|
|
3402
|
-
# ruff: noqa: UP006 UP007
|
|
3403
3486
|
|
|
3404
3487
|
|
|
3405
3488
|
##
|
|
@@ -3506,7 +3589,6 @@ def subprocess_try_output_str(*args: str, **kwargs: ta.Any) -> ta.Optional[str]:
|
|
|
3506
3589
|
|
|
3507
3590
|
########################################
|
|
3508
3591
|
# ../../interp/inspect.py
|
|
3509
|
-
# ruff: noqa: UP006 UP007
|
|
3510
3592
|
|
|
3511
3593
|
|
|
3512
3594
|
@dc.dataclass(frozen=True)
|
|
@@ -3629,7 +3711,6 @@ https://pip.pypa.io/en/stable/cli/pip_install/#vcs-support
|
|
|
3629
3711
|
vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir
|
|
3630
3712
|
'git+https://github.com/wrmsr/omlish@master#subdirectory=.pip/omlish'
|
|
3631
3713
|
""" # noqa
|
|
3632
|
-
# ruff: noqa: UP006 UP007
|
|
3633
3714
|
|
|
3634
3715
|
|
|
3635
3716
|
#
|
|
@@ -3726,6 +3807,35 @@ class BasePyprojectPackageGenerator(abc.ABC):
|
|
|
3726
3807
|
|
|
3727
3808
|
#
|
|
3728
3809
|
|
|
3810
|
+
class _PkgData(ta.NamedTuple):
|
|
3811
|
+
inc: ta.List[str]
|
|
3812
|
+
exc: ta.List[str]
|
|
3813
|
+
|
|
3814
|
+
@cached_nullary
|
|
3815
|
+
def _collect_pkg_data(self) -> _PkgData:
|
|
3816
|
+
inc: ta.List[str] = []
|
|
3817
|
+
exc: ta.List[str] = []
|
|
3818
|
+
|
|
3819
|
+
for p, ds, fs in os.walk(self._dir_name): # noqa
|
|
3820
|
+
for f in fs:
|
|
3821
|
+
if f != '.pkgdata':
|
|
3822
|
+
continue
|
|
3823
|
+
rp = os.path.relpath(p, self._dir_name)
|
|
3824
|
+
log.info('Found pkgdata %s for pkg %s', rp, self._dir_name)
|
|
3825
|
+
with open(os.path.join(p, f)) as fo:
|
|
3826
|
+
src = fo.read()
|
|
3827
|
+
for l in src.splitlines():
|
|
3828
|
+
if not (l := l.strip()):
|
|
3829
|
+
continue
|
|
3830
|
+
if l.startswith('!'):
|
|
3831
|
+
exc.append(os.path.join(rp, l[1:]))
|
|
3832
|
+
else:
|
|
3833
|
+
inc.append(os.path.join(rp, l))
|
|
3834
|
+
|
|
3835
|
+
return self._PkgData(inc, exc)
|
|
3836
|
+
|
|
3837
|
+
#
|
|
3838
|
+
|
|
3729
3839
|
@abc.abstractmethod
|
|
3730
3840
|
def _write_file_contents(self) -> None:
|
|
3731
3841
|
raise NotImplementedError
|
|
@@ -3749,13 +3859,12 @@ class BasePyprojectPackageGenerator(abc.ABC):
|
|
|
3749
3859
|
build_output_dir: ta.Optional[str] = None,
|
|
3750
3860
|
*,
|
|
3751
3861
|
add_revision: bool = False,
|
|
3862
|
+
test: bool = False,
|
|
3752
3863
|
) -> None:
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
'build',
|
|
3758
|
-
],
|
|
3864
|
+
subprocess_check_call(
|
|
3865
|
+
sys.executable,
|
|
3866
|
+
'-m',
|
|
3867
|
+
'build',
|
|
3759
3868
|
cwd=self._pkg_dir(),
|
|
3760
3869
|
)
|
|
3761
3870
|
|
|
@@ -3764,6 +3873,25 @@ class BasePyprojectPackageGenerator(abc.ABC):
|
|
|
3764
3873
|
if add_revision:
|
|
3765
3874
|
GitRevisionAdder().add_to(dist_dir)
|
|
3766
3875
|
|
|
3876
|
+
if test:
|
|
3877
|
+
for fn in os.listdir(dist_dir):
|
|
3878
|
+
tmp_dir = tempfile.mkdtemp()
|
|
3879
|
+
|
|
3880
|
+
subprocess_check_call(
|
|
3881
|
+
sys.executable,
|
|
3882
|
+
'-m', 'venv',
|
|
3883
|
+
'test-install',
|
|
3884
|
+
cwd=tmp_dir,
|
|
3885
|
+
)
|
|
3886
|
+
|
|
3887
|
+
subprocess_check_call(
|
|
3888
|
+
os.path.join(tmp_dir, 'test-install', 'bin', 'python3'),
|
|
3889
|
+
'-m', 'pip',
|
|
3890
|
+
'install',
|
|
3891
|
+
os.path.abspath(os.path.join(dist_dir, fn)),
|
|
3892
|
+
cwd=tmp_dir,
|
|
3893
|
+
)
|
|
3894
|
+
|
|
3767
3895
|
if build_output_dir is not None:
|
|
3768
3896
|
for fn in os.listdir(dist_dir):
|
|
3769
3897
|
shutil.copyfile(os.path.join(dist_dir, fn), os.path.join(build_output_dir, fn))
|
|
@@ -3837,13 +3965,56 @@ class PyprojectPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
3837
3965
|
|
|
3838
3966
|
#
|
|
3839
3967
|
|
|
3840
|
-
st = specs.setuptools
|
|
3968
|
+
st = dict(specs.setuptools)
|
|
3841
3969
|
pyp_dct['tool.setuptools'] = st
|
|
3842
3970
|
|
|
3843
3971
|
st.pop('cexts', None)
|
|
3844
3972
|
|
|
3845
|
-
|
|
3846
|
-
|
|
3973
|
+
#
|
|
3974
|
+
|
|
3975
|
+
# TODO: default
|
|
3976
|
+
# find_packages = {
|
|
3977
|
+
# 'include': [Project.name, f'{Project.name}.*'],
|
|
3978
|
+
# 'exclude': [*SetuptoolsBase.find_packages['exclude']],
|
|
3979
|
+
# }
|
|
3980
|
+
|
|
3981
|
+
fp = dict(st.pop('find_packages', {}))
|
|
3982
|
+
|
|
3983
|
+
pyp_dct['tool.setuptools.packages.find'] = fp
|
|
3984
|
+
|
|
3985
|
+
#
|
|
3986
|
+
|
|
3987
|
+
# TODO: default
|
|
3988
|
+
# package_data = {
|
|
3989
|
+
# '*': [
|
|
3990
|
+
# '*.c',
|
|
3991
|
+
# '*.cc',
|
|
3992
|
+
# '*.h',
|
|
3993
|
+
# '.manifests.json',
|
|
3994
|
+
# 'LICENSE',
|
|
3995
|
+
# ],
|
|
3996
|
+
# }
|
|
3997
|
+
|
|
3998
|
+
pd = dict(st.pop('package_data', {}))
|
|
3999
|
+
epd = dict(st.pop('exclude_package_data', {}))
|
|
4000
|
+
|
|
4001
|
+
cpd = self._collect_pkg_data()
|
|
4002
|
+
if cpd.inc:
|
|
4003
|
+
pd['*'] = [*pd.get('*', []), *sorted(set(cpd.inc))]
|
|
4004
|
+
if cpd.exc:
|
|
4005
|
+
epd['*'] = [*epd.get('*', []), *sorted(set(cpd.exc))]
|
|
4006
|
+
|
|
4007
|
+
if pd:
|
|
4008
|
+
pyp_dct['tool.setuptools.package-data'] = pd
|
|
4009
|
+
if epd:
|
|
4010
|
+
pyp_dct['tool.setuptools.exclude-package-data'] = epd
|
|
4011
|
+
|
|
4012
|
+
#
|
|
4013
|
+
|
|
4014
|
+
# TODO: default
|
|
4015
|
+
# manifest_in = [
|
|
4016
|
+
# 'global-exclude **/conftest.py',
|
|
4017
|
+
# ]
|
|
3847
4018
|
|
|
3848
4019
|
mani_in = st.pop('manifest_in', None)
|
|
3849
4020
|
|
|
@@ -3923,7 +4094,7 @@ class _PyprojectCextPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
3923
4094
|
|
|
3924
4095
|
#
|
|
3925
4096
|
|
|
3926
|
-
st = specs.setuptools
|
|
4097
|
+
st = dict(specs.setuptools)
|
|
3927
4098
|
pyp_dct['tool.setuptools'] = st
|
|
3928
4099
|
|
|
3929
4100
|
for k in [
|
|
@@ -4051,7 +4222,6 @@ TODO:
|
|
|
4051
4222
|
- optionally install / upgrade pyenv itself
|
|
4052
4223
|
- new vers dont need these custom mac opts, only run on old vers
|
|
4053
4224
|
"""
|
|
4054
|
-
# ruff: noqa: UP006 UP007
|
|
4055
4225
|
|
|
4056
4226
|
|
|
4057
4227
|
##
|
|
@@ -4446,7 +4616,6 @@ TODO:
|
|
|
4446
4616
|
- python, python3, python3.12, ...
|
|
4447
4617
|
- check if path py's are venvs: sys.prefix != sys.base_prefix
|
|
4448
4618
|
"""
|
|
4449
|
-
# ruff: noqa: UP006 UP007
|
|
4450
4619
|
|
|
4451
4620
|
|
|
4452
4621
|
##
|
|
@@ -4555,7 +4724,6 @@ class SystemInterpProvider(InterpProvider):
|
|
|
4555
4724
|
|
|
4556
4725
|
########################################
|
|
4557
4726
|
# ../../interp/resolvers.py
|
|
4558
|
-
# ruff: noqa: UP006 UP007
|
|
4559
4727
|
|
|
4560
4728
|
|
|
4561
4729
|
INTERP_PROVIDER_TYPES_BY_NAME: ta.Mapping[str, ta.Type[InterpProvider]] = {
|
omdev/tools/dockertools.py
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TODO:
|
|
3
|
+
- check for updates
|
|
4
|
+
"""
|
|
1
5
|
import os
|
|
6
|
+
import re
|
|
2
7
|
import shutil
|
|
3
8
|
import subprocess
|
|
9
|
+
import typing as ta
|
|
4
10
|
|
|
5
11
|
from omlish import argparse as ap
|
|
6
12
|
from omlish import check
|
|
7
13
|
from omlish import lang
|
|
8
14
|
from omlish import logs
|
|
15
|
+
from omlish.formats import yaml
|
|
9
16
|
|
|
10
17
|
|
|
11
18
|
@lang.cached_function
|
|
@@ -75,6 +82,101 @@ class Cli(ap.Cli):
|
|
|
75
82
|
'sh', '-c', 'echo 0 > /proc/sys/kernel/yama/ptrace_scope',
|
|
76
83
|
)
|
|
77
84
|
|
|
85
|
+
@ap.command(
|
|
86
|
+
ap.arg('-f', '--file'),
|
|
87
|
+
ap.arg('-w', '--write', action='store_true'),
|
|
88
|
+
ap.arg('-q', '--quiet', action='store_true'),
|
|
89
|
+
ap.arg('base', type=int),
|
|
90
|
+
)
|
|
91
|
+
def reset_compose_ports(self) -> None:
|
|
92
|
+
base_port = int(self.args.base)
|
|
93
|
+
if not base_port:
|
|
94
|
+
raise Exception('Invalid base port')
|
|
95
|
+
|
|
96
|
+
if self.args.file:
|
|
97
|
+
yml_file = self.args.file
|
|
98
|
+
else:
|
|
99
|
+
yml_file = os.path.join('docker', 'compose.yml')
|
|
100
|
+
|
|
101
|
+
with open(yml_file) as f:
|
|
102
|
+
yml_src = f.read()
|
|
103
|
+
|
|
104
|
+
#
|
|
105
|
+
|
|
106
|
+
port_pat = re.compile(r'(?P<l>\d+):(?P<r>\d+)')
|
|
107
|
+
port_line_pat = re.compile(r"( )+- '(?P<l>\d+):(?P<r>\d+)'\s*")
|
|
108
|
+
|
|
109
|
+
class PortEntry(ta.NamedTuple):
|
|
110
|
+
l: int
|
|
111
|
+
s: str
|
|
112
|
+
|
|
113
|
+
dct: dict[str, list[PortEntry]] = {}
|
|
114
|
+
|
|
115
|
+
with lang.disposing(yaml.WrappedLoaders.base(yml_src)) as loader:
|
|
116
|
+
val = check.not_none(loader.get_single_data()) # type: ignore
|
|
117
|
+
root = check.isinstance(val.value, ta.Mapping)
|
|
118
|
+
|
|
119
|
+
services = check.isinstance(
|
|
120
|
+
check.single(
|
|
121
|
+
v.value # type: ignore
|
|
122
|
+
for k, v in root.items()
|
|
123
|
+
if k.value == 'services' # type: ignore
|
|
124
|
+
),
|
|
125
|
+
ta.Mapping,
|
|
126
|
+
)
|
|
127
|
+
for name_w, cfg_w in services.items():
|
|
128
|
+
name = check.isinstance(name_w.value, str) # type: ignore
|
|
129
|
+
cfg = check.isinstance(cfg_w.value, ta.Mapping) # type: ignore
|
|
130
|
+
|
|
131
|
+
ports = check.opt_single(v.value for k, v in cfg.items() if k.value == 'ports') # type: ignore
|
|
132
|
+
if not ports:
|
|
133
|
+
continue
|
|
134
|
+
|
|
135
|
+
lst: list[PortEntry] = []
|
|
136
|
+
for port_w in ports:
|
|
137
|
+
port = check.isinstance(port_w.value, str)
|
|
138
|
+
if not re.fullmatch(port_pat, port):
|
|
139
|
+
raise Exception(f'Bad port: {port}')
|
|
140
|
+
|
|
141
|
+
lst.append(PortEntry(
|
|
142
|
+
l=port_w.node.start_mark.line,
|
|
143
|
+
s=port,
|
|
144
|
+
))
|
|
145
|
+
|
|
146
|
+
dct[name] = lst
|
|
147
|
+
|
|
148
|
+
#
|
|
149
|
+
|
|
150
|
+
src_lines = yml_src.splitlines(keepends=True)
|
|
151
|
+
cur_port = base_port
|
|
152
|
+
|
|
153
|
+
for ps in dct.values():
|
|
154
|
+
for p in ps:
|
|
155
|
+
l = src_lines[p.l]
|
|
156
|
+
if not (m := port_line_pat.fullmatch(l)):
|
|
157
|
+
raise Exception(f'Bad port line: {p} {l!r}')
|
|
158
|
+
|
|
159
|
+
p_l, p_r = map(int, p.s.split(':'))
|
|
160
|
+
l_l, l_r = map(int, [(gd := m.groupdict())['l'], gd['r']])
|
|
161
|
+
if p_l != l_l or p_r != l_r:
|
|
162
|
+
raise Exception(f'Port mismatch: {p}')
|
|
163
|
+
|
|
164
|
+
new_l = l.partition("'")[0] + f"'{cur_port}:{l_r}'\n"
|
|
165
|
+
src_lines[p.l] = new_l
|
|
166
|
+
|
|
167
|
+
cur_port += 1
|
|
168
|
+
|
|
169
|
+
new_src = ''.join(src_lines)
|
|
170
|
+
|
|
171
|
+
#
|
|
172
|
+
|
|
173
|
+
if not self.args.quiet:
|
|
174
|
+
print(new_src)
|
|
175
|
+
|
|
176
|
+
if self.args.write:
|
|
177
|
+
with open(yml_file, 'w') as f:
|
|
178
|
+
f.write(new_src)
|
|
179
|
+
|
|
78
180
|
|
|
79
181
|
if __name__ == '__main__':
|
|
80
182
|
logs.configure_standard_logging('INFO')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: omdev
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev27
|
|
4
4
|
Summary: omdev
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -12,7 +12,7 @@ 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.dev27
|
|
16
16
|
Provides-Extra: all
|
|
17
17
|
Requires-Dist: pycparser ~=2.22 ; extra == 'all'
|
|
18
18
|
Requires-Dist: cffi ~=1.17 ; extra == 'all'
|