fast-slic
fast-slic copied to clipboard
PEP 517 support
I am trying to use fast-slic via a poetry dependency. This fails because it is not compatible with PEP 517.
This can be reproduced via pip install --no-cache-dir --use-pep517 fast-slic.
Hi there, I was able to fix it by applying the following changes:
- Create a pyproject.toml with the following:
requires = ["setuptools", "wheel", "Cython", "numpy"]
build-backend = "setuptools.build_meta"
- Modify the setup.py with: Remove the:
dist.Distribution().fetch_build_eggs(['cython', 'numpy'])
This is now handled by pyproject.toml
Also need to adjust the _check_avx2() method to not crash if no cpuid found as :
try:
from cpuid.cpuid import CPUID
# Invoke CPUID instruction with eax 0x7
input_eax = 0x7
output_eax, output_ebx, output_ecx, output_edx = CPUID()(input_eax)
bits = bin(output_ebx)[::-1]
avx2_support = bits[5]
return avx2_support == '1'
except (ImportError, Exception) as e:
# If cpuid is not available or there's an issue, assume no AVX2 support
return False
Finally, in setup, remove the setup_requires line (you can also add cpuid to install_requires if you like.
Then just pip install .