From 1ee08a03ad7e1eff57b74676f0d527b2900cb91c Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Sun, 12 May 2024 17:59:03 +0300 Subject: [PATCH] build: Allow building sdist even if FFTW libs are not found --- MANIFEST.in | 2 +- setup.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 18df97e..4978b23 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ include *.py *.txt *.rst recursive-include mpi4py_fft *.py *.pyx *.pxd fftw_planxfftn.[c,h] -recursive-exclude mpi4py_fft fftw[f,l]_xfftn.pyx fftw[f,l]_xfftn.pxd \ No newline at end of file +recursive-exclude mpi4py_fft fftw[f,l]_xfftn.pyx fftw[f,l]_xfftn.pxd diff --git a/setup.py b/setup.py index cf8a287..a1ac903 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ import platform import sysconfig from distutils import ccompiler +from distutils.errors import DistutilsPlatformError from setuptools import setup from setuptools.dist import Distribution from setuptools.extension import Extension @@ -74,7 +75,9 @@ def get_fftw_libs(): libs[d].append(tlib) if os.name == 'posix': libs[d].append('m') - assert len(libs) > 0, "No FFTW libraries found in {}".format(library_dirs) + if not libs: + message = "No FFTW libraries found in {}".format(library_dirs) + raise DistutilsPlatformError(message) return libs def generate_extensions(fftwlibs, force=True): @@ -149,7 +152,12 @@ def get_extensions(): ), ] - fftwlibs = get_fftw_libs() + sdist = 'sdist' in sys.argv + egg_info = 'egg_info' in sys.argv + fftwlibs = ( + get_fftw_libs() if not (sdist or egg_info) else + {d: [] for d in ('float', 'double', 'long double')} + ) for d, libs in fftwlibs.items(): p = 'fftw' + prec_map[d] + '_' ext.append(