Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import sys
from pathlib import Path

# Available at setup time due to pyproject.toml
from pybind11.setup_helpers import Pybind11Extension, build_ext
from pybind11.setup_helpers import Pybind11Extension
from setuptools import setup


# Omit `-std=c++` flags if we're building C source files with Clang
if sys.platform == "darwin":
from distutils import unixccompiler

class PatchedUnixCCompiler(unixccompiler.UnixCCompiler):
def _compile(
self, obj, src, ext, cc_args, extra_postargs, pp_opts, *args, **kwargs
):
if self.compiler[0] == "clang" and ext == ".c":
extra_postargs = [a for a in extra_postargs if "-std=c++" not in a]

return super()._compile(
obj, src, ext, cc_args, extra_postargs, pp_opts, *args, **kwargs
)

unixccompiler.UnixCCompiler = PatchedUnixCCompiler


_DIR = Path(__file__).parent
_FRONTEND_DIR = _DIR / "tensorflow" / "lite" / "experimental" / "microfrontend" / "lib"
_KISSFFT_DIR = _DIR / "kissfft"
Expand Down Expand Up @@ -41,6 +61,7 @@
Pybind11Extension(
name="micro_features_cpp",
language="c++",
cxx_std=17,
extra_compile_args=flags,
sources=sorted([str(p) for p in sources] + [str(_DIR / "python.cpp")]),
define_macros=[("VERSION_INFO", __version__)],
Expand Down