Files

48 lines
1.5 KiB
Python

"""Build the compiled simbracket wheel.
python gen_c.py (once, where Cython is installed)
python -m pip wheel . --no-deps --no-build-isolation -w dist
The extension is built from simbracket/_core.c when it exists, so the build machine needs a C
compiler but not Cython. Neither the .pyx nor the .c is put into the wheel. Floating-point
contraction (FMA) is switched off so that the compiled arithmetic is the IEEE arithmetic of
the Python reference, operation for operation.
"""
import os
import sys
from setuptools import Extension, setup
HERE = os.path.dirname(os.path.abspath(__file__))
C_SRC = os.path.join("simbracket", "_core.c")
if sys.platform == "win32":
cflags = ["/O2", "/fp:precise"]
else:
cflags = ["-O2", "-ffp-contract=off", "-fno-fast-math"]
ext = Extension(
"simbracket._core",
sources=[C_SRC],
extra_compile_args=cflags,
define_macros=[("Py_LIMITED_API", "0x030A0000")],
py_limited_api=True,
)
if not os.path.exists(os.path.join(HERE, C_SRC)):
sys.exit("simbracket/_core.c is missing: run gen_c.py where Cython is installed")
setup(
name="simbracket",
version="1.0.0",
description="Bracketing root finding by similarity and analogy (compiled).",
license="Apache-2.0",
packages=["simbracket"],
package_data={},
include_package_data=False,
ext_modules=[ext],
python_requires=">=3.10",
options={"bdist_wheel": {"py_limited_api": "cp310"}},
zip_safe=False,
)