fCWT
fCWT copied to clipboard
building for python
fyi i had to add 'libs' to library_dirs and include_dirs in setup.py in order for this to build for python.
#!/usr/bin/env python
"""
setup.py file for SWIG
"""
from setuptools import Extension, setup, find_packages
import distutils.command.build
import sysconfig
import numpy
import os
import shutil
# Obtain the numpy include directory. This logic works across numpy versions.
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
libraries = ['fftw3f']
comp_args = ["/arch:AVX", "/O2", "/openmp"]
link_args = []
files2 = ["omp.h",
"fftw3.h",
"fftw3f.dll",
"fftw3f.lib",
"libfftw3fmac.a",
"libfftw3f_ompmac.a",
"libfftw3fl.so",
"libfftw3f_ompl.so",
"libomp.a"
]
files = [
"fcwt.h",
"fcwt.cpp"
]
files = files + files2
if "macosx" in sysconfig.get_platform() or "darwin" in sysconfig.get_platform():
libraries = ['fftw3fmac', 'fftw3f_ompmac']
comp_args = ["-mavx", "-O3"]
link_args = ["-lomp"]
if "linux" in sysconfig.get_platform():
libraries = ['fftw3fl', 'fftw3f_ompl']
comp_args = ["-mavx", "-O3"]
link_args = ["-lomp"]
setup(ext_modules=[
Extension('fcwt._fcwt',
sources=[
'src/fcwt/fcwt.cpp',
'src/fcwt/fcwt_wrap.cxx'
],
library_dirs=['src/fcwt', 'src', 'libs'],
include_dirs=['src/fcwt', 'src', 'libs', numpy_include],
libraries=libraries,
extra_compile_args=comp_args,
extra_link_args=link_args
)
],
packages=find_packages(where='src'),
package_dir={'fcwt': 'src/fcwt'},
package_data={'fcwt': files}
)
Thanks for the above update. In addition to this, however, I had to add the following to comp_args for an intel Mac running Ventura 13.2:
comp_args = ["-std=c++17", "-mavx", "-O3"]
This was due to the following error (which happened in a number of places):
error: use of undeclared identifier 'aligned_alloc'; did you mean 'omp_aligned_alloc'?