partis-pyproj 0.1.3rc4__py3-none-any.whl → 0.1.5__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.
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/__init__.py +9 -1
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/_legacy_setup.py +11 -11
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/_nonprintable.py +4 -3
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/backend.py +44 -37
- partis_pyproj-0.1.5.data/purelib/partis/pyproj/builder/builder.py +351 -0
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/builder/cargo.py +5 -6
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/builder/cmake.py +14 -25
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/builder/meson.py +10 -23
- partis_pyproj-0.1.5.data/purelib/partis/pyproj/builder/process.py +42 -0
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/dist_file/__init__.py +1 -1
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/dist_file/dist_base.py +75 -86
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/dist_file/dist_binary.py +6 -24
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/dist_file/dist_copy.py +7 -18
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/dist_file/dist_source.py +4 -21
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/dist_file/dist_targz.py +5 -12
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/dist_file/dist_zip.py +5 -14
- partis_pyproj-0.1.5.data/purelib/partis/pyproj/file.py +65 -0
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/legacy.py +3 -2
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/load_module.py +7 -6
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/norms.py +35 -31
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/path/__init__.py +2 -1
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/path/match.py +42 -35
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/path/pattern.py +60 -54
- partis_pyproj-0.1.5.data/purelib/partis/pyproj/path/utils.py +94 -0
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/pep.py +36 -35
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/pkginfo.py +7 -16
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/pptoml.py +125 -120
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/pyproj.py +44 -39
- partis_pyproj-0.1.5.data/purelib/partis/pyproj/template.py +229 -0
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/validate.py +279 -269
- partis_pyproj-0.1.5.dist-info/METADATA +500 -0
- partis_pyproj-0.1.5.dist-info/RECORD +37 -0
- partis_pyproj-0.1.3rc4.data/purelib/partis/pyproj/builder/builder.py +0 -153
- partis_pyproj-0.1.3rc4.data/purelib/partis/pyproj/builder/process.py +0 -78
- partis_pyproj-0.1.3rc4.data/purelib/partis/pyproj/path/utils.py +0 -40
- partis_pyproj-0.1.3rc4.dist-info/METADATA +0 -51
- partis_pyproj-0.1.3rc4.dist-info/RECORD +0 -35
- {partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/builder/__init__.py +0 -0
- {partis_pyproj-0.1.3rc4.dist-info → partis_pyproj-0.1.5.dist-info}/LICENSE.txt +0 -0
- {partis_pyproj-0.1.3rc4.dist-info → partis_pyproj-0.1.5.dist-info}/WHEEL +0 -0
- {partis_pyproj-0.1.3rc4.dist-info → partis_pyproj-0.1.5.dist-info}/entry_points.txt +0 -0
- {partis_pyproj-0.1.3rc4.dist-info → partis_pyproj-0.1.5.dist-info}/top_level.txt +0 -0
{partis_pyproj-0.1.3rc4.data → partis_pyproj-0.1.5.data}/purelib/partis/pyproj/path/pattern.py
RENAMED
@@ -1,21 +1,22 @@
|
|
1
|
+
from __future__ import annotations
|
1
2
|
import os
|
2
3
|
import os.path as osp
|
4
|
+
from pathlib import PurePath
|
3
5
|
import re
|
4
6
|
from collections import namedtuple
|
5
7
|
|
6
8
|
from .utils import _subdir
|
7
9
|
|
8
|
-
|
10
|
+
#===============================================================================
|
9
11
|
class PathPatternError(ValueError):
|
10
12
|
pass
|
11
13
|
|
12
|
-
|
14
|
+
#===============================================================================
|
13
15
|
# NOTE: The regular expressions are constructed to match path separators defined
|
14
16
|
# by these (non-printable) control characters, unlikely to be in any filename,
|
15
|
-
# making them independent from 'os.path.sep'
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
17
|
+
# making them independent from 'os.path.sep', instead of specializing the patterns
|
18
|
+
# to each flavor.
|
19
|
+
# The paths to be matched, though, must be translated to this form.
|
19
20
|
# File Separator (E.G. '/')
|
20
21
|
SEP = chr(0x1c)
|
21
22
|
# Group Separator (E.G. '.')
|
@@ -29,17 +30,18 @@ PARDIR = chr(0x1e)
|
|
29
30
|
# CURDIR = '.'
|
30
31
|
# PARDIR = '..'
|
31
32
|
|
32
|
-
|
33
|
-
def tr_path(path):
|
33
|
+
#===============================================================================
|
34
|
+
def tr_path(path: PurePath) -> str:
|
34
35
|
"""Translates path to be compatible with the translated regex.match
|
35
36
|
|
36
37
|
Parameters
|
37
38
|
---------
|
38
|
-
path:
|
39
|
+
path:
|
40
|
+
Path to be translated
|
39
41
|
|
40
42
|
Returns
|
41
43
|
-------
|
42
|
-
tr_path
|
44
|
+
tr_path:
|
43
45
|
Translated path, with each path segment separated by :data:`SEP`.
|
44
46
|
"""
|
45
47
|
parts = path.parts
|
@@ -53,13 +55,14 @@ def tr_path(path):
|
|
53
55
|
|
54
56
|
return SEP.join(parts)
|
55
57
|
|
56
|
-
|
57
|
-
def inv_path(path):
|
58
|
-
"""
|
58
|
+
#===============================================================================
|
59
|
+
def inv_path(path: str, sep: str = osp.sep) -> str:
|
60
|
+
"""Convert translated path back to os path
|
59
61
|
"""
|
60
|
-
return
|
62
|
+
return sep.join(path.split(SEP))
|
61
63
|
|
62
|
-
|
64
|
+
#===============================================================================
|
65
|
+
# The glob pattern is defined using POSIX paths, even if matching other flavors
|
63
66
|
# path separator (NOTE: except for a trailing recursive "/**")
|
64
67
|
re_sep = r'(?P<sep>/(?!\*\*\Z))'
|
65
68
|
# fixed (no wildcard) segment
|
@@ -92,25 +95,24 @@ re_glob = '|'.join([
|
|
92
95
|
rec_glob = re.compile(re_glob)
|
93
96
|
rec_unescape = re.compile(r'\\([*?[])')
|
94
97
|
|
95
|
-
|
96
|
-
def tr_rel_join(start, dir, names):
|
98
|
+
#===============================================================================
|
99
|
+
def tr_rel_join(start: str, dir: str, names: list[str]) -> list[tuple[str, str]]:
|
97
100
|
"""Creates paths relative to a 'start' path for a list of names in a 'dir'
|
98
101
|
'start' and 'dir' must already be translated by :func:`tr_path`.
|
99
102
|
|
100
103
|
Parameters
|
101
104
|
----------
|
102
|
-
start
|
105
|
+
start:
|
103
106
|
Starting directory, already translated by :func:`tr_path`.
|
104
|
-
dir
|
107
|
+
dir: str
|
105
108
|
Directory to compute relative path to, *must* be a sub-directory of `start`,
|
106
109
|
already translated by :func:`tr_path`.
|
107
|
-
names
|
110
|
+
names:
|
108
111
|
List of names in `dir`
|
109
112
|
|
110
113
|
Returns
|
111
114
|
-------
|
112
|
-
|
113
|
-
List of names joined with path relative to `start`
|
115
|
+
List of names joined with path relative to `start`
|
114
116
|
"""
|
115
117
|
|
116
118
|
rpath = tr_subdir( start, dir )
|
@@ -120,8 +122,8 @@ def tr_rel_join(start, dir, names):
|
|
120
122
|
(name, tr_join(rpath, name))
|
121
123
|
for name in names ]
|
122
124
|
|
123
|
-
|
124
|
-
def tr_join(*args):
|
125
|
+
#===============================================================================
|
126
|
+
def tr_join(*args: str):
|
125
127
|
"""Joins paths already translated by :func:`tr_path`.
|
126
128
|
"""
|
127
129
|
|
@@ -129,21 +131,21 @@ def tr_join(*args):
|
|
129
131
|
|
130
132
|
return SEP.join(args)
|
131
133
|
|
132
|
-
|
133
|
-
def tr_subdir(start, path):
|
134
|
+
#===============================================================================
|
135
|
+
def tr_subdir(start: str, path: str) -> str:
|
134
136
|
"""Relative path, restricted to sub-directories.
|
135
137
|
|
136
138
|
Parameters
|
137
139
|
----------
|
138
|
-
start
|
140
|
+
start:
|
139
141
|
Starting directory, already translated by :func:`tr_path`.
|
140
|
-
path
|
142
|
+
path:
|
141
143
|
Directory to compute relative path to, *must* be a sub-directory of `start`,
|
142
144
|
already translated by :func:`tr_path`.
|
143
145
|
|
144
146
|
Returns
|
145
147
|
-------
|
146
|
-
rpath
|
148
|
+
rpath:
|
147
149
|
Relative path from `start` to `path`.
|
148
150
|
"""
|
149
151
|
|
@@ -160,45 +162,49 @@ def tr_subdir(start, path):
|
|
160
162
|
raise PathPatternError(f"Not a subdirectory of {inv_path(start)}: {inv_path(path)}")
|
161
163
|
|
162
164
|
return SEP.join(_rpath)
|
163
|
-
|
164
|
-
|
165
|
+
|
166
|
+
#===============================================================================
|
165
167
|
class GRef(namedtuple('GRef', ['ori', 'case', 'start', 'end'])):
|
168
|
+
r"""Helps track how a regex was constructed from a glob pattern
|
169
|
+
"""
|
166
170
|
__slots__ = ()
|
167
171
|
|
168
172
|
|
169
|
-
|
173
|
+
#===============================================================================
|
170
174
|
class GCase:
|
175
|
+
r"""Container for constructing parts of a regex from glob pattern
|
176
|
+
"""
|
171
177
|
#-----------------------------------------------------------------------------
|
172
|
-
def __init__(self, ref = None):
|
178
|
+
def __init__(self, ref: GRef|None = None):
|
173
179
|
if ref is None:
|
174
180
|
ref = GRef(None, 'undefined', None, None)
|
175
181
|
|
176
182
|
self.ref = ref
|
177
183
|
|
178
184
|
#-----------------------------------------------------------------------------
|
179
|
-
def regex(self):
|
185
|
+
def regex(self) -> str:
|
180
186
|
raise NotImplementedError("")
|
181
187
|
|
182
188
|
#-----------------------------------------------------------------------------
|
183
189
|
def __str__(self):
|
184
190
|
return self.regex()
|
185
191
|
|
186
|
-
|
192
|
+
#===============================================================================
|
187
193
|
class GStr(GCase):
|
188
194
|
#-----------------------------------------------------------------------------
|
189
|
-
def __init__(self, regex, ref = None):
|
195
|
+
def __init__(self, regex: str, ref: GRef|None = None):
|
190
196
|
super().__init__(ref = ref)
|
191
197
|
|
192
198
|
self._regex = regex
|
193
199
|
|
194
200
|
#-----------------------------------------------------------------------------
|
195
|
-
def regex(self):
|
201
|
+
def regex(self) -> str:
|
196
202
|
return self._regex
|
197
203
|
|
198
|
-
|
204
|
+
#===============================================================================
|
199
205
|
class GList(GCase):
|
200
206
|
#-----------------------------------------------------------------------------
|
201
|
-
def __init__(self, parts = None, ref = None):
|
207
|
+
def __init__(self, parts: list[str] = None, ref: GRef|None = None):
|
202
208
|
super().__init__(ref = ref)
|
203
209
|
|
204
210
|
if parts is None:
|
@@ -207,34 +213,34 @@ class GList(GCase):
|
|
207
213
|
self.parts = parts
|
208
214
|
|
209
215
|
#-----------------------------------------------------------------------------
|
210
|
-
def regex(self):
|
216
|
+
def regex(self) -> str:
|
211
217
|
return ''.join([v.regex() for v in self.parts])
|
212
218
|
|
213
219
|
#-----------------------------------------------------------------------------
|
214
|
-
def append(self, val):
|
220
|
+
def append(self, val: str):
|
215
221
|
self.parts.append(val)
|
216
222
|
|
217
223
|
#-----------------------------------------------------------------------------
|
218
224
|
def __str__(self):
|
219
225
|
return self._regex
|
220
226
|
|
221
|
-
|
227
|
+
#===============================================================================
|
222
228
|
class GName(GStr):
|
223
229
|
pass
|
224
230
|
|
225
|
-
|
231
|
+
#===============================================================================
|
226
232
|
class GFixed(GName):
|
227
233
|
pass
|
228
234
|
|
229
|
-
|
235
|
+
#===============================================================================
|
230
236
|
class GChrSet(GName):
|
231
237
|
pass
|
232
238
|
|
233
|
-
|
239
|
+
#===============================================================================
|
234
240
|
GCHR = GName(rf'[^{SEP}]')
|
235
241
|
GANY = GName(rf'[^{SEP}]*')
|
236
242
|
|
237
|
-
|
243
|
+
#===============================================================================
|
238
244
|
def reduce_any(pid, sid, n, i, working):
|
239
245
|
r"""
|
240
246
|
Parameters
|
@@ -314,7 +320,7 @@ def reduce_any(pid, sid, n, i, working):
|
|
314
320
|
|
315
321
|
return pat
|
316
322
|
|
317
|
-
|
323
|
+
#===============================================================================
|
318
324
|
class GSegment(GList):
|
319
325
|
#-----------------------------------------------------------------------------
|
320
326
|
def __init__(self, pid, sid, parts = None, ref = None):
|
@@ -355,7 +361,7 @@ class GSegment(GList):
|
|
355
361
|
|
356
362
|
return ''.join(combined)
|
357
363
|
|
358
|
-
|
364
|
+
#===============================================================================
|
359
365
|
class GSeparator(GStr):
|
360
366
|
pass
|
361
367
|
|
@@ -363,12 +369,12 @@ GSEP = GSeparator(SEP)
|
|
363
369
|
GSUBDIR = GSeparator(rf'([^{SEP}]+{SEP})*')
|
364
370
|
GALLDIR = GSeparator(rf'({SEP}[^{SEP}]+)+')
|
365
371
|
|
366
|
-
|
372
|
+
#===============================================================================
|
367
373
|
class GPath(list):
|
368
374
|
def regex(self):
|
369
375
|
return ''.join([v.regex() for v in self])
|
370
376
|
|
371
|
-
|
377
|
+
#===============================================================================
|
372
378
|
class PatternError(ValueError):
|
373
379
|
#-----------------------------------------------------------------------------
|
374
380
|
def __init__(self, msg, pat, segs):
|
@@ -381,7 +387,7 @@ class PatternError(ValueError):
|
|
381
387
|
self.pat = pat
|
382
388
|
self.segs = segs
|
383
389
|
|
384
|
-
|
390
|
+
#===============================================================================
|
385
391
|
def esc_chrset(c):
|
386
392
|
if c == '/':
|
387
393
|
raise PathPatternError("Path separator '/' in character range is undefined.")
|
@@ -391,7 +397,7 @@ def esc_chrset(c):
|
|
391
397
|
|
392
398
|
return c
|
393
399
|
|
394
|
-
|
400
|
+
#===============================================================================
|
395
401
|
def tr_range(pat):
|
396
402
|
|
397
403
|
# range
|
@@ -416,7 +422,7 @@ def tr_range(pat):
|
|
416
422
|
|
417
423
|
return f"{esc_chrset(a)}-{esc_chrset(d)}"
|
418
424
|
|
419
|
-
|
425
|
+
#===============================================================================
|
420
426
|
def tr_chrset(pat):
|
421
427
|
n = len(pat)
|
422
428
|
|
@@ -467,7 +473,7 @@ def tr_chrset(pat):
|
|
467
473
|
|
468
474
|
return ''.join(parts)
|
469
475
|
|
470
|
-
|
476
|
+
#===============================================================================
|
471
477
|
def tr_glob(pat, pid = 0):
|
472
478
|
"""
|
473
479
|
Notes
|
@@ -0,0 +1,94 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
import sys
|
3
|
+
from os import (
|
4
|
+
curdir,
|
5
|
+
pardir,
|
6
|
+
fspath)
|
7
|
+
from os.path import (
|
8
|
+
realpath)
|
9
|
+
from pathlib import (
|
10
|
+
Path,
|
11
|
+
PurePath)
|
12
|
+
|
13
|
+
#===============================================================================
|
14
|
+
class PathError(ValueError):
|
15
|
+
pass
|
16
|
+
|
17
|
+
#===============================================================================
|
18
|
+
def resolve(path: Path):
|
19
|
+
r"""Backport of latest Path.resolve behavior
|
20
|
+
"""
|
21
|
+
return type(path)(realpath(fspath(path)))
|
22
|
+
|
23
|
+
#===============================================================================
|
24
|
+
def _concretize(comps: list[str]) -> list[str]|None:
|
25
|
+
r"""Mostly equivalent to :func:`os.path.normpath`, except for the cases where
|
26
|
+
a concrete path is not possible or would be truncated.
|
27
|
+
|
28
|
+
For example, the path `a/../b` can be normalized to the concrete path `b`,
|
29
|
+
but `a/../../b` depends the name of a's parent directory.
|
30
|
+
"""
|
31
|
+
|
32
|
+
new_comps = []
|
33
|
+
|
34
|
+
for comp in comps:
|
35
|
+
if not comp or comp == curdir:
|
36
|
+
continue
|
37
|
+
|
38
|
+
if comp == pardir:
|
39
|
+
if not new_comps:
|
40
|
+
# concrete path not possible
|
41
|
+
return None
|
42
|
+
|
43
|
+
new_comps.pop()
|
44
|
+
else:
|
45
|
+
new_comps.append(comp)
|
46
|
+
|
47
|
+
return new_comps
|
48
|
+
|
49
|
+
#===============================================================================
|
50
|
+
def _subdir(_start: list[str], _path: list[str]) -> list[str]|None:
|
51
|
+
r"""Concrete path relative to start, or `None` if path is not a sub-directory
|
52
|
+
"""
|
53
|
+
|
54
|
+
if (_start := _concretize(_start)) is None:
|
55
|
+
return None
|
56
|
+
|
57
|
+
if (_path := _concretize(_path)) is None:
|
58
|
+
return None
|
59
|
+
|
60
|
+
n = len(_start)
|
61
|
+
|
62
|
+
if len(_path) < n or _path[:n] != _start:
|
63
|
+
return None
|
64
|
+
|
65
|
+
return _path[n:]
|
66
|
+
|
67
|
+
#===============================================================================
|
68
|
+
def subdir(start: PurePath, path: PurePath, check: bool = True) -> PurePath|None:
|
69
|
+
"""Relative path, restricted to sub-directories.
|
70
|
+
|
71
|
+
Parameters
|
72
|
+
----------
|
73
|
+
start:
|
74
|
+
Starting directory.
|
75
|
+
path:
|
76
|
+
Directory to compute relative path to, *must* be a sub-directory of `start`.
|
77
|
+
check:
|
78
|
+
If True, raises exception if not a subdirectory. Otherwise returns None.
|
79
|
+
|
80
|
+
Returns
|
81
|
+
-------
|
82
|
+
rpath:
|
83
|
+
Relative path from `start` to `path`.
|
84
|
+
"""
|
85
|
+
|
86
|
+
_rpath = _subdir(start.parts, path.parts)
|
87
|
+
|
88
|
+
if _rpath is None:
|
89
|
+
if check:
|
90
|
+
raise PathError(f"Not a subdirectory of {start}: {path}")
|
91
|
+
|
92
|
+
return None
|
93
|
+
|
94
|
+
return type(path)(*_rpath)
|