Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building for python #21

Open
allmondjoy87 opened this issue Jan 26, 2023 · 1 comment
Open

building for python #21

allmondjoy87 opened this issue Jan 26, 2023 · 1 comment

Comments

@allmondjoy87
Copy link

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}
)
@damieno27
Copy link

damieno27 commented Feb 4, 2023

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'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants