34 lines
846 B
Python
34 lines
846 B
Python
"""Build hook for dlp-io.
|
|
|
|
Default builds (``python -m build``) stay pure Python and produce the
|
|
``py3-none-any`` wheel declared in ``pyproject.toml``.
|
|
|
|
Setting ``DLP_IO_PYD=1`` compiles the single ``dlp_io`` module into a C
|
|
extension with Cython, producing a platform wheel (for example
|
|
``cp313-cp313-win_amd64``) that ships one ``.pyd`` binary instead of
|
|
the ``.py`` source.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
from setuptools import setup
|
|
|
|
_BUILD_PYD = os.environ.get("DLP_IO_PYD") == "1"
|
|
_MODULE = "dlp_io"
|
|
|
|
if _BUILD_PYD:
|
|
from Cython.Build import cythonize
|
|
|
|
setup(
|
|
ext_modules=cythonize(
|
|
[f"{_MODULE}.py"],
|
|
build_dir=os.path.join("build", "cython"),
|
|
compiler_directives={"language_level": "3"},
|
|
),
|
|
py_modules=[],
|
|
)
|
|
else:
|
|
setup(py_modules=[_MODULE])
|