Files
aegis-python/setup.py
T
LeoVasanko 9583a1f9a8
release / build-wheels (linux, bash) (push) Successful in 1m12s
release / build-wheels (windows, cmd) (push) Failing after 1m16s
release / build-wheels (macos, bash) (push) Successful in 1m21s
release / publish-pypi (push) Skipped
Fix cdef size_t size on Win64 (LLP64), require 64-bit builds
The generated cdef typedef'd size_t as unsigned long: 8 bytes on LP64
but only 4 on 64-bit Windows, where C's size_t is 8. cffi's import-time
struct layout verification then failed (aegis_raf_scratch.len: cdef
says 4, C compiler says 8). cffi pre-defines size_t/uint8_t with the
correct platform sizes, so don't typedef them.

Also hard-fail 32-bit build attempts in setup.py; 32-bit platforms are
no longer supported.
2026-10-04 17:32:52 +00:00

50 lines
1.2 KiB
Python

"""Setup script for aeg - builds CFFI extension with libaegis C library."""
import sys
import sysconfig
from pathlib import Path
from cffi import FFI
from setuptools import setup
ROOT = Path(__file__).parent.resolve()
if sys.maxsize <= 2**32:
raise RuntimeError(
"aeg does not support 32-bit platforms; build with a 64-bit Python"
)
libaegis_static = ROOT / "libaegis/zig-out/lib" / (
"aegis.lib" if sys.platform == "win32" else "libaegis.a"
)
ffibuilder = FFI()
ffibuilder.cdef((ROOT / "src/aeg/aegis_cdef.h").read_text())
# Free-threaded Python does not support Limited API (abi3)
is_free_threaded = sysconfig.get_config_var("Py_GIL_DISABLED")
ffibuilder.set_source(
"aeg._aegis",
"""
#include "aegis.h"
#include "aegis128l.h"
#include "aegis128x2.h"
#include "aegis128x4.h"
#include "aegis256.h"
#include "aegis256x2.h"
#include "aegis256x4.h"
""",
include_dirs=[str(ROOT / "libaegis/src/include")],
extra_objects=[str(libaegis_static)],
py_limited_api=not is_free_threaded,
)
if __name__ == "__main__":
setup(
cffi_modules=["setup.py:ffibuilder"],
options=(
{"bdist_wheel": {"py_limited_api": "cp312"}} if not is_free_threaded else {}
),
)