- CMake: shared-таргет fgl-aircon-shared (FGL_BUILD_SHARED, PIC, SOVERSION) - C-API: fgl_prop_raw_range + кольцевые очереди событий/логов (fgl_session_poll/wait_events, fgl_log_poll/wait_events): прямые колбэки из потоков ядра со стеком 8 КБ небезопасны для интерпретатора Python - pyfglair: _corebuild (cmake->wheel), _cffi (ABI), Session (reader-поток -> loop.call_soon_threadsafe), templates (интроспекция C-таблиц), provision (aiohttp), CLI discover/monitor + esphome-secrets - setup.py/pyproject: платформенный wheel py3-none-linux_x86_64 с .so - tests/pyfglair: templates, provision (мок-облако), session + CLI против mock_ac.py; scripts/py-ci.sh; ci.sh запускает python-часть
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
"""Сборка 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)
|
||
_load_corebuild().build_core(dest=dest)
|
||
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,
|
||
)
|