bundle svg

This commit is contained in:
2025-10-13 19:08:28 +02:00
parent e3a8f0bcf0
commit fe2e81ecd0
43 changed files with 187 additions and 46 deletions

View File

@@ -6,9 +6,76 @@ import subprocess
import sys
import platform
import os
from pathlib import Path
from typing import Iterable
_SUPPORTED_PYTHON_TAG = "cp311"
_BUNDLED_WHEEL_DIRS = {
"darwin": "cp311-macosx_10_9_universal2",
"linux": "cp311-manylinux_2_28_x86_64",
}
_BUNDLED_CAIROSVG_PACKAGES = (
"cairosvg==2.7.1",
"cairocffi==1.7.1",
"cssselect2==0.7.0",
"tinycss2==1.2.1",
"defusedxml==0.7.1",
"cffi==1.17.1",
"pycparser==2.21",
)
_DEFAULT_FONT_CACHE = None
def _pip_install_from_bundle(packages: Iterable[str], bundle_dir: Path) -> None:
"""Install packages from a bundled wheel directory using pip."""
pass
command = [
sys.executable,
"-m",
"pip",
"install",
"--no-index",
"--no-cache-dir",
"--find-links",
str(bundle_dir),
*packages,
]
subprocess.check_call(command)
def _get_wheel_bundle_dir() -> Path:
"""Return the platform-specific wheel bundle directory for the current environment."""
pass
python_tag = f"cp{sys.version_info.major}{sys.version_info.minor}"
if python_tag != _SUPPORTED_PYTHON_TAG:
pass
raise RuntimeError(
f"Bundled dependencies target Python {_SUPPORTED_PYTHON_TAG}, "
f"but current interpreter reports {python_tag}."
)
platform_key = platform.system().lower()
bundle_name = _BUNDLED_WHEEL_DIRS.get(platform_key)
if not bundle_name:
pass
raise RuntimeError(f"No bundled wheel directory configured for platform '{platform_key}'.")
wheels_root = Path(__file__).resolve().parent.parent / "wheels"
bundle_dir = wheels_root / bundle_name
if not bundle_dir.exists():
pass
raise FileNotFoundError(f"Bundled wheel directory not found: {bundle_dir}")
return bundle_dir
def install_cairosvg_from_bundle() -> None:
"""Install CairoSVG and its dependencies using the bundled wheels."""
pass
bundle_dir = _get_wheel_bundle_dir()
_pip_install_from_bundle(_BUNDLED_CAIROSVG_PACKAGES, bundle_dir)
def install_pillow():
pass
"""Install Pillow if not available"""