ifm3d-ffmpeg 8.1.2.post1__py3-none-win_amd64.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.
@@ -0,0 +1,26 @@
1
+ {
2
+ "avcodec_major": 62,
3
+ "avutil_major": 60,
4
+ "build_revision": 1,
5
+ "bundled_non_system_dependencies": [],
6
+ "distribution_version": "8.1.2.post1",
7
+ "embedded_dependencies": [
8
+ "winpthreads"
9
+ ],
10
+ "ffmpeg_version": "8.1.2",
11
+ "libraries": {
12
+ "avcodec": "avcodec-62.dll",
13
+ "avutil": "avutil-60.dll"
14
+ },
15
+ "license_files": [
16
+ "licenses/COPYING.LGPLv2.1",
17
+ "licenses/COPYING.LGPLv3",
18
+ "licenses/LICENSE.md",
19
+ "licenses/winpthreads-COPYING"
20
+ ],
21
+ "platform": "windows-x64",
22
+ "schema_version": 1,
23
+ "source_date_epoch": 1781664417,
24
+ "source_sha256": "464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c",
25
+ "wheel_tag": "py3-none-win_amd64"
26
+ }
@@ -0,0 +1,13 @@
1
+ """Package-local FFmpeg H.264 decoder libraries for ifm3d."""
2
+
3
+ from ._loader import abi_info, activate, lib_files, lib_path, version
4
+
5
+ __version__ = str(abi_info()["distribution_version"])
6
+ __all__ = [
7
+ "__version__",
8
+ "version",
9
+ "abi_info",
10
+ "lib_path",
11
+ "lib_files",
12
+ "activate",
13
+ ]
@@ -0,0 +1,160 @@
1
+ """Strict discovery for the FFmpeg libraries bundled in a release wheel."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import ctypes
7
+ import os
8
+ import platform
9
+ import re
10
+ import sys
11
+ from pathlib import Path
12
+ from typing import Any, Dict
13
+
14
+ _VERSION_RE = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
15
+ _PLATFORMS = {"linux-x64", "linux-aarch64", "windows-x64"}
16
+ _REQUIRED_KEYS = {
17
+ "schema_version",
18
+ "ffmpeg_version",
19
+ "build_revision",
20
+ "distribution_version",
21
+ "platform",
22
+ "wheel_tag",
23
+ "source_sha256",
24
+ "source_date_epoch",
25
+ "avcodec_major",
26
+ "avutil_major",
27
+ "libraries",
28
+ "bundled_non_system_dependencies",
29
+ "embedded_dependencies",
30
+ "license_files",
31
+ }
32
+ _DLL_DIRECTORY_HANDLES: list[Any] = []
33
+ _LIBRARY_HANDLES: list[Any] = []
34
+
35
+
36
+ def _host_platform() -> str:
37
+ machine = platform.machine().lower()
38
+ if sys.platform == "win32" and machine in {"amd64", "x86_64"}:
39
+ return "windows-x64"
40
+ if sys.platform == "linux" and machine in {"amd64", "x86_64"}:
41
+ return "linux-x64"
42
+ if sys.platform == "linux" and machine in {"aarch64", "arm64"}:
43
+ return "linux-aarch64"
44
+ raise RuntimeError(
45
+ f"unsupported host for ifm3d-ffmpeg: {sys.platform}/{platform.machine()}"
46
+ )
47
+
48
+
49
+ def _load_metadata() -> Dict[str, Any]:
50
+ path = Path(__file__).with_name("BUILD_INFO.json")
51
+ try:
52
+ metadata = json.loads(path.read_text(encoding="utf-8"))
53
+ except FileNotFoundError as exc:
54
+ raise RuntimeError(f"required wheel metadata is missing: {path}") from exc
55
+ except (OSError, json.JSONDecodeError) as exc:
56
+ raise RuntimeError(f"required wheel metadata is invalid: {exc}") from exc
57
+ if not isinstance(metadata, dict) or set(metadata) != _REQUIRED_KEYS:
58
+ raise RuntimeError("wheel metadata fields are incomplete or unexpected")
59
+ version = metadata["ffmpeg_version"]
60
+ revision = metadata["build_revision"]
61
+ package_platform = metadata["platform"]
62
+ if (
63
+ metadata["schema_version"] != 1
64
+ or not isinstance(version, str)
65
+ or not _VERSION_RE.fullmatch(version)
66
+ or not isinstance(revision, int)
67
+ or revision < 1
68
+ or package_platform not in _PLATFORMS
69
+ or metadata["distribution_version"] != f"{version}.post{revision}"
70
+ or not re.fullmatch(r"[0-9a-f]{64}", str(metadata["source_sha256"]))
71
+ or not isinstance(metadata["source_date_epoch"], int)
72
+ or not isinstance(metadata["avcodec_major"], int)
73
+ or not isinstance(metadata["avutil_major"], int)
74
+ or not isinstance(metadata["bundled_non_system_dependencies"], list)
75
+ or metadata["bundled_non_system_dependencies"]
76
+ or not isinstance(metadata["embedded_dependencies"], list)
77
+ ):
78
+ raise RuntimeError("wheel metadata values are invalid")
79
+ if package_platform != _host_platform():
80
+ raise RuntimeError(
81
+ f"wheel targets {package_platform}, but host is {_host_platform()}"
82
+ )
83
+ libraries = metadata["libraries"]
84
+ if not isinstance(libraries, dict) or set(libraries) != {"avcodec", "avutil"}:
85
+ raise RuntimeError("wheel metadata library map is invalid")
86
+ expected = (
87
+ {
88
+ "avcodec": f"avcodec-{metadata['avcodec_major']}.dll",
89
+ "avutil": f"avutil-{metadata['avutil_major']}.dll",
90
+ }
91
+ if package_platform == "windows-x64"
92
+ else {
93
+ "avcodec": f"libavcodec.so.{metadata['avcodec_major']}",
94
+ "avutil": f"libavutil.so.{metadata['avutil_major']}",
95
+ }
96
+ )
97
+ if libraries != expected:
98
+ raise RuntimeError("wheel library names do not match ABI metadata")
99
+ expected_embedded = (
100
+ {"winpthreads"} if package_platform == "windows-x64" else set()
101
+ )
102
+ embedded_dependencies = metadata["embedded_dependencies"]
103
+ if (
104
+ len(embedded_dependencies) != len(set(embedded_dependencies))
105
+ or set(embedded_dependencies) != expected_embedded
106
+ ):
107
+ raise RuntimeError("wheel dependency metadata is invalid")
108
+ return metadata
109
+
110
+
111
+ def version() -> str:
112
+ """Return the exact upstream FFmpeg version."""
113
+ return str(_load_metadata()["ffmpeg_version"])
114
+
115
+
116
+ def abi_info() -> Dict[str, Any]:
117
+ """Return a copy of the validated build and ABI metadata."""
118
+ return dict(_load_metadata())
119
+
120
+
121
+ def lib_path() -> Path:
122
+ """Return the package-local runtime library directory."""
123
+ path = Path(__file__).with_name("lib")
124
+ if not path.is_dir():
125
+ raise RuntimeError(f"required wheel library directory is missing: {path}")
126
+ return path
127
+
128
+
129
+ def lib_files() -> Dict[str, Path]:
130
+ """Return exact metadata-matching avcodec and avutil runtime paths."""
131
+ metadata = _load_metadata()
132
+ libraries = metadata["libraries"]
133
+ assert isinstance(libraries, dict)
134
+ result = {name: lib_path() / str(filename) for name, filename in libraries.items()}
135
+ missing = [str(path) for path in result.values() if not path.is_file()]
136
+ if missing:
137
+ raise RuntimeError(f"required wheel libraries are missing: {missing}")
138
+ return result
139
+
140
+
141
+ def activate() -> Dict[str, Path]:
142
+ """Make bundled libraries discoverable before ifm3d loads bare ABI names."""
143
+ files = lib_files()
144
+ if _LIBRARY_HANDLES:
145
+ return files
146
+ new_handles: list[Any] = []
147
+ if _host_platform() == "windows-x64":
148
+ directory_handle = os.add_dll_directory(str(lib_path()))
149
+ try:
150
+ new_handles.append(ctypes.WinDLL(str(files["avutil"])))
151
+ new_handles.append(ctypes.WinDLL(str(files["avcodec"])))
152
+ except Exception:
153
+ directory_handle.close()
154
+ raise
155
+ _DLL_DIRECTORY_HANDLES.append(directory_handle)
156
+ else:
157
+ new_handles.append(ctypes.CDLL(str(files["avutil"]), mode=ctypes.RTLD_GLOBAL))
158
+ new_handles.append(ctypes.CDLL(str(files["avcodec"]), mode=ctypes.RTLD_GLOBAL))
159
+ _LIBRARY_HANDLES.extend(new_handles)
160
+ return files
Binary file
Binary file