fast-slic icon indicating copy to clipboard operation
fast-slic copied to clipboard

PEP 517 support

Open christian-rauch opened this issue 1 year ago • 1 comments

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.

christian-rauch avatar Mar 22 '24 07:03 christian-rauch

Hi there, I was able to fix it by applying the following changes:

  1. Create a pyproject.toml with the following:
requires = ["setuptools", "wheel", "Cython", "numpy"]
build-backend = "setuptools.build_meta"
  1. 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 .

a-mruiz avatar Sep 23 '24 14:09 a-mruiz