omdev 0.0.0.dev464__py3-none-any.whl → 0.0.0.dev465__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/__about__.py +2 -1
- omdev/pyproject/pkg.py +182 -42
- omdev/rs/__init__.py +0 -0
- omdev/scripts/pyproject.py +181 -42
- {omdev-0.0.0.dev464.dist-info → omdev-0.0.0.dev465.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev464.dist-info → omdev-0.0.0.dev465.dist-info}/RECORD +10 -10
- omdev/pyproject/cexts.py +0 -110
- {omdev-0.0.0.dev464.dist-info → omdev-0.0.0.dev465.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev464.dist-info → omdev-0.0.0.dev465.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev464.dist-info → omdev-0.0.0.dev465.dist-info}/licenses/LICENSE +0 -0
- {omdev-0.0.0.dev464.dist-info → omdev-0.0.0.dev465.dist-info}/top_level.txt +0 -0
omdev/__about__.py
CHANGED
omdev/pyproject/pkg.py
CHANGED
|
@@ -28,10 +28,12 @@ vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir
|
|
|
28
28
|
import abc
|
|
29
29
|
import dataclasses as dc
|
|
30
30
|
import importlib
|
|
31
|
+
import inspect
|
|
31
32
|
import os.path
|
|
32
33
|
import shutil
|
|
33
34
|
import sys
|
|
34
35
|
import tempfile
|
|
36
|
+
import textwrap
|
|
35
37
|
import types
|
|
36
38
|
import typing as ta
|
|
37
39
|
|
|
@@ -260,6 +262,7 @@ class BasePyprojectPackageGenerator(Abstract):
|
|
|
260
262
|
)
|
|
261
263
|
|
|
262
264
|
if output_dir is not None:
|
|
265
|
+
log.info(lambda: f'Copying {dist_dir} to {output_dir}')
|
|
263
266
|
for fn in os.listdir(dist_dir):
|
|
264
267
|
shutil.copyfile(os.path.join(dist_dir, fn), os.path.join(output_dir, fn))
|
|
265
268
|
|
|
@@ -315,7 +318,11 @@ class PyprojectPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
315
318
|
st = dict(specs.setuptools)
|
|
316
319
|
pyp_dct['tool.setuptools'] = st
|
|
317
320
|
|
|
318
|
-
|
|
321
|
+
for k in [
|
|
322
|
+
'cext',
|
|
323
|
+
'rs',
|
|
324
|
+
]:
|
|
325
|
+
st.pop(k, None)
|
|
319
326
|
|
|
320
327
|
#
|
|
321
328
|
|
|
@@ -388,13 +395,20 @@ class PyprojectPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
388
395
|
def children(self) -> ta.Sequence[BasePyprojectPackageGenerator]:
|
|
389
396
|
out: ta.List[BasePyprojectPackageGenerator] = []
|
|
390
397
|
|
|
391
|
-
if self.build_specs().setuptools.get('
|
|
398
|
+
if self.build_specs().setuptools.get('cext'):
|
|
392
399
|
out.append(_PyprojectCextPackageGenerator(
|
|
393
400
|
self._dir_name,
|
|
394
401
|
self._pkgs_root,
|
|
395
402
|
pkg_suffix='-cext',
|
|
396
403
|
))
|
|
397
404
|
|
|
405
|
+
if self.build_specs().setuptools.get('rs'):
|
|
406
|
+
out.append(_PyprojectRsPackageGenerator(
|
|
407
|
+
self._dir_name,
|
|
408
|
+
self._pkgs_root,
|
|
409
|
+
pkg_suffix='-rs',
|
|
410
|
+
))
|
|
411
|
+
|
|
398
412
|
if self.build_specs().pyproject.get('cli_scripts'):
|
|
399
413
|
out.append(_PyprojectCliPackageGenerator(
|
|
400
414
|
self._dir_name,
|
|
@@ -405,10 +419,67 @@ class PyprojectPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
405
419
|
return out
|
|
406
420
|
|
|
407
421
|
|
|
408
|
-
|
|
422
|
+
##
|
|
409
423
|
|
|
410
424
|
|
|
411
|
-
class
|
|
425
|
+
class _PyprojectExtensionPackageGenerator(BasePyprojectPackageGenerator, Abstract):
|
|
426
|
+
#
|
|
427
|
+
|
|
428
|
+
def _build_project_dict(self) -> ta.Dict[str, ta.Any]:
|
|
429
|
+
prj = dict(self.build_specs().pyproject)
|
|
430
|
+
|
|
431
|
+
prj['dependencies'] = [f'{prj["name"]} == {prj["version"]}']
|
|
432
|
+
prj['name'] += self._pkg_suffix
|
|
433
|
+
|
|
434
|
+
for k in [
|
|
435
|
+
'optional_dependencies',
|
|
436
|
+
'entry_points',
|
|
437
|
+
'scripts',
|
|
438
|
+
'cli_scripts',
|
|
439
|
+
]:
|
|
440
|
+
prj.pop(k, None)
|
|
441
|
+
|
|
442
|
+
return prj
|
|
443
|
+
|
|
444
|
+
def _build_setuptools_dict(self) -> ta.Dict[str, ta.Any]:
|
|
445
|
+
st = dict(self.build_specs().setuptools)
|
|
446
|
+
|
|
447
|
+
for k in [
|
|
448
|
+
'cext',
|
|
449
|
+
'rs',
|
|
450
|
+
|
|
451
|
+
'find_packages',
|
|
452
|
+
'package_data',
|
|
453
|
+
'manifest_in',
|
|
454
|
+
]:
|
|
455
|
+
st.pop(k, None)
|
|
456
|
+
|
|
457
|
+
return st
|
|
458
|
+
|
|
459
|
+
#
|
|
460
|
+
|
|
461
|
+
@dc.dataclass(frozen=True)
|
|
462
|
+
class FileContents:
|
|
463
|
+
pyproject_dct: ta.Mapping[str, ta.Any]
|
|
464
|
+
setup_py: str
|
|
465
|
+
|
|
466
|
+
@abc.abstractmethod
|
|
467
|
+
def file_contents(self) -> FileContents:
|
|
468
|
+
raise NotImplementedError
|
|
469
|
+
|
|
470
|
+
#
|
|
471
|
+
|
|
472
|
+
def _write_file_contents(self) -> None:
|
|
473
|
+
fc = self.file_contents()
|
|
474
|
+
|
|
475
|
+
with open(os.path.join(self._pkg_dir(), 'pyproject.toml'), 'w') as f:
|
|
476
|
+
TomlWriter(f).write_root(fc.pyproject_dct)
|
|
477
|
+
|
|
478
|
+
with open(os.path.join(self._pkg_dir(), 'setup.py'), 'w') as f:
|
|
479
|
+
f.write(fc.setup_py)
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
class _PyprojectCextPackageGenerator(_PyprojectExtensionPackageGenerator):
|
|
412
483
|
@cached_nullary
|
|
413
484
|
def find_cext_srcs(self) -> ta.Sequence[str]:
|
|
414
485
|
return sorted(find_magic_files(
|
|
@@ -419,14 +490,10 @@ class _PyprojectCextPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
419
490
|
|
|
420
491
|
#
|
|
421
492
|
|
|
422
|
-
@dc.dataclass(frozen=True)
|
|
423
|
-
class FileContents:
|
|
424
|
-
pyproject_dct: ta.Mapping[str, ta.Any]
|
|
425
|
-
setup_py: str
|
|
426
|
-
|
|
427
493
|
@cached_nullary
|
|
428
|
-
def file_contents(self) -> FileContents:
|
|
429
|
-
|
|
494
|
+
def file_contents(self) -> _PyprojectExtensionPackageGenerator.FileContents:
|
|
495
|
+
prj = self._build_project_dict()
|
|
496
|
+
st = self._build_setuptools_dict()
|
|
430
497
|
|
|
431
498
|
#
|
|
432
499
|
|
|
@@ -437,33 +504,9 @@ class _PyprojectCextPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
437
504
|
'build-backend': 'setuptools.build_meta',
|
|
438
505
|
}
|
|
439
506
|
|
|
440
|
-
prj = specs.pyproject
|
|
441
|
-
prj['dependencies'] = [f'{prj["name"]} == {prj["version"]}']
|
|
442
|
-
prj['name'] += self._pkg_suffix
|
|
443
|
-
for k in [
|
|
444
|
-
'optional_dependencies',
|
|
445
|
-
'entry_points',
|
|
446
|
-
'scripts',
|
|
447
|
-
'cli_scripts',
|
|
448
|
-
]:
|
|
449
|
-
prj.pop(k, None)
|
|
450
|
-
|
|
451
507
|
pyp_dct['project'] = prj
|
|
452
|
-
|
|
453
|
-
#
|
|
454
|
-
|
|
455
|
-
st = dict(specs.setuptools)
|
|
456
508
|
pyp_dct['tool.setuptools'] = st
|
|
457
509
|
|
|
458
|
-
for k in [
|
|
459
|
-
'cexts',
|
|
460
|
-
|
|
461
|
-
'find_packages',
|
|
462
|
-
'package_data',
|
|
463
|
-
'manifest_in',
|
|
464
|
-
]:
|
|
465
|
-
st.pop(k, None)
|
|
466
|
-
|
|
467
510
|
pyp_dct['tool.setuptools.packages.find'] = {
|
|
468
511
|
'include': [],
|
|
469
512
|
}
|
|
@@ -501,14 +544,110 @@ class _PyprojectCextPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
501
544
|
src,
|
|
502
545
|
)
|
|
503
546
|
|
|
504
|
-
def _write_file_contents(self) -> None:
|
|
505
|
-
fc = self.file_contents()
|
|
506
547
|
|
|
507
|
-
|
|
508
|
-
|
|
548
|
+
class _PyprojectRsPackageGenerator(_PyprojectExtensionPackageGenerator):
|
|
549
|
+
@cached_nullary
|
|
550
|
+
def find_rs_dirs(self) -> ta.Sequence[str]:
|
|
551
|
+
return sorted(
|
|
552
|
+
dp
|
|
553
|
+
for dp, dns, fns in os.walk(self._dir_name)
|
|
554
|
+
for fn in fns
|
|
555
|
+
if fn == '.omlish-rs-ext'
|
|
556
|
+
)
|
|
509
557
|
|
|
510
|
-
|
|
511
|
-
|
|
558
|
+
#
|
|
559
|
+
|
|
560
|
+
@staticmethod
|
|
561
|
+
def _sdist_patch_body() -> None:
|
|
562
|
+
def _patch_sdist():
|
|
563
|
+
def _sdist_add_defaults(old, self):
|
|
564
|
+
import os.path
|
|
565
|
+
|
|
566
|
+
old(self)
|
|
567
|
+
|
|
568
|
+
if self.distribution.rust_extensions and len(self.distribution.rust_extensions) > 0:
|
|
569
|
+
build_rust = self.get_finalized_command('build_rust') # noqa
|
|
570
|
+
for ext in build_rust.extensions:
|
|
571
|
+
ext_dir = os.path.dirname(ext.path)
|
|
572
|
+
for n in os.listdir(ext_dir):
|
|
573
|
+
if n.startswith('.') or n == 'target':
|
|
574
|
+
continue
|
|
575
|
+
p = os.path.join(ext_dir, n)
|
|
576
|
+
if os.path.isfile(p):
|
|
577
|
+
self.filelist.append(p)
|
|
578
|
+
elif os.path.isdir(p):
|
|
579
|
+
self.filelist.extend(os.path.join(dp, f) for dp, dn, fn in os.walk(p) for f in fn)
|
|
580
|
+
|
|
581
|
+
# Sadly, we can't just subclass sdist and override it via cmdclass because manifest_maker calls
|
|
582
|
+
# `sdist.add_defaults` as an unbound function, not a bound method:
|
|
583
|
+
# https://github.com/pypa/setuptools/blob/9c4d383631d3951fcae0afd73b5d08ff5a262976/setuptools/command/egg_info.py#L581
|
|
584
|
+
from setuptools.command.sdist import sdist # noqa
|
|
585
|
+
sdist.add_defaults = (lambda old: lambda sdist: _sdist_add_defaults(old, sdist))(sdist.add_defaults) # noqa
|
|
586
|
+
|
|
587
|
+
_patch_sdist()
|
|
588
|
+
|
|
589
|
+
@cached_nullary
|
|
590
|
+
def sdist_patch_code(self) -> str:
|
|
591
|
+
return textwrap.dedent(''.join(inspect.getsource(self._sdist_patch_body).splitlines(keepends=True)[2:])).strip()
|
|
592
|
+
|
|
593
|
+
#
|
|
594
|
+
|
|
595
|
+
@cached_nullary
|
|
596
|
+
def file_contents(self) -> _PyprojectExtensionPackageGenerator.FileContents:
|
|
597
|
+
prj = self._build_project_dict()
|
|
598
|
+
st = self._build_setuptools_dict()
|
|
599
|
+
|
|
600
|
+
#
|
|
601
|
+
|
|
602
|
+
pyp_dct = {}
|
|
603
|
+
|
|
604
|
+
pyp_dct['build-system'] = {
|
|
605
|
+
'requires': ['setuptools', 'setuptools-rust'],
|
|
606
|
+
'build-backend': 'setuptools.build_meta',
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
pyp_dct['project'] = prj
|
|
610
|
+
pyp_dct['tool.setuptools'] = st
|
|
611
|
+
|
|
612
|
+
pyp_dct['tool.setuptools.packages.find'] = {
|
|
613
|
+
'include': [],
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
#
|
|
617
|
+
|
|
618
|
+
ext_lines: list = []
|
|
619
|
+
|
|
620
|
+
for ext_dir in self.find_rs_dirs(): # noqa
|
|
621
|
+
ext_name = ext_dir.replace(os.sep, '.')
|
|
622
|
+
ext_lines.extend([
|
|
623
|
+
'st_rs.RustExtension(',
|
|
624
|
+
f" '{ext_name}',",
|
|
625
|
+
f" path='{ext_dir}/Cargo.toml',",
|
|
626
|
+
'),',
|
|
627
|
+
])
|
|
628
|
+
|
|
629
|
+
src = '\n'.join([
|
|
630
|
+
'import setuptools as st',
|
|
631
|
+
'import setuptools_rust as st_rs',
|
|
632
|
+
'',
|
|
633
|
+
'',
|
|
634
|
+
self.sdist_patch_code(),
|
|
635
|
+
'',
|
|
636
|
+
'',
|
|
637
|
+
'st.setup(',
|
|
638
|
+
' rust_extensions=[',
|
|
639
|
+
*[' ' + l for l in ext_lines],
|
|
640
|
+
' ],',
|
|
641
|
+
')',
|
|
642
|
+
'',
|
|
643
|
+
])
|
|
644
|
+
|
|
645
|
+
#
|
|
646
|
+
|
|
647
|
+
return self.FileContents(
|
|
648
|
+
pyp_dct,
|
|
649
|
+
src,
|
|
650
|
+
)
|
|
512
651
|
|
|
513
652
|
|
|
514
653
|
##
|
|
@@ -553,7 +692,8 @@ class _PyprojectCliPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
553
692
|
pyp_dct['tool.setuptools'] = st
|
|
554
693
|
|
|
555
694
|
for k in [
|
|
556
|
-
'
|
|
695
|
+
'cext',
|
|
696
|
+
'rs',
|
|
557
697
|
|
|
558
698
|
'find_packages',
|
|
559
699
|
'package_data',
|
omdev/rs/__init__.py
ADDED
|
File without changes
|
omdev/scripts/pyproject.py
CHANGED
|
@@ -65,6 +65,7 @@ import subprocess
|
|
|
65
65
|
import sys
|
|
66
66
|
import tarfile
|
|
67
67
|
import tempfile
|
|
68
|
+
import textwrap
|
|
68
69
|
import threading
|
|
69
70
|
import time
|
|
70
71
|
import traceback
|
|
@@ -11016,6 +11017,7 @@ class BasePyprojectPackageGenerator(Abstract):
|
|
|
11016
11017
|
)
|
|
11017
11018
|
|
|
11018
11019
|
if output_dir is not None:
|
|
11020
|
+
log.info(lambda: f'Copying {dist_dir} to {output_dir}')
|
|
11019
11021
|
for fn in os.listdir(dist_dir):
|
|
11020
11022
|
shutil.copyfile(os.path.join(dist_dir, fn), os.path.join(output_dir, fn))
|
|
11021
11023
|
|
|
@@ -11071,7 +11073,11 @@ class PyprojectPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
11071
11073
|
st = dict(specs.setuptools)
|
|
11072
11074
|
pyp_dct['tool.setuptools'] = st
|
|
11073
11075
|
|
|
11074
|
-
|
|
11076
|
+
for k in [
|
|
11077
|
+
'cext',
|
|
11078
|
+
'rs',
|
|
11079
|
+
]:
|
|
11080
|
+
st.pop(k, None)
|
|
11075
11081
|
|
|
11076
11082
|
#
|
|
11077
11083
|
|
|
@@ -11144,13 +11150,20 @@ class PyprojectPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
11144
11150
|
def children(self) -> ta.Sequence[BasePyprojectPackageGenerator]:
|
|
11145
11151
|
out: ta.List[BasePyprojectPackageGenerator] = []
|
|
11146
11152
|
|
|
11147
|
-
if self.build_specs().setuptools.get('
|
|
11153
|
+
if self.build_specs().setuptools.get('cext'):
|
|
11148
11154
|
out.append(_PyprojectCextPackageGenerator(
|
|
11149
11155
|
self._dir_name,
|
|
11150
11156
|
self._pkgs_root,
|
|
11151
11157
|
pkg_suffix='-cext',
|
|
11152
11158
|
))
|
|
11153
11159
|
|
|
11160
|
+
if self.build_specs().setuptools.get('rs'):
|
|
11161
|
+
out.append(_PyprojectRsPackageGenerator(
|
|
11162
|
+
self._dir_name,
|
|
11163
|
+
self._pkgs_root,
|
|
11164
|
+
pkg_suffix='-rs',
|
|
11165
|
+
))
|
|
11166
|
+
|
|
11154
11167
|
if self.build_specs().pyproject.get('cli_scripts'):
|
|
11155
11168
|
out.append(_PyprojectCliPackageGenerator(
|
|
11156
11169
|
self._dir_name,
|
|
@@ -11161,10 +11174,67 @@ class PyprojectPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
11161
11174
|
return out
|
|
11162
11175
|
|
|
11163
11176
|
|
|
11164
|
-
|
|
11177
|
+
##
|
|
11165
11178
|
|
|
11166
11179
|
|
|
11167
|
-
class
|
|
11180
|
+
class _PyprojectExtensionPackageGenerator(BasePyprojectPackageGenerator, Abstract):
|
|
11181
|
+
#
|
|
11182
|
+
|
|
11183
|
+
def _build_project_dict(self) -> ta.Dict[str, ta.Any]:
|
|
11184
|
+
prj = dict(self.build_specs().pyproject)
|
|
11185
|
+
|
|
11186
|
+
prj['dependencies'] = [f'{prj["name"]} == {prj["version"]}']
|
|
11187
|
+
prj['name'] += self._pkg_suffix
|
|
11188
|
+
|
|
11189
|
+
for k in [
|
|
11190
|
+
'optional_dependencies',
|
|
11191
|
+
'entry_points',
|
|
11192
|
+
'scripts',
|
|
11193
|
+
'cli_scripts',
|
|
11194
|
+
]:
|
|
11195
|
+
prj.pop(k, None)
|
|
11196
|
+
|
|
11197
|
+
return prj
|
|
11198
|
+
|
|
11199
|
+
def _build_setuptools_dict(self) -> ta.Dict[str, ta.Any]:
|
|
11200
|
+
st = dict(self.build_specs().setuptools)
|
|
11201
|
+
|
|
11202
|
+
for k in [
|
|
11203
|
+
'cext',
|
|
11204
|
+
'rs',
|
|
11205
|
+
|
|
11206
|
+
'find_packages',
|
|
11207
|
+
'package_data',
|
|
11208
|
+
'manifest_in',
|
|
11209
|
+
]:
|
|
11210
|
+
st.pop(k, None)
|
|
11211
|
+
|
|
11212
|
+
return st
|
|
11213
|
+
|
|
11214
|
+
#
|
|
11215
|
+
|
|
11216
|
+
@dc.dataclass(frozen=True)
|
|
11217
|
+
class FileContents:
|
|
11218
|
+
pyproject_dct: ta.Mapping[str, ta.Any]
|
|
11219
|
+
setup_py: str
|
|
11220
|
+
|
|
11221
|
+
@abc.abstractmethod
|
|
11222
|
+
def file_contents(self) -> FileContents:
|
|
11223
|
+
raise NotImplementedError
|
|
11224
|
+
|
|
11225
|
+
#
|
|
11226
|
+
|
|
11227
|
+
def _write_file_contents(self) -> None:
|
|
11228
|
+
fc = self.file_contents()
|
|
11229
|
+
|
|
11230
|
+
with open(os.path.join(self._pkg_dir(), 'pyproject.toml'), 'w') as f:
|
|
11231
|
+
TomlWriter(f).write_root(fc.pyproject_dct)
|
|
11232
|
+
|
|
11233
|
+
with open(os.path.join(self._pkg_dir(), 'setup.py'), 'w') as f:
|
|
11234
|
+
f.write(fc.setup_py)
|
|
11235
|
+
|
|
11236
|
+
|
|
11237
|
+
class _PyprojectCextPackageGenerator(_PyprojectExtensionPackageGenerator):
|
|
11168
11238
|
@cached_nullary
|
|
11169
11239
|
def find_cext_srcs(self) -> ta.Sequence[str]:
|
|
11170
11240
|
return sorted(find_magic_files(
|
|
@@ -11175,14 +11245,10 @@ class _PyprojectCextPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
11175
11245
|
|
|
11176
11246
|
#
|
|
11177
11247
|
|
|
11178
|
-
@dc.dataclass(frozen=True)
|
|
11179
|
-
class FileContents:
|
|
11180
|
-
pyproject_dct: ta.Mapping[str, ta.Any]
|
|
11181
|
-
setup_py: str
|
|
11182
|
-
|
|
11183
11248
|
@cached_nullary
|
|
11184
|
-
def file_contents(self) -> FileContents:
|
|
11185
|
-
|
|
11249
|
+
def file_contents(self) -> _PyprojectExtensionPackageGenerator.FileContents:
|
|
11250
|
+
prj = self._build_project_dict()
|
|
11251
|
+
st = self._build_setuptools_dict()
|
|
11186
11252
|
|
|
11187
11253
|
#
|
|
11188
11254
|
|
|
@@ -11193,33 +11259,9 @@ class _PyprojectCextPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
11193
11259
|
'build-backend': 'setuptools.build_meta',
|
|
11194
11260
|
}
|
|
11195
11261
|
|
|
11196
|
-
prj = specs.pyproject
|
|
11197
|
-
prj['dependencies'] = [f'{prj["name"]} == {prj["version"]}']
|
|
11198
|
-
prj['name'] += self._pkg_suffix
|
|
11199
|
-
for k in [
|
|
11200
|
-
'optional_dependencies',
|
|
11201
|
-
'entry_points',
|
|
11202
|
-
'scripts',
|
|
11203
|
-
'cli_scripts',
|
|
11204
|
-
]:
|
|
11205
|
-
prj.pop(k, None)
|
|
11206
|
-
|
|
11207
11262
|
pyp_dct['project'] = prj
|
|
11208
|
-
|
|
11209
|
-
#
|
|
11210
|
-
|
|
11211
|
-
st = dict(specs.setuptools)
|
|
11212
11263
|
pyp_dct['tool.setuptools'] = st
|
|
11213
11264
|
|
|
11214
|
-
for k in [
|
|
11215
|
-
'cexts',
|
|
11216
|
-
|
|
11217
|
-
'find_packages',
|
|
11218
|
-
'package_data',
|
|
11219
|
-
'manifest_in',
|
|
11220
|
-
]:
|
|
11221
|
-
st.pop(k, None)
|
|
11222
|
-
|
|
11223
11265
|
pyp_dct['tool.setuptools.packages.find'] = {
|
|
11224
11266
|
'include': [],
|
|
11225
11267
|
}
|
|
@@ -11257,14 +11299,110 @@ class _PyprojectCextPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
11257
11299
|
src,
|
|
11258
11300
|
)
|
|
11259
11301
|
|
|
11260
|
-
def _write_file_contents(self) -> None:
|
|
11261
|
-
fc = self.file_contents()
|
|
11262
11302
|
|
|
11263
|
-
|
|
11264
|
-
|
|
11303
|
+
class _PyprojectRsPackageGenerator(_PyprojectExtensionPackageGenerator):
|
|
11304
|
+
@cached_nullary
|
|
11305
|
+
def find_rs_dirs(self) -> ta.Sequence[str]:
|
|
11306
|
+
return sorted(
|
|
11307
|
+
dp
|
|
11308
|
+
for dp, dns, fns in os.walk(self._dir_name)
|
|
11309
|
+
for fn in fns
|
|
11310
|
+
if fn == '.omlish-rs-ext'
|
|
11311
|
+
)
|
|
11265
11312
|
|
|
11266
|
-
|
|
11267
|
-
|
|
11313
|
+
#
|
|
11314
|
+
|
|
11315
|
+
@staticmethod
|
|
11316
|
+
def _sdist_patch_body() -> None:
|
|
11317
|
+
def _patch_sdist():
|
|
11318
|
+
def _sdist_add_defaults(old, self):
|
|
11319
|
+
import os.path
|
|
11320
|
+
|
|
11321
|
+
old(self)
|
|
11322
|
+
|
|
11323
|
+
if self.distribution.rust_extensions and len(self.distribution.rust_extensions) > 0:
|
|
11324
|
+
build_rust = self.get_finalized_command('build_rust') # noqa
|
|
11325
|
+
for ext in build_rust.extensions:
|
|
11326
|
+
ext_dir = os.path.dirname(ext.path)
|
|
11327
|
+
for n in os.listdir(ext_dir):
|
|
11328
|
+
if n.startswith('.') or n == 'target':
|
|
11329
|
+
continue
|
|
11330
|
+
p = os.path.join(ext_dir, n)
|
|
11331
|
+
if os.path.isfile(p):
|
|
11332
|
+
self.filelist.append(p)
|
|
11333
|
+
elif os.path.isdir(p):
|
|
11334
|
+
self.filelist.extend(os.path.join(dp, f) for dp, dn, fn in os.walk(p) for f in fn)
|
|
11335
|
+
|
|
11336
|
+
# Sadly, we can't just subclass sdist and override it via cmdclass because manifest_maker calls
|
|
11337
|
+
# `sdist.add_defaults` as an unbound function, not a bound method:
|
|
11338
|
+
# https://github.com/pypa/setuptools/blob/9c4d383631d3951fcae0afd73b5d08ff5a262976/setuptools/command/egg_info.py#L581
|
|
11339
|
+
from setuptools.command.sdist import sdist # noqa
|
|
11340
|
+
sdist.add_defaults = (lambda old: lambda sdist: _sdist_add_defaults(old, sdist))(sdist.add_defaults) # noqa
|
|
11341
|
+
|
|
11342
|
+
_patch_sdist()
|
|
11343
|
+
|
|
11344
|
+
@cached_nullary
|
|
11345
|
+
def sdist_patch_code(self) -> str:
|
|
11346
|
+
return textwrap.dedent(''.join(inspect.getsource(self._sdist_patch_body).splitlines(keepends=True)[2:])).strip()
|
|
11347
|
+
|
|
11348
|
+
#
|
|
11349
|
+
|
|
11350
|
+
@cached_nullary
|
|
11351
|
+
def file_contents(self) -> _PyprojectExtensionPackageGenerator.FileContents:
|
|
11352
|
+
prj = self._build_project_dict()
|
|
11353
|
+
st = self._build_setuptools_dict()
|
|
11354
|
+
|
|
11355
|
+
#
|
|
11356
|
+
|
|
11357
|
+
pyp_dct = {}
|
|
11358
|
+
|
|
11359
|
+
pyp_dct['build-system'] = {
|
|
11360
|
+
'requires': ['setuptools', 'setuptools-rust'],
|
|
11361
|
+
'build-backend': 'setuptools.build_meta',
|
|
11362
|
+
}
|
|
11363
|
+
|
|
11364
|
+
pyp_dct['project'] = prj
|
|
11365
|
+
pyp_dct['tool.setuptools'] = st
|
|
11366
|
+
|
|
11367
|
+
pyp_dct['tool.setuptools.packages.find'] = {
|
|
11368
|
+
'include': [],
|
|
11369
|
+
}
|
|
11370
|
+
|
|
11371
|
+
#
|
|
11372
|
+
|
|
11373
|
+
ext_lines: list = []
|
|
11374
|
+
|
|
11375
|
+
for ext_dir in self.find_rs_dirs(): # noqa
|
|
11376
|
+
ext_name = ext_dir.replace(os.sep, '.')
|
|
11377
|
+
ext_lines.extend([
|
|
11378
|
+
'st_rs.RustExtension(',
|
|
11379
|
+
f" '{ext_name}',",
|
|
11380
|
+
f" path='{ext_dir}/Cargo.toml',",
|
|
11381
|
+
'),',
|
|
11382
|
+
])
|
|
11383
|
+
|
|
11384
|
+
src = '\n'.join([
|
|
11385
|
+
'import setuptools as st',
|
|
11386
|
+
'import setuptools_rust as st_rs',
|
|
11387
|
+
'',
|
|
11388
|
+
'',
|
|
11389
|
+
self.sdist_patch_code(),
|
|
11390
|
+
'',
|
|
11391
|
+
'',
|
|
11392
|
+
'st.setup(',
|
|
11393
|
+
' rust_extensions=[',
|
|
11394
|
+
*[' ' + l for l in ext_lines],
|
|
11395
|
+
' ],',
|
|
11396
|
+
')',
|
|
11397
|
+
'',
|
|
11398
|
+
])
|
|
11399
|
+
|
|
11400
|
+
#
|
|
11401
|
+
|
|
11402
|
+
return self.FileContents(
|
|
11403
|
+
pyp_dct,
|
|
11404
|
+
src,
|
|
11405
|
+
)
|
|
11268
11406
|
|
|
11269
11407
|
|
|
11270
11408
|
##
|
|
@@ -11309,7 +11447,8 @@ class _PyprojectCliPackageGenerator(BasePyprojectPackageGenerator):
|
|
|
11309
11447
|
pyp_dct['tool.setuptools'] = st
|
|
11310
11448
|
|
|
11311
11449
|
for k in [
|
|
11312
|
-
'
|
|
11450
|
+
'cext',
|
|
11451
|
+
'rs',
|
|
11313
11452
|
|
|
11314
11453
|
'find_packages',
|
|
11315
11454
|
'package_data',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: omdev
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev465
|
|
4
4
|
Summary: omdev
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
14
14
|
Requires-Python: >=3.13
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: omlish==0.0.0.
|
|
17
|
+
Requires-Dist: omlish==0.0.0.dev465
|
|
18
18
|
Provides-Extra: all
|
|
19
19
|
Requires-Dist: black~=25.9; extra == "all"
|
|
20
20
|
Requires-Dist: pycparser~=2.23; extra == "all"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
omdev/.omlish-manifests.json,sha256=cMWrMB14_AFp9mQiTEeoTYL1uaC3zq7ER7-XHGCXY8I,11671
|
|
2
|
-
omdev/__about__.py,sha256=
|
|
2
|
+
omdev/__about__.py,sha256=9oG5_aX1pKiZ-pxcYppjvatDSNyKOwEcT5zG7-H_bSY,1236
|
|
3
3
|
omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
omdev/cmake.py,sha256=gu49t10_syXh_TUJs4POsxeFs8we8Y3XTOOPgIXmGvg,4608
|
|
5
5
|
omdev/imgur.py,sha256=oqei705LhSnLWQTOMHMHwRecRXcpSEP90Sg4SVINPQ0,3133
|
|
@@ -272,20 +272,20 @@ omdev/py/tools/importscan.py,sha256=OYPZBg__u6On416tcmYfRTMkjr1ZlFcOAy9AafJ8iuo,
|
|
|
272
272
|
omdev/py/tools/mkrelimp.py,sha256=40gE1p_w-f_oWptUiS8TqODhso6ow46UCEptw4VbH0c,4040
|
|
273
273
|
omdev/pyproject/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
|
274
274
|
omdev/pyproject/__main__.py,sha256=gn3Rl1aYPYdiTtEqa9ifi0t-e4ZwPY0vhJ4UXvYdJDY,165
|
|
275
|
-
omdev/pyproject/cexts.py,sha256=GLD4fe61M_fHhdMcKlcQNUoCb7MeVXY6Fw-grKH4hTU,4264
|
|
276
275
|
omdev/pyproject/cli.py,sha256=Umsu2bcJUYeeVXICaZFhKckUBT6VWuYDL4htgCGGQIs,8749
|
|
277
276
|
omdev/pyproject/configs.py,sha256=baNRwHtUW8S8DKCxuKlMbV3Gduujd1PyNURxQ48Nnxk,2813
|
|
278
277
|
omdev/pyproject/inject.py,sha256=Von8_8ofkITLoCEwDHNRAwY0AEdFQg7r2ILS8kcTMuY,325
|
|
279
|
-
omdev/pyproject/pkg.py,sha256=
|
|
278
|
+
omdev/pyproject/pkg.py,sha256=eo8g-EaKEfEFH2urERDlYC8ojKOsWBUZ00mQGcs5Ujg,19255
|
|
280
279
|
omdev/pyproject/reqs.py,sha256=DU7NBNpFTjU06VgqRYZj5jZRQxpIWbzL9q9Vm13_o0o,3317
|
|
281
280
|
omdev/pyproject/venvs.py,sha256=PNgfVrGlw9NFKJgUyzyWH5H5nAIzUDPTHRVUNBM0bKs,2187
|
|
282
281
|
omdev/pyproject/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
283
282
|
omdev/pyproject/resources/docker-dev.sh,sha256=DHkz5D18jok_oDolfg2mqrvGRWFoCe9GQo04dR1czcc,838
|
|
284
283
|
omdev/pyproject/resources/python.sh,sha256=rFaN4SiJ9hdLDXXsDTwugI6zsw6EPkgYMmtacZeTbvw,749
|
|
284
|
+
omdev/rs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
285
285
|
omdev/scripts/__init__.py,sha256=MKCvUAEQwsIvwLixwtPlpBqmkMXLCnjjXyAXvVpDwVk,91
|
|
286
286
|
omdev/scripts/ci.py,sha256=dmpJXF0mS37K6psivRDukXEBF8Z6CAuK_PQERDBzFgE,427466
|
|
287
287
|
omdev/scripts/interp.py,sha256=GELa1TPg0tStMbofHpEYetMrAl3YnInehwler2gdE2I,168564
|
|
288
|
-
omdev/scripts/pyproject.py,sha256=
|
|
288
|
+
omdev/scripts/pyproject.py,sha256=J6X4Izk-mdGLxPw-HplF3fwPQdmSEo7jQB--f1Q3xac,353810
|
|
289
289
|
omdev/scripts/slowcat.py,sha256=PwdT-pg62imEEb6kcOozl9_YUi-4KopvjvzWT1OmGb0,2717
|
|
290
290
|
omdev/scripts/tmpexec.py,sha256=t0nErDRALjTk7H0X8ADjZUIDFjlPNzOOokmjCjBHdzs,1431
|
|
291
291
|
omdev/scripts/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -355,9 +355,9 @@ omdev/tui/textual/autocomplete/__init__.py,sha256=m0EGewct7SoATrTcsCSmeRQyPucP5S
|
|
|
355
355
|
omdev/tui/textual/autocomplete/matching.py,sha256=joxUxF4jfs47E4JK0DAo_l0lwoNe9mU6iJzxI2FlVYI,6801
|
|
356
356
|
omdev/tui/textual/autocomplete/paths.py,sha256=Z3ZlTkPZezKBaFgB23d6IFJXanJc8OueBm-S0kExdRM,7242
|
|
357
357
|
omdev/tui/textual/autocomplete/widget.py,sha256=1UgWqDT0d9wD6w7MNaZBjgj0o9FohYXydifocPErdks,22629
|
|
358
|
-
omdev-0.0.0.
|
|
359
|
-
omdev-0.0.0.
|
|
360
|
-
omdev-0.0.0.
|
|
361
|
-
omdev-0.0.0.
|
|
362
|
-
omdev-0.0.0.
|
|
363
|
-
omdev-0.0.0.
|
|
358
|
+
omdev-0.0.0.dev465.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
359
|
+
omdev-0.0.0.dev465.dist-info/METADATA,sha256=YcjjqPR-_yHV6suja0JJvqNBnDRViw3bBQBSL_cje2Y,5170
|
|
360
|
+
omdev-0.0.0.dev465.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
361
|
+
omdev-0.0.0.dev465.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
|
362
|
+
omdev-0.0.0.dev465.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
|
363
|
+
omdev-0.0.0.dev465.dist-info/RECORD,,
|
omdev/pyproject/cexts.py
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007 UP045
|
|
2
|
-
import dataclasses as dc
|
|
3
|
-
import typing as ta
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
# https://setuptools.pypa.io/en/latest/userguide/ext_modules.html#extension-api-reference
|
|
8
|
-
|
|
9
|
-
name (str) -
|
|
10
|
-
the full name of the extension, including any packages - ie. not a filename or pathname, but Python dotted name
|
|
11
|
-
|
|
12
|
-
sources (list[str]) -
|
|
13
|
-
list of source filenames, relative to the distribution root (where the setup script lives), in Unix form
|
|
14
|
-
(slash-separated) for portability. Source files may be C, C++, SWIG (.i), platform-specific resource files, or
|
|
15
|
-
whatever else is recognized by the "build_ext" command as source for a Python extension.
|
|
16
|
-
|
|
17
|
-
include_dirs (list[str]) -
|
|
18
|
-
list of directories to search for C/C++ header files (in Unix form for portability)
|
|
19
|
-
|
|
20
|
-
define_macros (list[tuple[str, str|None]]) -
|
|
21
|
-
list of macros to define; each macro is defined using a 2-tuple: the first item corresponding to the name of the
|
|
22
|
-
macro and the second item either a string with its value or None to define it without a particular value (equivalent
|
|
23
|
-
of "#define FOO" in source or -DFOO on Unix C compiler command line)
|
|
24
|
-
|
|
25
|
-
undef_macros (list[str]) -
|
|
26
|
-
list of macros to undefine explicitly
|
|
27
|
-
|
|
28
|
-
library_dirs (list[str]) -
|
|
29
|
-
list of directories to search for C/C++ libraries at link time
|
|
30
|
-
|
|
31
|
-
libraries (list[str]) -
|
|
32
|
-
list of library names (not filenames or paths) to link against
|
|
33
|
-
|
|
34
|
-
runtime_library_dirs (list[str]) -
|
|
35
|
-
list of directories to search for C/C++ libraries at run time (for shared extensions, this is when the extension is
|
|
36
|
-
loaded). Setting this will cause an exception during build on Windows platforms.
|
|
37
|
-
|
|
38
|
-
extra_objects (list[str]) -
|
|
39
|
-
list of extra files to link with (eg. object files not implied by 'sources', static library that must be explicitly
|
|
40
|
-
specified, binary resource files, etc.)
|
|
41
|
-
|
|
42
|
-
extra_compile_args (list[str]) -
|
|
43
|
-
any extra platform- and compiler-specific information to use when compiling the source files in 'sources'. For
|
|
44
|
-
platforms and compilers where "command line" makes sense, this is typically a list of command-line arguments, but
|
|
45
|
-
for other platforms it could be anything.
|
|
46
|
-
|
|
47
|
-
extra_link_args (list[str]) -
|
|
48
|
-
any extra platform- and compiler-specific information to use when linking object files together to create the
|
|
49
|
-
extension (or to create a new static Python interpreter). Similar interpretation as for 'extra_compile_args'.
|
|
50
|
-
|
|
51
|
-
export_symbols (list[str]) -
|
|
52
|
-
list of symbols to be exported from a shared extension. Not used on all platforms, and not generally necessary for
|
|
53
|
-
Python extensions, which typically export exactly one symbol: "init" + extension_name.
|
|
54
|
-
|
|
55
|
-
swig_opts (list[str]) -
|
|
56
|
-
any extra options to pass to SWIG if a source file has the .i extension.
|
|
57
|
-
|
|
58
|
-
depends (list[str]) -
|
|
59
|
-
list of files that the extension depends on
|
|
60
|
-
|
|
61
|
-
language (str) -
|
|
62
|
-
extension language (i.e. "c", "c++", "objc"). Will be detected from the source extensions if not provided.
|
|
63
|
-
|
|
64
|
-
optional (bool) -
|
|
65
|
-
specifies that a build failure in the extension should not abort the build process, but simply not install the
|
|
66
|
-
failing extension.
|
|
67
|
-
|
|
68
|
-
py_limited_api (bool) -
|
|
69
|
-
opt-in flag for the usage of Python's limited API.
|
|
70
|
-
"""
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
##
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
SETUP_PY_TMPL = """
|
|
77
|
-
import setuptools as st
|
|
78
|
-
|
|
79
|
-
st.setup(
|
|
80
|
-
ext_modules=[
|
|
81
|
-
st.Extension(
|
|
82
|
-
'{mod_name}',
|
|
83
|
-
[{mod_srcs}],
|
|
84
|
-
include_dirs=['lib'],
|
|
85
|
-
py_limited_api=True
|
|
86
|
-
),
|
|
87
|
-
],
|
|
88
|
-
)
|
|
89
|
-
"""
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@dc.dataclass(frozen=True)
|
|
93
|
-
class ExtModule:
|
|
94
|
-
name: str
|
|
95
|
-
sources: ta.List[str]
|
|
96
|
-
include_dirs: ta.Optional[ta.List[str]] = None
|
|
97
|
-
define_macros: ta.Optional[ta.List[ta.Tuple[str, ta.Optional[str]]]] = None
|
|
98
|
-
undef_macros: ta.Optional[ta.List[str]] = None
|
|
99
|
-
library_dirs: ta.Optional[ta.List[str]] = None
|
|
100
|
-
libraries: ta.Optional[ta.List[str]] = None
|
|
101
|
-
runtime_library_dirs: ta.Optional[ta.List[str]] = None
|
|
102
|
-
extra_objects: ta.Optional[ta.List[str]] = None
|
|
103
|
-
extra_compile_args: ta.Optional[ta.List[str]] = None
|
|
104
|
-
extra_link_args: ta.Optional[ta.List[str]] = None
|
|
105
|
-
export_symbols: ta.Optional[ta.List[str]] = None
|
|
106
|
-
swig_opts: ta.Optional[ta.List[str]] = None
|
|
107
|
-
depends: ta.Optional[ta.List[str]] = None
|
|
108
|
-
language: ta.Optional[str] = None
|
|
109
|
-
optional: ta.Optional[bool] = None
|
|
110
|
-
py_limited_api: ta.Optional[bool] = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|