Skip to content

Commit

Permalink
fix properties
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Feb 9, 2024
1 parent 8545525 commit b6ad315
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
import sysconfig
import tempfile
import platform
if sys.version_info[:2] >= (3, 8):
from functools import cached_property
else:
cached_property = property # Fallback for Python 3.7
from setuptools import setup, Distribution, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.build_py import build_py
Expand Down Expand Up @@ -282,7 +286,7 @@ def compile_args(self) -> tuple[str, ...]:
compile_args.extend(self.__host_config.native_compile_args)
return tuple(compile_args)

@lru_cache
@lru_cache(maxsize=None)
def _is_enabled(self, feature: str) -> bool:
"""Returns True if given compilation feature is enabled.
Expand All @@ -303,13 +307,15 @@ def _is_enabled(self, feature: str) -> bool:
use_openmp = property(lambda self: self._is_enabled('openmp'))
use_native = property(lambda self: self._is_enabled('native'))

@cached_property
def use_ssse3(self) -> bool:
enabled = self._is_enabled('ssse3')
if enabled and not self.use_sse2:
logger.error("use_ssse3=True disabled: incompatible with use_sse2=False")
return False
return enabled

@cached_property
def use_avx2(self) -> bool:
enabled = self._is_enabled('avx2')
if enabled and not (self.use_sse2 and self.use_ssse3):
Expand All @@ -318,6 +324,7 @@ def use_avx2(self) -> bool:
return False
return enabled

@cached_property
def use_avx512(self) -> bool:
enabled = self._is_enabled('avx512')
if enabled and not (self.use_sse2 and self.use_ssse3 and self.use_avx2):
Expand Down

0 comments on commit b6ad315

Please sign in to comment.