jodhus / pyebur128

A Cython implementation of the libebur128 library for measuring audio loudness.
MIT License
1 stars 1 forks source link

Installation not compatible with Setuptools>65 #1

Closed psobot closed 6 days ago

psobot commented 2 weeks ago

Thanks for this great package, @jodhus!

Unfortunately, the setup.py in this project doesn't seem to be compatible with newer versions of Setuptools; failing at installation time with:

Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "/Users/psobot/Library/Caches/uv/builds-v0/.tmpfwaiHS/lib/python3.10/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
  File "/Users/psobot/Library/Caches/uv/builds-v0/.tmpfwaiHS/lib/python3.10/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
    self.run_setup()
  File "/Users/psobot/Library/Caches/uv/builds-v0/.tmpfwaiHS/lib/python3.10/site-packages/setuptools/build_meta.py", line 318, in run_setup
    exec(code, locals())
  File "<string>", line 7, in <module>
ModuleNotFoundError: No module named 'distutils.msvccompiler'

Downgrading Setuptools works, but is not compatible with PEP 517 build isolation and causes installation to fail with newer tools like uv.

jodhus commented 2 weeks ago

Thanks for catching this! Unfortunately I have not looked at this code in a very long time so it's not surprising something broke.

If I remember correctly, the only reason I needed that specific class was to make sure that I included the math library for those using the MSVC compiler since it didn't add it automatically at compile time. I'll have to see if there's a new way to detect that and/or if it's still needed with the newer versions of MSVC.

jodhus commented 2 weeks ago

@psobot:

Well, I got it compiling on Windows 11, VS 2022, Python 3.12.5, setuptools 74.0.0 by modifying the imports in the setup.py file:

from setuptools import setup, find_packages, Extension
from setuptools._distutils.ccompiler import new_compiler
from setuptools._distutils._msvccompiler import MSVCCompiler

However, after scouring the setuptools issues log on GitHub it appears that they don't particularly like anyone using that due to how they are slowly merging distutils functionality into the main module. So far, there isn't a real good replacement/migration for the new_compiler function and the MSVCCompiler class. See https://github.com/pypa/setuptools/issues/2806

I'm going to look to see if there's a better way to detect MSVC to avoid this mess altogether before I update the code with the above hack.

jodhus commented 1 week ago

@psobot:

After lots of cleanup and refactoring the GitHub automation, I released 0.1.1 which should fix the issue. I'm basically forcing the _USE_MATH_DEFINE macro on all compilers for now since all the other compilers besides MSVC ignore it. Not particularly happy with it, but it's what works until setuptools reimplements compiler detection functions from distutils.

I'll leave this open for a few more days in case you have any other suggestions/concerns. Otherwise, I'll go ahead and close it then.

jodhus commented 6 days ago

Fixed with version 0.1.1.

psobot commented 6 days ago

Thank you @jodhus! Looks great to me and I appreciate the quick response. 🙌🏻