From 4f4f5546cdbb8b67b6f5e5cf76b3b618f4164ea3 Mon Sep 17 00:00:00 2001 From: Claudio Satriano Date: Tue, 21 May 2024 23:23:39 +0200 Subject: [PATCH] get_fftw3.sh: move to `scripts` dir, build to `external` dir --- .gitignore | 6 +----- README.md | 4 +++- get_fftw3.sh | 32 -------------------------------- pyproject.toml | 2 +- scripts/get_fftw3.sh | 38 ++++++++++++++++++++++++++++++++++++++ setup.py | 9 +++++---- 6 files changed, 48 insertions(+), 43 deletions(-) delete mode 100755 get_fftw3.sh create mode 100755 scripts/get_fftw3.sh diff --git a/.gitignore b/.gitignore index 0e69bd3..2105cf7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ stockwell.egg-info/ dist/ build/ wheels/ +external/ RELEASE-VERSION *.so *.pyd @@ -19,8 +20,3 @@ RELEASE-VERSION # IDE .vscode - -# FFTW3 files -fftw3/ -fftw-3.*/ -fftw-3.*.tar.gz \ No newline at end of file diff --git a/README.md b/README.md index e0a38f0..8d32a30 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/get_fftw3.sh b/get_fftw3.sh deleted file mode 100755 index eb0f322..0000000 --- a/get_fftw3.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -# Download and build the FFTW3 library -# -# This script is part of the Stockwell project. -# -# :copyright: -# 2024 Claudio Satriano -# -# :license: -# GNU General Public License v3.0 or later. -# (https://www.gnu.org/licenses/gpl-3.0.html) - -# exit on error -set -e - -# Get the script directory and move to it -scriptdir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -cd "$scriptdir" - -# remove any existing FFTW3 package and directory -rm -rf fftw-3.3.10.tar.gz fftw-3.3.10 fftw3 - -# Download the FFTW3 library and unpack it -curl -O http://www.fftw.org/fftw-3.3.10.tar.gz -tar -xzf fftw-3.3.10.tar.gz -mkdir -p fftw3 - -# Build the FFTW3 library -cd fftw-3.3.10 -./configure --prefix="$scriptdir/fftw3" --enable-threads -make -s -make -s install \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 74fd03f..90f93d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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' diff --git a/scripts/get_fftw3.sh b/scripts/get_fftw3.sh new file mode 100755 index 0000000..abbb9f1 --- /dev/null +++ b/scripts/get_fftw3.sh @@ -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 +# +# :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 \ No newline at end of file diff --git a/setup.py b/setup.py index a48ffc9..c357c7f 100644 --- a/setup.py +++ b/setup.py @@ -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: