wheelpaths 0.3.2__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.
wheelpaths/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ """Offline lexical installation path plans. Never installs or imports a wheel."""
2
+ from .planner import audit, InvalidPlan, Limits
3
+
4
+ __all__ = ['audit', 'InvalidPlan', 'Limits']
wheelpaths/cli.py ADDED
@@ -0,0 +1,81 @@
1
+ """Machine-readable exit codes: 0 no modeled collision, 1 collisions, 2 invalid."""
2
+ import argparse
3
+ import json
4
+ import os
5
+ import sys
6
+ from functools import partial
7
+ from .planner import audit, InvalidPlan, Limits, _read_regular
8
+
9
+ MAX_SCHEME_BYTES = 1024 * 1024
10
+
11
+
12
+ def no_duplicates(pairs):
13
+ result = {}
14
+ for key, value in pairs:
15
+ if key in result:
16
+ raise InvalidPlan('duplicate JSON key: ' + key)
17
+ result[key] = value
18
+ return result
19
+
20
+
21
+ def _execute(argv=None):
22
+ parser = argparse.ArgumentParser(
23
+ description=__doc__,
24
+ **({"color": False} if sys.version_info >= (3, 14) else {}),
25
+ **({"formatter_class": partial(argparse.HelpFormatter, color=False)}
26
+ if sys.version_info[:2] == (3, 14) else {}))
27
+ parser.add_argument('--scheme', required=True,
28
+ help='JSON file with explicit absolute POSIX scheme paths')
29
+ parser.add_argument('wheels', nargs='+')
30
+ for name, value in vars(Limits()).items():
31
+ parser.add_argument('--' + name.replace('_', '-'), type=int, default=value)
32
+ args = parser.parse_args(argv)
33
+ try:
34
+ raw_scheme = _read_regular(args.scheme, MAX_SCHEME_BYTES)
35
+ if len(raw_scheme) > MAX_SCHEME_BYTES:
36
+ raise InvalidPlan('scheme JSON exceeds 1 MiB byte limit')
37
+ try:
38
+ scheme = json.loads(raw_scheme.decode('utf-8'), object_pairs_hook=no_duplicates)
39
+ except RecursionError as exc:
40
+ raise InvalidPlan('scheme JSON exceeds decoder nesting limit') from exc
41
+ result = audit(args.wheels, scheme, limits=Limits(**{
42
+ name: getattr(args, name) for name in vars(Limits())}))
43
+ except (InvalidPlan, ValueError, OSError) as exc:
44
+ result = {'schema': 1, 'status': 'INVALID', 'error': str(exc)}
45
+ code = 2
46
+ else:
47
+ code = 1 if result['conflicts'] else 0
48
+ try:
49
+ sys.stdout.write(json.dumps(result, sort_keys=(code != 2)) + '\n')
50
+ sys.stdout.flush()
51
+ except (OSError, ValueError, AttributeError):
52
+ return 2, True
53
+ return code, False
54
+
55
+
56
+ def main(argv=None):
57
+ """Return the report exit code without redirecting caller-owned streams."""
58
+ return _execute(argv)[0]
59
+
60
+
61
+ def entrypoint():
62
+ """Process runner: stop a failed stdout from failing again at shutdown."""
63
+ code, output_failed = _execute()
64
+ if output_failed:
65
+ # A failed buffered flush is retried during interpreter shutdown,
66
+ # which otherwise replaces the intended exit 2 with exit 120.
67
+ try:
68
+ stdout_fd = sys.stdout.fileno()
69
+ null_fd = os.open(os.devnull, os.O_WRONLY)
70
+ try:
71
+ os.dup2(null_fd, stdout_fd)
72
+ finally:
73
+ if null_fd != stdout_fd:
74
+ os.close(null_fd)
75
+ except (OSError, ValueError, AttributeError):
76
+ sys.stdout = open(os.devnull, 'w')
77
+ return code
78
+
79
+
80
+ if __name__ == '__main__':
81
+ sys.exit(entrypoint())
wheelpaths/planner.py ADDED
@@ -0,0 +1,286 @@
1
+ """Explicit POSIX scheme projections, not an installer or wheel validator."""
2
+ import configparser
3
+ import hashlib
4
+ import io
5
+ import os
6
+ import re
7
+ import stat
8
+ import zipfile
9
+ import zlib
10
+ from collections import defaultdict
11
+ from dataclasses import dataclass
12
+ from email.parser import Parser
13
+ from pathlib import Path, PurePosixPath
14
+
15
+
16
+ class InvalidPlan(ValueError):
17
+ """Input cannot be projected within the supported model."""
18
+
19
+
20
+ KEYS = {'purelib', 'platlib', 'scripts', 'data'}
21
+ MAX_METADATA = 1024 * 1024
22
+ MAX_MEMBERS = 100000
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class Limits:
27
+ """Invocation-wide admission caps, not hard resource guarantees."""
28
+
29
+ max_wheels: int = 100
30
+ max_total_archive_bytes: int = 1024 * 1024 * 1024
31
+ max_total_members: int = 250000
32
+ max_claims: int = 500000
33
+ max_conflict_claims: int = 500000
34
+
35
+ def __post_init__(self):
36
+ for name, value in vars(self).items():
37
+ if type(value) is not int or not 1 <= value <= 1000000000000:
38
+ raise InvalidPlan(name + ' must be an integer from 1 through 1000000000000')
39
+
40
+
41
+ class _Budget:
42
+ def __init__(self, limits):
43
+ self.limits = limits
44
+ self.archive_bytes = self.members = self.claims = 0
45
+
46
+
47
+ def relative(value):
48
+ if (not isinstance(value, str) or not value or '\\' in value or
49
+ any(ord(c) < 32 or ord(c) == 127 for c in value) or
50
+ any(p in ('', '.', '..') for p in value.split('/')) or
51
+ value.startswith('/') or ':' in value):
52
+ raise InvalidPlan('unsupported relative POSIX path: ' + repr(value))
53
+ return value
54
+
55
+
56
+ def scheme_paths(scheme):
57
+ if not isinstance(scheme, dict) or set(scheme) != KEYS:
58
+ raise InvalidPlan('scheme must have exactly purelib, platlib, scripts, data')
59
+ for value in scheme.values():
60
+ if not isinstance(value, str) or not value.startswith('/'):
61
+ raise InvalidPlan('scheme paths must be absolute POSIX paths')
62
+ if value != '/':
63
+ relative(value[1:])
64
+ return dict(scheme)
65
+
66
+
67
+ def destination(base, name):
68
+ return str(PurePosixPath(base) / relative(name))
69
+
70
+
71
+ def field(message, name):
72
+ values = message.get_all(name, [])
73
+ if len(values) != 1:
74
+ raise InvalidPlan('metadata needs one ' + name)
75
+ return values[0].strip()
76
+
77
+
78
+ def _read_regular(path, max_bytes):
79
+ """Read at most max_bytes plus one from a descriptor-verified regular file."""
80
+ fd = os.open(path, os.O_RDONLY | getattr(os, 'O_NONBLOCK', 0))
81
+ with os.fdopen(fd, 'rb') as stream:
82
+ if not stat.S_ISREG(os.fstat(stream.fileno()).st_mode):
83
+ raise InvalidPlan('input must be a regular file')
84
+ return stream.read(max_bytes + 1)
85
+
86
+
87
+ def wheel_claims(path, scheme, index, budget=None):
88
+ if budget is None:
89
+ budget = _Budget(Limits())
90
+ if not isinstance(path, (str, os.PathLike)):
91
+ raise InvalidPlan('wheel path must be text or path-like')
92
+ try:
93
+ path = Path(path)
94
+ except TypeError as exc:
95
+ raise InvalidPlan('wheel path must resolve to text') from exc
96
+ # The filename supplies only the expected metadata directory, never code.
97
+ parts = path.name[:-4].split('-') if path.name.endswith('.whl') else []
98
+ if len(parts) not in (5, 6) or any(not p for p in parts):
99
+ raise InvalidPlan('unsupported wheel filename: ' + path.name)
100
+ prefix = parts[0] + '-' + parts[1]
101
+ relative(prefix)
102
+ dist = prefix + '.dist-info'
103
+ data = prefix + '.data'
104
+ raw = _read_regular(path, min(256 * 1024 * 1024,
105
+ budget.limits.max_total_archive_bytes - budget.archive_bytes))
106
+ if len(raw) > 256 * 1024 * 1024:
107
+ raise InvalidPlan('wheel exceeds 256 MiB archive limit')
108
+ budget.archive_bytes += len(raw)
109
+ if budget.archive_bytes > budget.limits.max_total_archive_bytes:
110
+ raise InvalidPlan('total archive byte limit exceeded')
111
+ owner = {'input': index, 'wheel': path.name,
112
+ 'sha256': hashlib.sha256(raw).hexdigest()}
113
+ result = []
114
+ with zipfile.ZipFile(io.BytesIO(raw)) as z:
115
+ infos = z.infolist()
116
+ if len(infos) > MAX_MEMBERS:
117
+ raise InvalidPlan('wheel exceeds member limit')
118
+ budget.members += len(infos)
119
+ if budget.members > budget.limits.max_total_members:
120
+ raise InvalidPlan('total ZIP member limit exceeded')
121
+ names = set()
122
+ for info in infos:
123
+ original = info.orig_filename
124
+ name = original[:-1] if original.endswith('/') else original
125
+ relative(name)
126
+ if info.filename != original:
127
+ raise InvalidPlan('ZIP member name was truncated')
128
+ if original in names:
129
+ raise InvalidPlan('duplicate ZIP member: ' + original)
130
+ names.add(original)
131
+ mode = info.external_attr >> 16
132
+ kind = stat.S_IFMT(mode)
133
+ if kind not in (0, stat.S_IFREG, stat.S_IFDIR):
134
+ raise InvalidPlan('non-regular ZIP member: ' + original)
135
+ if ((info.is_dir() and kind == stat.S_IFREG) or
136
+ (not info.is_dir() and kind == stat.S_IFDIR)):
137
+ raise InvalidPlan('ZIP directory spelling and type differ')
138
+ if info.flag_bits & 1:
139
+ raise InvalidPlan('encrypted ZIP member')
140
+ top = name.split('/')[0]
141
+ if top.endswith('.dist-info') and top != dist:
142
+ raise InvalidPlan('unexpected metadata directory')
143
+ if top.endswith('.data') and top != data:
144
+ raise InvalidPlan('unexpected data directory')
145
+
146
+ def text(member):
147
+ try:
148
+ info = z.getinfo(member)
149
+ except KeyError as exc:
150
+ raise InvalidPlan('missing ' + member) from exc
151
+ if info.compress_type not in (zipfile.ZIP_STORED, zipfile.ZIP_DEFLATED):
152
+ raise InvalidPlan('unsupported metadata compression')
153
+ if info.file_size > MAX_METADATA:
154
+ raise InvalidPlan('metadata exceeds byte limit')
155
+ with z.open(info) as stream:
156
+ raw = stream.read(MAX_METADATA + 1)
157
+ if len(raw) > MAX_METADATA:
158
+ raise InvalidPlan('metadata exceeds byte limit')
159
+ return raw.decode('utf-8', errors='strict')
160
+
161
+ wheel = Parser().parsestr(text(dist + '/WHEEL'))
162
+ if field(wheel, 'Wheel-Version') != '1.0':
163
+ raise InvalidPlan('only Wheel-Version 1.0 is modeled')
164
+ pure = field(wheel, 'Root-Is-Purelib')
165
+ if pure not in ('true', 'false'):
166
+ raise InvalidPlan('invalid Root-Is-Purelib')
167
+ root = 'purelib' if pure == 'true' else 'platlib'
168
+ metadata = Parser().parsestr(text(dist + '/METADATA'))
169
+ normalize = lambda s: re.sub(r'[-_.]+', '-', s).lower()
170
+ if (normalize(field(metadata, 'Name')) != normalize(parts[0]) or
171
+ field(metadata, 'Version').replace('-', '_') != parts[1]):
172
+ raise InvalidPlan('filename and metadata identity differ')
173
+
174
+ def claim(target, member, kind='file'):
175
+ budget.claims += 1
176
+ if budget.claims > budget.limits.max_claims:
177
+ raise InvalidPlan('total projected claim limit exceeded')
178
+ result.append(dict(owner, target=target, member=member, kind=kind))
179
+
180
+ for info in infos:
181
+ name = info.filename.rstrip('/')
182
+ if name == data and not info.is_dir():
183
+ raise InvalidPlan('data root is not a directory')
184
+ if info.is_dir() and (name == data or
185
+ name in {data + '/' + key for key in KEYS}):
186
+ continue
187
+ if name.startswith(data + '/'):
188
+ bits = name.split('/', 2)
189
+ if len(bits) != 3 or bits[1] not in KEYS:
190
+ raise InvalidPlan('unsupported data scheme: ' + name)
191
+ key, rel = bits[1:]
192
+ else:
193
+ key, rel = root, name
194
+ claim(destination(scheme[key], rel), info.filename,
195
+ 'directory' if info.is_dir() else 'file')
196
+ ep = dist + '/entry_points.txt'
197
+ if ep in names:
198
+ config = configparser.ConfigParser(interpolation=None, strict=True,
199
+ delimiters=('=',))
200
+ config.optionxform = str
201
+ config.read_string(text(ep))
202
+ if config.defaults():
203
+ raise InvalidPlan('entry point DEFAULT values are unsupported')
204
+ for section in ('console_scripts', 'gui_scripts'):
205
+ if not config.has_section(section):
206
+ continue
207
+ for name, value in config.items(section):
208
+ relative(name)
209
+ if '/' in name or not value.strip():
210
+ raise InvalidPlan('unsupported script entry point')
211
+ claim(destination(scheme['scripts'], name), ep + ':' +
212
+ section + ':' + name, 'generated-script')
213
+ return owner, result
214
+
215
+
216
+ def audit(wheels, scheme, *, limits=None):
217
+ """Plan one candidate wheel set. Input errors never return a clear plan."""
218
+ scheme = scheme_paths(scheme)
219
+ if not isinstance(wheels, (list, tuple)) or not wheels:
220
+ raise InvalidPlan('at least one wheel is required')
221
+ if limits is None:
222
+ limits = Limits()
223
+ if type(limits) is not Limits:
224
+ raise InvalidPlan('limits must be a Limits instance')
225
+ if len(wheels) > limits.max_wheels:
226
+ raise InvalidPlan('wheel count limit exceeded')
227
+ budget = _Budget(limits)
228
+ owners, claims = [], []
229
+ try:
230
+ for index, path in enumerate(wheels):
231
+ owner, rows = wheel_claims(path, scheme, index, budget)
232
+ owners.append(owner)
233
+ claims.extend(rows)
234
+ except (OSError, zipfile.BadZipFile, UnicodeError,
235
+ configparser.Error, RuntimeError, zlib.error, EOFError) as exc:
236
+ raise InvalidPlan(str(exc)) from exc
237
+ groups = defaultdict(list)
238
+ for row in claims:
239
+ groups[row['target']].append(row)
240
+ conflicts = []
241
+ conflict_claims = 0
242
+ # Cache multi-claim ancestors only. Single-claim groups are cheap to scan,
243
+ # and caching them adds memory for ordinary directory/child pairs.
244
+ # Claim groups stay unchanged throughout conflict planning.
245
+ parent_files_cache = {}
246
+
247
+ def admit_conflict(count):
248
+ nonlocal conflict_claims
249
+ if count > limits.max_conflict_claims - conflict_claims:
250
+ raise InvalidPlan('total conflict claim reference limit exceeded')
251
+ conflict_claims += count
252
+
253
+ for target in sorted(groups):
254
+ rows = groups[target]
255
+ files = [row for row in rows if row['kind'] != 'directory']
256
+ if len(files) > 1 or (files and len(files) < len(rows)):
257
+ admit_conflict(len(rows))
258
+ conflicts.append({'type': 'same-target', 'target': target,
259
+ 'claims': rows})
260
+ # Every file also requires all ancestors to be directories. Shared
261
+ # directories alone are valid (including PEP 420 namespace packages).
262
+ for parent in PurePosixPath(target).parents:
263
+ parent_target = str(parent)
264
+ parent_rows = groups.get(parent_target, [])
265
+ if len(parent_rows) > 1:
266
+ if parent_target not in parent_files_cache:
267
+ parent_files_cache[parent_target] = [
268
+ row for row in parent_rows if row['kind'] != 'directory']
269
+ parent_files = parent_files_cache[parent_target]
270
+ else:
271
+ parent_files = [row for row in parent_rows
272
+ if row['kind'] != 'directory']
273
+ if parent_files:
274
+ # Charge before concatenation, including references repeated
275
+ # across different conflicts. No partial plan is returned.
276
+ admit_conflict(len(parent_files) + len(rows))
277
+ conflicts.append({'type': 'file-directory', 'target': str(parent),
278
+ 'claims': parent_files + rows})
279
+ return {'schema': 1, 'status': 'COLLISIONS' if conflicts else 'NO_COLLISIONS_IN_MODEL',
280
+ 'scheme': scheme, 'wheels': owners, 'claims': claims,
281
+ 'conflicts': conflicts,
282
+ 'scope': 'POSIX exact lexical paths; candidate wheels only; no installation',
283
+ 'excluded': ['existing files', 'filesystem symlink/case/Unicode aliases',
284
+ 'generated bytecode', 'Windows launchers', 'compatibility tags',
285
+ 'dependency resolution', 'RECORD integrity and wheel validity',
286
+ 'import namespace shadowing', 'execution safety']}
@@ -0,0 +1,254 @@
1
+ Metadata-Version: 2.4
2
+ Name: wheelpaths
3
+ Version: 0.3.2
4
+ Summary: Offline collision plans for explicit POSIX wheel installation layouts
5
+ Author: Anish Pentyala
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/anishpentyala/wheelpaths
8
+ Project-URL: Repository, https://github.com/anishpentyala/wheelpaths
9
+ Project-URL: Issues, https://github.com/anishpentyala/wheelpaths/issues
10
+ Keywords: wheel,python-packaging,file-collisions
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # wheelpaths
17
+
18
+ Check whether a chosen set of Python wheels would claim the same installation paths.
19
+
20
+ [![Tests](https://github.com/anishpentyala/wheelpaths/actions/workflows/tests.yml/badge.svg)](https://github.com/anishpentyala/wheelpaths/actions)
21
+
22
+ ## Quickstart
23
+
24
+ ```sh
25
+ python -m pip install "git+https://github.com/anishpentyala/wheelpaths.git"
26
+ python -m pip download --only-binary=:all: --no-deps jwt==1.4.0 PyJWT==2.15.1 -d wheels
27
+ printf '{"purelib":"/venv/lib/site-packages","platlib":"/venv/lib/site-packages","scripts":"/venv/bin","data":"/venv"}' > scheme.json
28
+ wheelpaths --scheme scheme.json wheels/*.whl > plan.json
29
+ ```
30
+
31
+ The pinned JWT wheel pair has four shared destinations under that scheme:
32
+
33
+ ```text
34
+ jwt/__init__.py
35
+ jwt/exceptions.py
36
+ jwt/py.typed
37
+ jwt/utils.py
38
+ ```
39
+
40
+ The planner exits 1 for collisions. It reads archives without installing,
41
+ extracting or importing them. This explicit POSIX path model does not inspect
42
+ an existing environment, resolve dependencies or prove an installation is safe.
43
+
44
+ Installation is currently from source. A PyPI release is being prepared; do not
45
+ assume `pip install wheelpaths` is available until its package page is linked here.
46
+
47
+ ## Details
48
+
49
+ Plan collisions in the destinations of a chosen set of Python wheels, without
50
+ installing them or importing their code. Supply an explicit POSIX installation
51
+ scheme. The output binds every claim to the SHA256 of the exact archive snapshot
52
+ read for the plan and distinguishes archive members from generated entry-point
53
+ scripts.
54
+
55
+ This is a path planner, not a package resolver, wheel validator or safe-install
56
+ certificate. `NO_COLLISIONS_IN_MODEL` means exactly that. It does not mean the
57
+ packages can be used together or installed safely.
58
+
59
+ ## Run
60
+
61
+ Install from this repository with `pip install .`, then:
62
+
63
+ ```sh
64
+ wheelpaths --scheme scheme.json first.whl second.whl > plan.json
65
+ ```
66
+
67
+ `scheme.json` must have exactly these four keys, with canonical absolute POSIX
68
+ paths. Equal destinations are allowed and important:
69
+
70
+ ```json
71
+ {
72
+ "purelib": "/venv/lib/python3.12/site-packages",
73
+ "platlib": "/venv/lib/python3.12/site-packages",
74
+ "scripts": "/venv/bin",
75
+ "data": "/venv"
76
+ }
77
+ ```
78
+
79
+ Exit 0: no collision found in the supported model. Exit 1: collisions found.
80
+ Exit 2: invalid/unsupported input, never a clear plan. Argument syntax errors use
81
+ argparse's stderr and exit 2; data/input errors produce JSON with status INVALID.
82
+
83
+ Root members use `Root-Is-Purelib`. Members in the wheel's own `.data/purelib`,
84
+ `.data/platlib`, `.data/scripts` and `.data/data` are relocated. `console_scripts`
85
+ and `gui_scripts` create POSIX command-name claims. Other entry-point groups
86
+ are ignored, including misspelled script group names; they do not generate
87
+ commands in this model. Equal targets are conflicts
88
+ even with equal contents: two owners can remove each other's files on uninstall.
89
+ A file that another claim needs as a directory is also a conflict. Shared
90
+ directories alone, including namespace-package directories, are not conflicts.
91
+
92
+ Inputs must resolve to regular files, verified on the opened descriptor. Symlinks
93
+ to regular files are allowed. On systems with `O_NONBLOCK`, FIFOs without writers
94
+ are refused without waiting for a producer. Other device or socket open failures
95
+ also produce INVALID; there is no universal timeout for regular files on a slow
96
+ or remote filesystem. The scheme JSON is UTF-8 and at most 1 MiB, including
97
+ whitespace. An over-limit or nonregular later input produces no partial plan.
98
+
99
+ Archives are never extracted. Per archive, at most 256 MiB of archive bytes, 100,000 members and 1 MiB per
100
+ read metadata file are accepted. Invocation-wide limits additionally cap the
101
+ wheel count, aggregate archive bytes, aggregate ZIP members and projected claims.
102
+ These are admission limits, not a general hostile-input sandbox or hard limits
103
+ on memory, disk, CPU time or serialized report bytes. ZIP central directories,
104
+ metadata text and path/claim objects still need memory. Conflict claim references
105
+ have a separate admission cap, including repetitions across conflicts.
106
+
107
+ ## Supported boundary
108
+
109
+ - Metadata ZIP compression must be stored or deflated; corrupted reads are INVALID.
110
+ - Wheel-Version 1.0, one expected `.dist-info` directory, optional matching `.data`.
111
+ - Explicit exact, case-sensitive POSIX lexical paths only.
112
+ - Candidate wheel set only; no network and no installed environment inspection.
113
+ - Headers and unknown schemes, special/symlink ZIP entries, duplicate members,
114
+ traversal/noncanonical paths and unknown metadata layouts fail explicitly.
115
+ - Root metadata identity is checked against the filename. RECORD contents,
116
+ member payload checksums, dependency metadata and wheel validity are not checked.
117
+
118
+ Not modeled: existing files, filesystem symlinks, case/Unicode aliases, Windows
119
+ launchers, generated bytecode, installer-added metadata such as INSTALLER, import
120
+ shadowing, ABI/tag compatibility, package dependencies or execution safety. The
121
+ scheme must reflect the intended install layout; it is not inferred from the
122
+ machine running the planner. No guarantee about a specific installer's extra
123
+ files or behavior is implied. No source builds or editable installs.
124
+
125
+ ## Checked example
126
+
127
+ An offline plan for actual `jwt 1.4.0` and `PyJWT 2.15.1` wheels finds four shared
128
+ destinations: `jwt/__init__.py`, `jwt/exceptions.py`, `jwt/py.typed` and
129
+ `jwt/utils.py`. The archive URLs and hashes are in `evidence/downloads.json`.
130
+ In a disposable staging directory, pypa installer copied the first wheel's 14
131
+ projected paths and refused the second wheel at the first predicted collision.
132
+ This is local verification, not maintainer adoption. The packages were not imported.
133
+
134
+ The test suite also checks `.data` relocation, aliased/distinct scheme roots,
135
+ console/gui scripts, within-wheel projection collisions, file/directory clashes,
136
+ namespace-directory sharing, invalid metadata, duplicate members, special files,
137
+ and machine-readable CLI outcomes. See `evidence/QUALIFICATION.md` for exact
138
+ runtime, negative-control and installed-artifact scope.
139
+
140
+ ### OpenCV desktop and headless wheels
141
+
142
+ A second offline check uses the manylinux2014 x86-64 `opencv-python` and
143
+ `opencv-python-headless` wheels for version `5.1.0.95`. Under the explicit scheme
144
+ in [`evidence/opencv-downloads.json`](evidence/opencv-downloads.json), the pair
145
+ produces 230 claims and 41 same-target conflicts, all under `cv2`. The manifest
146
+ pins both archive URLs, sizes and SHA256 hashes, plus the checked planner commit.
147
+ Pass those two wheel files and that scheme to the command in **Run** to reproduce
148
+ the plan. Neither wheel was installed or imported.
149
+
150
+ For these exact archives, an independent intersection of regular ZIP member
151
+ names gives the same 41 targets. Neither archive has `.data` relocation members
152
+ or entry-point metadata, both have `Root-Is-Purelib: false`, and the scheme's
153
+ library roots are equal. That simple intersection is not an oracle for arbitrary
154
+ wheels. Each wheel alone has no collision in this model, not a safe-install
155
+ certificate.
156
+
157
+ This illustrates a known packaging boundary, not a newly discovered OpenCV bug
158
+ or maintainer adoption. Both [OpenCV package](https://pypi.org/project/opencv-python/)
159
+ and [headless package](https://pypi.org/project/opencv-python-headless/) pages
160
+ already say to choose only one variant because they share the `cv2` namespace.
161
+
162
+ ## Existing work and intended use
163
+
164
+ Conflict detection is not new. ModuleGuard already studies and detects import
165
+ module conflicts. check-wheel-contents checks individual wheel contents.
166
+ Installer and package-manager overwrite checks are useful at install time.
167
+ wheelpaths instead emits an explicit, offline, cross-archive destination plan
168
+ including non-module `.data` and generated command targets. It is a small CI or
169
+ release-preflight building block, not a replacement for those tools. The research
170
+ notes cite their actual capabilities and do not claim exhaustive novelty.
171
+
172
+ ## License
173
+
174
+ MIT. No package-index release is implied by this repository.
175
+
176
+
177
+ ## Invocation-wide admission limits
178
+
179
+ | Option | Default | What counts |
180
+ | --- | --- | --- |
181
+ | `--max-wheels` | 100 | Every supplied input, including repeated paths |
182
+ | `--max-total-archive-bytes` | 1073741824 (1 GiB) | Sum of exact archive bytes read across inputs |
183
+ | `--max-total-members` | 250000 | Every ZIP member, including directories/metadata |
184
+ | `--max-claims` | 500000 | Each projected file/directory/generated script claim |
185
+ | `--max-conflict-claims` | 500000 | Every claim reference in every reported conflict, counting repetitions |
186
+
187
+ Each cap is an integer from 1 through 1000000000000. API booleans are not
188
+ integers here. Use `audit(wheels, scheme, limits=Limits(...))`, importing `Limits`
189
+ from `wheelpaths`, or the CLI flags above. Existing per-archive limits still
190
+ apply independently, even if an aggregate cap is raised. Equality with a cap is
191
+ allowed; exceeding any cap returns INVALID/exit2, never a partial collision plan.
192
+ Raising a cap is an explicit choice to admit more input, not a safety guarantee.
193
+
194
+ The wheel count is checked before any archive is opened. Each archive read is
195
+ bounded by the smaller of the per-archive limit plus one byte and the remaining
196
+ aggregate byte budget plus one. The one excess byte detects an overrun, is never
197
+ accepted into a plan, and need not be the entire next archive. Aggregate member
198
+ counts are checked after ZIP indexing but before reading metadata. Claims are
199
+ counted as projected, including generated console/gui scripts and repeated
200
+ claims; a relocation-only directory entry skipped by the existing planner still
201
+ counts as a ZIP member but does not create a projected claim. No file content is
202
+ installed, extracted or executed. Budgets reset for each audit call.
203
+
204
+ These new defaults intentionally reject formerly uncapped large invocations.
205
+ For inputs admitted under the defaults, successful plan structure, owner hashes,
206
+ claim ordering, collision semantics and report schema remain unchanged. No new
207
+ fields are added to successful reports. The CLI's INVALID JSON keeps its existing
208
+ shape; consumers must not interpret an invalid result as a collision-free plan.
209
+
210
+ ### Conflict report admission
211
+
212
+ `Limits(max_conflict_claims=N)` or `--max-conflict-claims N` limits the sum of
213
+ `len(conflict["claims"])` across the complete report. A claim repeated in several
214
+ conflicts is counted every time. Both same-target and file/directory conflicts
215
+ count. Shared directories alone do not create conflicts or spend this budget.
216
+ For example, one file blocking 100 descendant targets creates 200 claim references,
217
+ even though the blocking file is only one projected claim.
218
+
219
+ Equality with the cap is accepted. If the next conflict would exceed it, the
220
+ whole audit raises `InvalidPlan`, or the CLI returns INVALID/exit 2 without a
221
+ partial conflict plan. It never clips conflicts or presents an incomplete list
222
+ as a complete report. The cap is checked before constructing a combined
223
+ ancestor/descendant conflict-claim list. Budget state resets for each audit call.
224
+ This new default intentionally rejects previously admitted reports above the
225
+ cap; reports within it retain the same fields, ordering and collision semantics.
226
+
227
+ This limits claim-reference count, not unique claims, string lengths, encoded
228
+ JSON bytes or every intermediate allocation. Input claims and ZIP indexes have
229
+ already been collected before conflict analysis. A long target or member string
230
+ can make each reference large, so this is not a hard output-size or RAM bound.
231
+ No file is installed, executed, extracted, deleted or repaired.
232
+
233
+ ### Output failures
234
+
235
+ The installed command and `python -m wheelpaths.cli` return exit 2 if stdout
236
+ cannot be written or flushed, including closed pipes and full devices. This
237
+ overrides the model's clear/collision status. Partial bytes already written
238
+ cannot be retracted; check the process exit status before using a report.
239
+ The process runner redirects failed stdout to the null device before Python's
240
+ shutdown flush, avoiding an ignored flush exception and exit 120.
241
+
242
+ The callable `wheelpaths.cli.main(argv)` returns 2 on output failure without
243
+ closing or redirecting caller-owned streams. Embedding applications own their
244
+ own later flush/shutdown behavior.
245
+
246
+
247
+ ## Scheme decoder limits
248
+
249
+ A scheme JSON document nested beyond Python's decoder limit returns INVALID
250
+ JSON and exit 2, rather than an uncaught traceback and exit 1 (which otherwise
251
+ means a collision was found). This refusal happens before reading wheel
252
+ archives. The nesting guard applies only to scheme decoding; unexpected planner
253
+ failures are not silently turned into input errors. This is not a hard input
254
+ byte, memory, or CPU limit for scheme files.
@@ -0,0 +1,9 @@
1
+ wheelpaths/__init__.py,sha256=LCr2qS_bpFfMbTaSRDfnqpnoah4YOHGURbO5papuhMg,176
2
+ wheelpaths/cli.py,sha256=wEkW-24KlA0VFcNNTwj2uCA0x1xrneQP_bvLPpzMCF0,2941
3
+ wheelpaths/planner.py,sha256=GdFXuG6m946NoVj8deJysaKdANVWH1HxR45tt3adfQI,12635
4
+ wheelpaths-0.3.2.dist-info/licenses/LICENSE,sha256=5yembAmR4hjWu7NOBFMDqvjvtnM8Ta_OGaPrAsVcI-I,1071
5
+ wheelpaths-0.3.2.dist-info/METADATA,sha256=gckRHuKuGZJ3uCmdaaQddPwSHLkZ7eg37B0Wg4nFNnA,13212
6
+ wheelpaths-0.3.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ wheelpaths-0.3.2.dist-info/entry_points.txt,sha256=PRkLQBknzFnETaCqlWzo0PBrriL2e0A_BH5Z57p0YEQ,57
8
+ wheelpaths-0.3.2.dist-info/top_level.txt,sha256=QpS98snMLFJOGsEMhiAEZq4uV1WiKrT7W2lxrejiq74,11
9
+ wheelpaths-0.3.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ wheelpaths = wheelpaths.cli:entrypoint
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anish Pentyala
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ wheelpaths