Files
fgl-aircon/setup.py
T
petr.polezhaev b84bd8d555 ha(H1): исправления по ревью — жизненный цикл сессии, самодостаточный wheel
- C1: единственный владелец stop+destroy — reader-поток; close() только
  выставляет флаг и ждёт; повторный close и close из колбэка безопасны
  (регресс-тесты; TSan на close с мёртвым модулем — 0 гонок)
- M1: wheel собирается с bundled mbedtls (нет внешней soname mbedcrypto);
  попутно исправлена bundled-ветка CMake (-lSTATIC)
- C-API: счётчики потерянных событий/логов, лог-кольцо без union-балласта,
  атомарные fn/ctx лог-синка
- provision: валидация формата облачных ответов; CLI: человеческие ошибки
  (exit 2), --out с правами 0600, console_script pyfglair
- упаковка: MANIFEST.in (sdist с C++-исходниками), очистка stale .so,
  readme в метаданных; find_library без ложных .bak
- тесты: close-сценарии, доставка логов, ошибки CLI/provision, C-API очередь
2026-09-29 11:48:32 +03:00

58 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Сборка wheel pyfglair: вместе с python-пакетом собирается libfgl-aircon.so
из корня монорепо (cmake). Метаданные — в pyproject.toml; здесь только хуки
setuptools для сборки нативного ядра."""
from importlib.util import module_from_spec, spec_from_file_location
from pathlib import Path
from setuptools import Distribution, setup
from setuptools.command.build_py import build_py as _build_py
try:
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
except ImportError: # setuptools < 70
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
ROOT = Path(__file__).resolve().parent
def _load_corebuild():
spec = spec_from_file_location(
"_pyfglair_corebuild", ROOT / "pyfglair" / "_corebuild.py"
)
module = module_from_spec(spec)
spec.loader.exec_module(module)
return module
class build_py(_build_py):
"""Кладёт libfgl-aircon.so внутрь пакета до сборки wheel."""
def run(self):
dest = Path(self.build_lib) / "pyfglair"
dest.mkdir(parents=True, exist_ok=True)
for stale in dest.glob("libfgl-aircon.*"):
stale.unlink()
_load_corebuild().build_core(dest=dest, bundled_mbedtls=True)
super().run()
class BinaryDistribution(Distribution):
"""Платформенный wheel (внутри — .so), не py3-none-any."""
def has_ext_modules(self):
return True
class bdist_wheel(_bdist_wheel):
"""Тег py3-none-<plat>: .so собран в ABI-режиме cffi (не CPython-ABI)."""
def get_tag(self):
_, _, platform = super().get_tag()
return "py3", "none", platform
setup(
cmdclass={"build_py": build_py, "bdist_wheel": bdist_wheel},
distclass=BinaryDistribution,
)