from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import sys

# This class will properly handle NumPy dependencies
class BuildExt(build_ext):
  def finalize_options(self):
    build_ext.finalize_options(self)
    # Prevent numpy from thinking it is still in its setup process
    import builtins
    builtins.__NUMPY_SETUP__ = False
    import numpy
    self.include_dirs.append(numpy.get_include())

setup(
  name='filter_short_groups',
    version='1.0',
    description='Optimized C implementation of filter_short_groups',
    setup_requires=['numpy'],
    install_requires=['numpy'],
    python_requires='>=3.6',
    ext_modules=[
      Extension(
          'filter_short_groups',
            sources=['filter_short_groups.c'],
            extra_compile_args=['-O3', '-march=native', '-ffast-math'],  # Optimization flags
            ),
        ],
    cmdclass={'build_ext': BuildExt},
)
