- _corebuild.musl_platform_tag(): на musl (Alpine/HA OS) bdist_wheel выпускает py3-none-musllinux_X_Y_<arch> вместо linux_<arch> — иначе pip ставит glibc-сборку и dlopen падает на ld-linux-x86-64.so.2 - shared-библиотека линкуется со -static-libstdc++ -static-libgcc (gcc): NEEDED только libm/libc (проверено readelf), меньше зависимостей у HA OS - Gitea Actions: job build-musllinux (container python:3.12-alpine) собирает и публикует musl-wheel; build-glibc — как раньше; общий scripts/publish-gitea-pypi.sh с пропуском уже загруженных файлов - тесты musl_platform_tag; RELEASE_HA §1.1-1.4 (выбор wheel, переустановка на HA OS, ручная сборка musllinux без container:); README troubleshooting
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
"""Определение платформы wheel: musl (Alpine/HA OS) vs glibc."""
|
|
from __future__ import annotations
|
|
|
|
from pyfglair import _corebuild
|
|
|
|
|
|
class _Result:
|
|
def __init__(self, stdout: str = "", stderr: str = "") -> None:
|
|
self.stdout = stdout
|
|
self.stderr = stderr
|
|
|
|
|
|
def test_glibc_returns_none(monkeypatch):
|
|
monkeypatch.setattr(
|
|
_corebuild.subprocess,
|
|
"run",
|
|
lambda *args, **kwargs: _Result("ldd (GNU libc) 2.42\n"),
|
|
)
|
|
assert _corebuild.musl_platform_tag() is None
|
|
|
|
|
|
def test_musl_x86_64(monkeypatch):
|
|
monkeypatch.setattr(
|
|
_corebuild.subprocess,
|
|
"run",
|
|
lambda *args, **kwargs: _Result("musl libc (x86_64)\nVersion 1.2.5\n"),
|
|
)
|
|
monkeypatch.setattr(_corebuild.platform, "machine", lambda: "x86_64")
|
|
assert _corebuild.musl_platform_tag() == "musllinux_1_2_x86_64"
|
|
|
|
|
|
def test_musl_aarch64(monkeypatch):
|
|
monkeypatch.setattr(
|
|
_corebuild.subprocess,
|
|
"run",
|
|
lambda *args, **kwargs: _Result(
|
|
"musl libc (aarch64)\nVersion 1.2.4\n"
|
|
),
|
|
)
|
|
monkeypatch.setattr(_corebuild.platform, "machine", lambda: "aarch64")
|
|
assert _corebuild.musl_platform_tag() == "musllinux_1_2_aarch64"
|
|
|
|
|
|
def test_ldd_missing(monkeypatch):
|
|
def boom(*args, **kwargs):
|
|
raise FileNotFoundError("ldd")
|
|
|
|
monkeypatch.setattr(_corebuild.subprocess, "run", boom)
|
|
assert _corebuild.musl_platform_tag() is None
|