Skip to content

Commit

Permalink
added include and lib dir for fftw3 in setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pravirkr committed Nov 17, 2020
1 parent b060fa9 commit f0f3f91
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sphinx:
configuration: docs/conf.py

conda:
environment: environment_doc.yml
environment: docs/environment.yml

# Optionally set the version of Python and requirements required to build your docs
python:
Expand All @@ -26,6 +26,8 @@ python:
path: .
extra_requirements:
- docs
- method: setuptools
path: .

build:
image: latest
34 changes: 24 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

# import os
# import sys
# sys.path.insert(0, os.path.abspath('../'))

import sigpyproc

import os
import sys
sys.path.insert(0, os.path.abspath('../'))

# -- Project information -----------------------------------------------------

project = 'sigpyproc3'
Expand All @@ -37,12 +38,12 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.coverage',
'nbsphinx',
'IPython.sphinxext.ipython_console_highlighting',
Expand Down Expand Up @@ -80,3 +81,16 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


# -- Extension configuration -------------------------------------------------

napoleon_google_docstring = False
napoleon_use_admonition_for_notes = True

# -- Options for intersphinx extension ---------------------------------------

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable/", None),
}
File renamed without changes.
44 changes: 43 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import codecs
import os.path
import sysconfig

from setuptools import setup

Expand Down Expand Up @@ -28,6 +29,45 @@ def get_version(rel_path):

package_version = get_version("sigpyproc/__init__.py")


def append_path(dirs_list, *args):
entry = os.path.normpath(os.path.join(*args))
if os.path.isdir(entry):
if entry not in dirs_list:
dirs_list.append(entry)


def get_include_dirs():
prefix_dirs = ['/usr']
dirs = []
triplet = sysconfig.get_config_var('MULTIARCH') or '' # x86_64-linux-gnu
sys_include = sysconfig.get_config_var('INCLUDEDIR')
if 'FFTW_PATH' in os.environ:
append_path(dirs, os.environ['FFTW_PATH'], 'include')
if sys_include is not None:
append_path(dirs, sys_include, triplet)
append_path(dirs, sys_include)
for prefix in prefix_dirs:
append_path(dirs, prefix, 'include', triplet)
append_path(dirs, prefix, 'include')
return dirs


def get_library_dirs():
prefix_dirs = ['/usr']
dirs = []
triplet = sysconfig.get_config_var('MULTIARCH') or '' # x86_64-linux-gnu
sys_lib = sysconfig.get_config_var('LIBDIR')
if 'FFTW_PATH' in os.environ:
append_path(dirs, os.environ['FFTW_PATH'], 'lib')
if sys_lib is not None:
append_path(dirs, sys_lib, triplet)
append_path(dirs, sys_lib)
for prefix in prefix_dirs:
append_path(dirs, prefix, 'lib', triplet)
append_path(dirs, prefix, 'lib')
return dirs

# The main interface is through Pybind11Extension.
# * You can add cxx_std=11/14/17, and then build_ext can be removed.
# * You can set include_pybind11=false to add the include directory yourself,
Expand All @@ -37,11 +77,13 @@ def get_version(rel_path):
# Sort input source files if you glob sources to ensure bit-for-bit
# reproducible builds (https://github.com/pybind/python_example/pull/53)


ext_modules = [
Pybind11Extension(
'sigpyproc.libSigPyProc',
sources=['c_src/bindings.cpp'],
include_dirs=['c_src/'],
include_dirs=get_include_dirs() + ['c_src/'],
library_dirs=get_library_dirs(),
define_macros=[('VERSION_INFO', package_version)],
extra_link_args=['-lgomp', '-lm', '-lfftw3', '-lfftw3f'],
extra_compile_args=['-fopenmp'],
Expand Down

0 comments on commit f0f3f91

Please sign in to comment.