Skip to content

Commit

Permalink
get_fftw3.sh: move to scripts dir, build to external dir
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed May 21, 2024
1 parent bf67328 commit 4f4f554
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 43 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ stockwell.egg-info/
dist/
build/
wheels/
external/
RELEASE-VERSION
*.so
*.pyd
Expand All @@ -19,8 +20,3 @@ RELEASE-VERSION

# IDE
.vscode

# FFTW3 files
fftw3/
fftw-3.*/
fftw-3.*.tar.gz
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ To compile Stockwell, you will need to have [FFTW]
installed.

On Linux and macOS, you can download and compile FFTW from source using
the script `get_fftw3.sh`
the script `get_fftw3.sh` provided in the `scripts` directory:

./scripts/get_fftw3.sh

Alternatively, you can install FFTW using your package manager:

Expand Down
32 changes: 0 additions & 32 deletions get_fftw3.sh

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ select = "*-musllinux*"
before-all = "apk add fftw-dev"

[tool.cibuildwheel.macos]
before-build = './get_fftw3.sh'
before-build = './scripts/get_fftw3.sh'

[tool.cibuildwheel.windows]
before-all = '%CONDA%\Scripts\conda.exe install fftw'
Expand Down
38 changes: 38 additions & 0 deletions scripts/get_fftw3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Download and build the FFTW3 library
#
# This script is part of the Stockwell project.
#
# :copyright:
# 2024 Claudio Satriano <[email protected]>
#
# :license:
# GNU General Public License v3.0 or later.
# (https://www.gnu.org/licenses/gpl-3.0.html)

FFWT_VERSION="3.3.10"

# exit on error
set -e

# Get the script directory
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Create a directory named "external" in the project root, if it doesn't exist
ext_dir="$script_dir/../external"
mkdir -p "$ext_dir"
cd "$ext_dir"

# remove any existing FFTW3 package and directory
rm -rf fftw-*.tar.gz fftw-* fftw3

# Download the FFTW3 library and unpack it
curl -O http://www.fftw.org/fftw-$FFWT_VERSION.tar.gz
tar -xzf fftw-$FFWT_VERSION.tar.gz
rm fftw-$FFWT_VERSION.tar.gz
mkdir -p fftw3

# Build the FFTW3 library
cd fftw-$FFWT_VERSION
./configure --prefix="$ext_dir/fftw3" --enable-threads
make -s
make -s install
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

include_dirs_st = []
library_dirs_st = []
# First search for fftw3 in the current directory
# First search for fftw3 in the "external" directory
# (i.e., installed using the script "get_fftw3.sh")
if os.path.exists('fftw3'):
include_dirs_st.append('fftw3/include')
library_dirs_st.append('fftw3/lib')
fftw3_dir = os.path.join('external', 'fftw3')
if os.path.exists(fftw3_dir):
include_dirs_st.append(os.path.join(fftw3_dir, 'include'))
library_dirs_st.append(os.path.join(fftw3_dir, 'lib'))
else:
# Search Homebrew fftw3 on macOS
if 'HOMEBREW_PREFIX' in os.environ:
Expand Down

0 comments on commit 4f4f554

Please sign in to comment.