From 7df5317d5363d7e9a9279173b2e8930c7642e558 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 12:45:05 +0100 Subject: [PATCH 01/24] Added minor fixes for cibuildwheel config --- pyproject.toml | 5 +- setup.py | 5 +- tests/benchmarks/PkL_CLASS.dat | 159 +++++++++++++++++++++++++++++++++ tests/test_coffe.py | 33 +++---- 4 files changed, 181 insertions(+), 21 deletions(-) create mode 100644 tests/benchmarks/PkL_CLASS.dat diff --git a/pyproject.toml b/pyproject.toml index 32494c8..b9e57a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ classifiers = [ dependencies = [ "numpy>=1.19.5", ] +optional-dependencies.test = ["pytest", "pandas", "scipy"] [project.scripts] coffe-cli = "coffe.__main__:main" @@ -34,6 +35,8 @@ repository = "https://github.com/JCGoran/coffe" [tool.cibuildwheel] skip = ["cp36-*", "pp*", "pypy*", "*musllinux*"] +test-extras = ["test"] +test-command = ["pytest {package}/tests"] [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"] @@ -42,4 +45,4 @@ archs = ["x86_64", "arm64"] archs = ["x86_64"] [build-system] -requires = ["setuptools", "wheel", "Cython"] +requires = ["setuptools", "wheel", "Cython<3"] diff --git a/setup.py b/setup.py index 932ffa3..acdf806 100755 --- a/setup.py +++ b/setup.py @@ -31,8 +31,7 @@ def get_library_dirs(): extra_compile_args = [ - "-fopenmp", - "-Ofast", + "-O3", "-DHAVE_CLASS", "-DHAVE_CUBA", "-DCOFFE_CYTHON", @@ -81,9 +80,7 @@ def get_library_dirs(): "cuba", "class", ], - library_dirs=get_library_dirs(), extra_compile_args=extra_compile_args, - extra_link_args=["-fopenmp"], ), ] ), diff --git a/tests/benchmarks/PkL_CLASS.dat b/tests/benchmarks/PkL_CLASS.dat new file mode 100644 index 0000000..d77268d --- /dev/null +++ b/tests/benchmarks/PkL_CLASS.dat @@ -0,0 +1,159 @@ + 1.046002468616e-07 6.235364087170e-01 + 1.316839088540e-07 7.781293869189e-01 + 1.657802191807e-07 9.710481518263e-01 + 2.087049306994e-07 1.211799689987e+00 + 2.627439408242e-07 1.512240402026e+00 + 3.307750238985e-07 1.887186149825e+00 + 4.164210831727e-07 2.355091179122e+00 + 5.242430836130e-07 2.938987403334e+00 + 6.599829399177e-07 3.667640613187e+00 + 8.308692944130e-07 4.576937720508e+00 + 1.046002468616e-06 5.711684797774e+00 + 1.316839088540e-06 7.127797422125e+00 + 1.657802191807e-06 8.894993767927e+00 + 2.087049306994e-06 1.110039754482e+01 + 2.627439408242e-06 1.385238500634e+01 + 3.307750238985e-06 1.728689331607e+01 + 4.164210831727e-06 2.157269994273e+01 + 5.242430836129e-06 2.692138005360e+01 + 6.599829399177e-06 3.359570573321e+01 + 8.308692944130e-06 4.192510972798e+01 + 1.046002468616e-05 5.231953251804e+01 + 1.316839088540e-05 6.529098007757e+01 + 1.657802191807e-05 8.147833032282e+01 + 2.087049306994e-05 1.016787939908e+02 + 2.627439408242e-05 1.268871368768e+02 + 3.307750238985e-05 1.583445906013e+02 + 4.164210831727e-05 1.975997213788e+02 + 5.242430836130e-05 2.465842771463e+02 + 6.599829399177e-05 3.077074737843e+02 + 8.308692944130e-05 3.839729381223e+02 + 1.046002468616e-04 4.791232322596e+02 + 1.316839088540e-04 5.978175666464e+02 + 1.657802191807e-04 7.458483460835e+02 + 2.087049306994e-04 9.304015200118e+02 + 2.627439408242e-04 1.160363097424e+03 + 3.307750238985e-04 1.446668624527e+03 + 4.164210831727e-04 1.802682995344e+03 + 5.242430836130e-04 2.244585193304e+03 + 6.599829399177e-04 2.791718483337e+03 + 8.308692944130e-04 3.466843869212e+03 + 1.046002468616e-03 4.296160591409e+03 + 1.316839088540e-03 5.308791813948e+03 + 1.657802191807e-03 6.535188754858e+03 + 2.087049306994e-03 8.004803666436e+03 + 2.627439408242e-03 9.741203518106e+03 + 3.307750238985e-03 1.175527796161e+04 + 4.164210831727e-03 1.403598949228e+04 + 5.242430836130e-03 1.653770957442e+04 + 6.599829399177e-03 1.916470680453e+04 + 8.308692944130e-03 2.175693061375e+04 + 1.046002468616e-02 2.407037967204e+04 + 1.316839088540e-02 2.576916386540e+04 + 1.657802191804e-02 2.644066661190e+04 + 2.087049290115e-02 2.568269081177e+04 + 2.627426607523e-02 2.330574353176e+04 + 3.305983861456e-02 1.967028021559e+04 + 4.105589834407e-02 1.602355992606e+04 + 4.779681971948e-02 1.392626514416e+04 + 5.268562702534e-02 1.288880123643e+04 + 5.671721594501e-02 1.223759727526e+04 + 6.031687829181e-02 1.174365662217e+04 + 6.367418442744e-02 1.131141199246e+04 + 6.688946261170e-02 1.089205686404e+04 + 7.002286650976e-02 1.046031012785e+04 + 7.311390692949e-02 1.000446612186e+04 + 7.619042858984e-02 9.520258933464e+03 + 7.927320502998e-02 9.012490350506e+03 + 8.237849179503e-02 8.490012576078e+03 + 8.551953925527e-02 7.965379106689e+03 + 8.870753630877e-02 7.452866103636e+03 + 9.195222427013e-02 6.966656922411e+03 + 9.526231024366e-02 6.519762304196e+03 + 9.864575353763e-02 6.121786086448e+03 + 1.021099688283e-01 5.778453921247e+03 + 1.056619730371e-01 5.491472744261e+03 + 1.093084931093e-01 5.256628633898e+03 + 1.130560459802e-01 5.065780809561e+03 + 1.169109983473e-01 4.906439520419e+03 + 1.208796115317e-01 4.763158483537e+03 + 1.249680751995e-01 4.618879035664e+03 + 1.291825327147e-01 4.458647792313e+03 + 1.335291002364e-01 4.271387181131e+03 + 1.380138812293e-01 4.053559592995e+03 + 1.426429777658e-01 3.809515635752e+03 + 1.474224998042e-01 3.551298500134e+03 + 1.523585735031e-01 3.295395783048e+03 + 1.574573495511e-01 3.059396256620e+03 + 1.627250124421e-01 2.856661250781e+03 + 1.681677915969e-01 2.693462239672e+03 + 1.737919752073e-01 2.567549830606e+03 + 1.796039276714e-01 2.468144036854e+03 + 1.856101114764e-01 2.379834974201e+03 + 1.918171143817e-01 2.285726308966e+03 + 1.982316827589e-01 2.172737501207e+03 + 2.048607619578e-01 2.039108418104e+03 + 2.117115446000e-01 1.894369971192e+03 + 2.187915277619e-01 1.753620388901e+03 + 2.261085801025e-01 1.630316189727e+03 + 2.336710201441e-01 1.531112366691e+03 + 2.414877071275e-01 1.453842042334e+03 + 2.495681461696e-01 1.387905170938e+03 + 2.579226098714e-01 1.320134555909e+03 + 2.665622790882e-01 1.242906350006e+03 + 2.754994063270e-01 1.157703473246e+03 + 2.847475062343e-01 1.073446906898e+03 + 2.943215789532e-01 1.000161847404e+03 + 3.042383738781e-01 9.404478634107e+02 + 3.145167036585e-01 8.890953092738e+02 + 3.251778214267e-01 8.382522377623e+02 + 3.362458784590e-01 7.834337869853e+02 + 3.477484852899e-01 7.277216952219e+02 + 3.597174073793e-01 6.767921568778e+02 + 3.721894378311e-01 6.330801940196e+02 + 3.852075059997e-01 5.932430307158e+02 + 3.988221046420e-01 5.532692664077e+02 + 4.130931536463e-01 5.130955397824e+02 + 4.280924719868e-01 4.756274674146e+02 + 4.439071126178e-01 4.417256922022e+02 + 4.606439469169e-01 4.095987886090e+02 + 4.784361004430e-01 3.778085203090e+02 + 4.974522035406e-01 3.475017783359e+02 + 5.179100495760e-01 3.193258926116e+02 + 5.400973908098e-01 2.919260169042e+02 + 5.644047482072e-01 2.653798353486e+02 + 5.913793669410e-01 2.399835927855e+02 + 6.218183726548e-01 2.150674574747e+02 + 6.569391134310e-01 1.906853493852e+02 + 6.987123569887e-01 1.663926167344e+02 + 7.505660696221e-01 1.418939207055e+02 + 8.189917989690e-01 1.166537176031e+02 + 9.173402034529e-01 9.018541068760e+01 + 1.072860309668e+00 6.291194875862e+01 + 1.320414800762e+00 3.871991604207e+01 + 1.659546108755e+00 2.247636909241e+01 + 2.089192449348e+00 1.287803244810e+01 + 2.630137270126e+00 7.317815913718e+00 + 3.311146645767e+00 4.127008815959e+00 + 4.168486654533e+00 2.311755560598e+00 + 5.247813778117e+00 1.287002807355e+00 + 6.606606121635e+00 7.124349059768e-01 + 8.317224332241e+00 3.923399364081e-01 + 1.047076506745e+01 2.150334916342e-01 + 1.318191222434e+01 1.173322685326e-01 + 1.659504427526e+01 6.375816692002e-02 + 2.089192294798e+01 3.451098286821e-02 + 2.630137270045e+01 1.861093164120e-02 + 3.311146645767e+01 9.999853410280e-03 + 4.168486654533e+01 5.353185944966e-03 + 5.247813778117e+01 2.854539593210e-03 + 6.606606121635e+01 1.515512297386e-03 + 8.317224332241e+01 8.004430803193e-04 + 1.047076506745e+02 4.199626525805e-04 + 1.318191222434e+02 2.184026684970e-04 + 1.659504427526e+02 1.122067043641e-04 + 2.089192294798e+02 5.668850302366e-05 + 2.630137270045e+02 2.800241111863e-05 + 3.311146645767e+02 1.344544980356e-05 + 4.168486654533e+02 6.260444081632e-06 + 5.247813778117e+02 2.845605974333e-06 diff --git a/tests/test_coffe.py b/tests/test_coffe.py index ef479f7..7e56053 100644 --- a/tests/test_coffe.py +++ b/tests/test_coffe.py @@ -1,18 +1,19 @@ """ Tests for the Python wrapper of COFFE. """ - from pathlib import Path import numpy as np import pandas as pd import pytest -from coffe import Coffe, Multipoles +from coffe import Coffe +from coffe import Multipoles from coffe.representation import Representation -from coffe_utils import average_covariance_matrix, covariance_matrix +from coffe_utils import average_covariance_matrix +from coffe_utils import covariance_matrix -DATA_DIR = Path("tests/benchmarks/") +DATA_DIR = Path(__file__).parent / "benchmarks/" h = 0.67 COFFE_H0 = 1 / 2997.92458 @@ -119,7 +120,7 @@ def test_parameters(self): def test_power_spectrum(self): cosmo = Coffe() - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -130,7 +131,7 @@ def test_power_spectrum(self): def test_cross_spectrum(self): cosmo = Coffe() - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -195,7 +196,7 @@ def test_background(self): def test_integrals(self): cosmo = Coffe() - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -238,7 +239,7 @@ def test_corrfunc(self): mu=[0.0, 0.2, 0.5, 0.8, 0.95], ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 contributions = { @@ -273,7 +274,7 @@ def test_multipoles(self): l=[0, 2, 4], ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -310,7 +311,7 @@ def test_average_multipoles(self): z_max=[1.1], ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -331,7 +332,7 @@ def test_multipoles_flat_lensing_lensing(self): l=[0, 2, 4], ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -357,7 +358,7 @@ def test_multipoles_flat_density_lensing(self): l=[0, 2, 4], ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -393,7 +394,7 @@ def test_covariance_multipoles(self): l=[0, 2, 4], ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -445,7 +446,7 @@ def test_average_covariance_multipoles(self): l=[0, 2, 4], ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -513,7 +514,7 @@ def test_multiple_populations(self): covariance_poisson=False, ) - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) k, pk = k * h, pk / h**3 cosmo.set_power_spectrum_linear(k, pk) @@ -524,7 +525,7 @@ def test_multiple_populations(self): # only Poisson contribution cosmo.covariance_poisson = True - k, pk = np.transpose(np.loadtxt("PkL_CLASS.dat")) + k, pk = np.transpose(np.loadtxt(DATA_DIR / "PkL_CLASS.dat")) cosmo.set_power_spectrum_linear(k, pk) cov = covariance_matrix(cosmo.compute_covariance_bulk()) From f6757e7eb17a4b725a0446bf11832c39c34b07c8 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 14:30:40 +0100 Subject: [PATCH 02/24] Added fixes for building wheels * simplified build structure * moved most of requirements to pyproject * removed unused submodules --- .gitmodules | 8 --- build_sdist.sh | 7 --- build_wheels_linux.sh | 11 ---- build_wheels_linux_manylinux2014.sh | 15 ------ build_wheels_linux_manylinux_2_24.sh | 9 ---- build_wheels_linux_manylinux_2_28.sh | 8 --- class_public | 1 - install | 20 ------- install_other.sh | 81 +++++++++++++++------------- libcuba | 1 - pip-requirements.txt | 1 - pyproject.toml | 8 ++- reinstall.sh | 10 ---- src/background.h | 1 + src/covariance.h | 1 + src/integrals.h | 3 ++ 16 files changed, 56 insertions(+), 129 deletions(-) delete mode 100755 build_sdist.sh delete mode 100755 build_wheels_linux.sh delete mode 100755 build_wheels_linux_manylinux2014.sh delete mode 100755 build_wheels_linux_manylinux_2_24.sh delete mode 100755 build_wheels_linux_manylinux_2_28.sh delete mode 160000 class_public delete mode 100755 install delete mode 160000 libcuba delete mode 100644 pip-requirements.txt delete mode 100755 reinstall.sh diff --git a/.gitmodules b/.gitmodules index 8781a45..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +0,0 @@ -[submodule "class_public"] - path = class_public - url = https://github.com/JCGoran/class_public - branch = feature/conda -[submodule "libcuba"] - path = libcuba - url = https://github.com/JCGoran/libcuba - branch = master diff --git a/build_sdist.sh b/build_sdist.sh deleted file mode 100755 index 3cb4421..0000000 --- a/build_sdist.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env sh - -set -eux - -python3 -m build --sdist - -set +eux diff --git a/build_wheels_linux.sh b/build_wheels_linux.sh deleted file mode 100755 index 58a35d8..0000000 --- a/build_wheels_linux.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env sh - -set -eux -# script for building multiple manylinux images - -# by default we build the manylinux2014 wheel -CIBW_BEFORE_ALL="sh build_wheels_linux_${1:-manylinux2014}.sh" \ - CIBW_MANYLINUX_X86_64_IMAGE="${1:-manylinux2014}" \ - cibuildwheel --platform linux - -set +eux diff --git a/build_wheels_linux_manylinux2014.sh b/build_wheels_linux_manylinux2014.sh deleted file mode 100755 index b2e1d45..0000000 --- a/build_wheels_linux_manylinux2014.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env sh -set -eux - -# we need to build GSL from source as the one in the repos is too old (need -# version 2.1 for 2D interpolation) -GSL_VERSION="2.0" - -curl -sL -vvv https://ftp.gnu.org/gnu/gsl/gsl-${GSL_VERSION}.tar.gz --output libgsl.tar.gz -tar xf libgsl.tar.gz -(cd gsl-${GSL_VERSION} && ./autogen.sh && ./configure && make && make install) -yum install -y fftw-devel -git submodule update --init --recursive -git submodule foreach 'sh install.sh' - -set +eux diff --git a/build_wheels_linux_manylinux_2_24.sh b/build_wheels_linux_manylinux_2_24.sh deleted file mode 100755 index 5994c5e..0000000 --- a/build_wheels_linux_manylinux_2_24.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env sh -set -eux - -apt-get update -apt-get install -y libgsl-dev libfftw3-dev -git submodule update --init --recursive -git submodule foreach 'sh install.sh' - -set +eux diff --git a/build_wheels_linux_manylinux_2_28.sh b/build_wheels_linux_manylinux_2_28.sh deleted file mode 100755 index b9e88d6..0000000 --- a/build_wheels_linux_manylinux_2_28.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh -set -eux - -yum install -y gsl-devel fftw-devel -git submodule update --init --recursive -git submodule foreach 'sh install.sh' - -set +eux diff --git a/class_public b/class_public deleted file mode 160000 index 8efeba0..0000000 --- a/class_public +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8efeba01ab61aaf56879f8d4b1264f6c977a4874 diff --git a/install b/install deleted file mode 100755 index 062a944..0000000 --- a/install +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh - -# THIS IS THE ONLY SCRIPT YOU NEED TO RUN TO INSTALL COFFE - -set -eux - -# in case of no conda env, we just install the Python-specific requirements -if [ -z "${CONDA_PREFIX-}" ] && [ -z "${CONDA_DEFAULT_ENV-}" ] -then - python3 -m pip install Cython wheel -# otherwise, we need to install all of the requirements (compiler, GSL lib, etc.) -else - conda install --channel conda-forge --file requirements.txt -fi - -git submodule update --init --recursive -git submodule foreach './install.sh' -sh reinstall.sh - -set +eux diff --git a/install_other.sh b/install_other.sh index b02ef09..b2d62d8 100755 --- a/install_other.sh +++ b/install_other.sh @@ -1,52 +1,61 @@ #!/usr/bin/env sh -set -e -# installer for CLASS when using a conda environment -CLASS_DIR="class_public" +set -ex + +CLASS_INSTALL_DIR="/opt/class_public" CLASS_REMOTE_URL="https://github.com/JCGoran/class_public" CLASS_BRANCH="feature/conda" -CUBA_DIR="cuba" +CUBA_INSTALL_DIR="/opt/cuba" CUBA_REMOTE_URL="https://github.com/JCGoran/libcuba" CUBA_BRANCH="master" install_cuba(){ - if [ -z "${CONDA_PREFIX}" ] - then - printf 'You need to activate a conda environment using `conda activate [ENVIRONMENT]` before running this script\n' - return 1 - fi - - if [ ! -d "${CUBA_DIR}" ] - then - printf 'Attempting to install CUBA in the current environment (%s)...\n' "${CONDA_DEFAULT_ENV}" - printf 'Cloning to directory %s...\n' "${CUBA_DIR}" - git clone --branch "${CUBA_BRANCH}" "${CUBA_REMOTE_URL}" "${CUBA_DIR}" - fi - - cd "${CUBA_DIR}" && autoreconf --install && ./configure --prefix="${CONDA_PREFIX}" CFLAGS=-fPIC && make install && cd - - printf 'CUBA successfully installed\n' + cuba_dir="$(mktemp -d)" + git clone --depth 1 --branch "${CUBA_BRANCH}" "${CUBA_REMOTE_URL}" "${cuba_dir}" + + cd "${cuba_dir}" + autoreconf --install + ./configure --prefix="${CUBA_INSTALL_DIR}" CFLAGS=-fPIC + make install + cd - + printf 'CUBA installed\n' } install_class(){ - if [ -z "${CONDA_PREFIX}" ] - then - printf 'You need to activate a conda environment using `conda activate [ENVIRONMENT]` before running this script\n' - return 1 - fi - - if [ ! -d "${CLASS_DIR}" ] - then - printf 'Attempting to install CLASS in the current environment (%s)...\n' "${CONDA_DEFAULT_ENV}" - printf 'Cloning to directory %s...\n' "${CLASS_DIR}" - git clone --branch "${CLASS_BRANCH}" "${CLASS_REMOTE_URL}" "${CLASS_DIR}" - fi - - make -C "${CLASS_DIR}" libclass.a && cp -a "${CLASS_DIR}/libclass.a" "${CONDA_PREFIX}/lib/" && cp -a "${CLASS_DIR}/include/"*.h "${CONDA_PREFIX}/include/" - printf 'CLASS successfully installed\n' + class_dir="$(mktemp -d)" + git clone --depth 1 --branch "${CLASS_BRANCH}" "${CLASS_REMOTE_URL}" "${class_dir}" + + cd "${class_dir}" + make libclass.a + mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" + cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" + cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" + cd - + printf 'CLASS installed\n' +} + +install_fftw(){ + yum install -y fftw-devel } -install_cuba && install_class -set +e +install_gsl(){ + GSL_VERSION='2.0' + curl -sL -vvv "https://ftp.gnu.org/gnu/gsl/gsl-${GSL_VERSION}.tar.gz" --output libgsl.tar.gz + tar xf libgsl.tar.gz + cd "gsl-${GSL_VERSION}" + ./autogen.sh + ./configure + make -j 2 all + make install + cd - +} + +install_gsl +install_class +install_fftw +install_cuba + +set +ex diff --git a/libcuba b/libcuba deleted file mode 160000 index 687b7f3..0000000 --- a/libcuba +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 687b7f3b089eda4d9fc44edc7b2d3c58a4e7f21c diff --git a/pip-requirements.txt b/pip-requirements.txt deleted file mode 100644 index 24ce15a..0000000 --- a/pip-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -numpy diff --git a/pyproject.toml b/pyproject.toml index b9e57a5..1442834 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,10 +39,14 @@ test-extras = ["test"] test-command = ["pytest {package}/tests"] [tool.cibuildwheel.macos] -archs = ["x86_64", "arm64"] [tool.cibuildwheel.linux] -archs = ["x86_64"] +before-all = [ + # install CUBA, FFTW, GSL, and CLASS + "bash install_other.sh", +] +environment = { LDFLAGS="-L/opt/cuba/lib -L/opt/class_public/lib ${LDFLAGS}", CFLAGS="-I/opt/cuba/include -I/opt/class_public/include ${CFLAGS}" } + [build-system] requires = ["setuptools", "wheel", "Cython<3"] diff --git a/reinstall.sh b/reinstall.sh deleted file mode 100755 index df8dc47..0000000 --- a/reinstall.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env sh - -# This script is used to rebuild COFFE is changes are made to the source files - -set -eux - -python3 -m pip install . -python3 setup.py build_ext -i - -set +eux diff --git a/src/background.h b/src/background.h index 5ccf121..ba44d01 100644 --- a/src/background.h +++ b/src/background.h @@ -19,6 +19,7 @@ #ifndef COFFE_BACKGROUND_H #define COFFE_BACKGROUND_H +#include "common.h" typedef struct coffe_background_t { diff --git a/src/covariance.h b/src/covariance.h index ab1d6ce..b23f427 100644 --- a/src/covariance.h +++ b/src/covariance.h @@ -19,6 +19,7 @@ #ifndef COFFE_COVARIANCE #define COFFE_COVARIANCE +#include "background.h" #include "common.h" typedef struct coffe_covariance_t diff --git a/src/integrals.h b/src/integrals.h index a4c83f3..1aa5e68 100644 --- a/src/integrals.h +++ b/src/integrals.h @@ -19,6 +19,9 @@ #ifndef COFFE_INTEGRALS_H #define COFFE_INTEGRALS_H +#include "common.h" +#include "background.h" + /* for detection of half integers (spherical (int) vs. ordinary Bessel (half-int) functions) */ enum coffe_integer_state {COFFE_INTEGER, COFFE_HALF_INTEGER}; From 4d0ec2e4782ee6745a267b1222b5367986557159 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 18:19:18 +0100 Subject: [PATCH 03/24] More changes for CIBW to work --- .github/workflows/build-wheels.yml | 62 +++++++++++++++++++ Dockerfile | 57 ----------------- generate_docs.sh | 9 --- pyproject.toml | 22 +++++-- scripts/Dockerfile | 5 ++ .../generate_defaults.py | 0 scripts/generate_docs.sh | 14 +++++ install_other.sh => scripts/install_other.sh | 0 8 files changed, 98 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/build-wheels.yml delete mode 100644 Dockerfile delete mode 100755 generate_docs.sh create mode 100644 scripts/Dockerfile rename generate_defaults.py => scripts/generate_defaults.py (100%) create mode 100755 scripts/generate_docs.sh rename install_other.sh => scripts/install_other.sh (100%) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml new file mode 100644 index 0000000..c2244a5 --- /dev/null +++ b/.github/workflows/build-wheels.yml @@ -0,0 +1,62 @@ +name: Build + +on: + pull_request: + push: + branches: + - master + workflow_dispatch: + inputs: + version: + description: 'The version of COFFE to release' + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + + - name: Setup all external dependencies + if: runner.os == 'macOS' + run: | + brew install fftw gsl cuba automake jq + if [ "$(uname -m)" = 'arm64' ] + then + echo "BREW_PREFIX=/opt/homebrew/Cellar/" >> "$GITHUB_ENV" + else + echo "BREW_PREFIX=/usr/local/Cellar/" >> "$GITHUB_ENV" + fi + echo "GSL_VERSION=$(brew info --json gsl | jq -r '.[0].installed[0].version')" >> "$GITHUB_ENV" + echo "FFTW_VERSION=$(brew info --json fftw | jq -r '.[0].installed[0].version')" >> "$GITHUB_ENV" + echo "CUBA_VERSION=$(brew info --json cuba | jq -r '.[0].installed[0].version')" >> "$GITHUB_ENV" + + # Used to host cibuildwheel + - uses: actions/setup-python@v3 + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.16.5 + + # if we're not doing a release version (manual!), only build one python version + - name: Setup versions + if: !(github.event_name == 'workflow_dispatch' && github.event.inputs.version) + run: echo "CIBW_BUILD='cp311-*'" >> "$GITHUB_ENV" + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + # to supply options, put them in 'env', like: + env: + # we skip tests in CI to save time + CIBW_TEST_COMMAND: 'true' + CIBW_ENVIRONMENT_MACOS: > + CFLAGS="-I${BREW_PREFIX}/gsl/${GSL_VERSION}/include -I${BREW_PREFIX}/fftw/${FFTW_VERSION}/include -I${BREW_PREFIX}/cuba/${CUBA_VERSION}/include ${CFLAGS}" + LDFLAGS="-L${BREW_PREFIX}/gsl/${GSL_VERSION}/lib -L${BREW_PREFIX}/fftw/${FFTW_VERSION}/lib -L${BREW_PREFIX}/cuba/${CUBA_VERSION}/lib ${LDFLAGS}" + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 8647001..0000000 --- a/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -# NOTE: if you are building this on your system and are not pulling from Dockerhub, -# a lot or warnings may be displayed; to turn them off, use "docker build -q [PATH]", -# where [PATH] is the location of this Dockerfile; -# most are harmless and do not affect the outcome of the build -FROM gcc:8 -MAINTAINER Goran Jelic-Cizmek "goran.jelic-cizmek@unige.ch" -# get all the standard required libraries -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - autoconf-archive git \ - libconfig-dev \ - libgsl-dev \ - libfftw3-dev \ - python3-pip \ - python3-setuptools \ - python3-wheel \ - wget && \ - apt-get clean && apt-get autoremove -y -# get CUBA and build it -WORKDIR /tmp/ -RUN wget http://www.feynarts.de/cuba/Cuba-4.2.tar.gz -RUN tar xf /tmp/Cuba-4.2.tar.gz -C /tmp/ -WORKDIR /tmp/Cuba-4.2/ -RUN ./configure -RUN make -j lib -RUN make install -RUN rm -rf /tmp/Cuba* -# get CLASS and set it up -WORKDIR /tmp/ -# CLASS has a small bug when using the static library, -# see https://github.com/lesgourg/class_public/issues/255 for details, -# which was fixed in the fork -RUN git clone -b master --single-branch https://github.com/lesgourg/class_public class -WORKDIR /tmp/class/ -RUN make -j libclass.a -RUN cp libclass.a /usr/lib/x86_64-linux-gnu/ -RUN cp include/*.h /usr/include/ -# get COFFE and set it up -WORKDIR / -RUN git clone -q https://github.com/JCGoran/coffe -WORKDIR /coffe/ -# this is necessary as long as the future branch isn't merged into master -RUN git checkout future -RUN autoreconf -i -RUN ./configure --enable-cuba --enable-class -RUN make -j coffe -# optional dependencies for making life easier -RUN pip3 install \ - wheel \ - numpy \ - scipy \ - matplotlib \ - jupyter -# installing dependencies for COFFE python "wrapper" -RUN pip3 install -r python/requirements.txt -RUN ln -s /coffe/coffe /usr/bin/coffe -WORKDIR /data/ diff --git a/generate_docs.sh b/generate_docs.sh deleted file mode 100755 index 981eb73..0000000 --- a/generate_docs.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env sh - -set -eux - -python3 -m pdoc --docformat numpy --math -o docs/ coffe - -printf "Docs generated at: %s\n" "${PWD}/docs/index.html" - -set +eux diff --git a/pyproject.toml b/pyproject.toml index 1442834..48419ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,17 @@ dependencies = [ "numpy>=1.19.5", ] optional-dependencies.test = ["pytest", "pandas", "scipy"] +optional-dependencies.docs = ["pdoc"] +optional-dependencies.dev = [ + "pylint", + "mypy", + "isort", + "reorder-python-imports", + "autoimport", + "black", + "cibuildwheel", + "twine", +] [project.scripts] coffe-cli = "coffe.__main__:main" @@ -35,15 +46,16 @@ repository = "https://github.com/JCGoran/coffe" [tool.cibuildwheel] skip = ["cp36-*", "pp*", "pypy*", "*musllinux*"] -test-extras = ["test"] -test-command = ["pytest {package}/tests"] - -[tool.cibuildwheel.macos] +test-extras = ["test", "docs"] +test-command = [ + "pytest {package}/tests", + "bash {package}/scripts/generate_docs.sh", +] [tool.cibuildwheel.linux] before-all = [ # install CUBA, FFTW, GSL, and CLASS - "bash install_other.sh", + "bash scripts/install_other.sh", ] environment = { LDFLAGS="-L/opt/cuba/lib -L/opt/class_public/lib ${LDFLAGS}", CFLAGS="-I/opt/cuba/include -I/opt/class_public/include ${CFLAGS}" } diff --git a/scripts/Dockerfile b/scripts/Dockerfile new file mode 100644 index 0000000..7235c2c --- /dev/null +++ b/scripts/Dockerfile @@ -0,0 +1,5 @@ +ARG MANYLINUX_IMAGE=manylinux2014_x86_64 +FROM quay.io/pypa/$MANYLINUX_IMAGE +LABEL author="Goran Jelic-Cizmek" + +bash install_other.sh diff --git a/generate_defaults.py b/scripts/generate_defaults.py similarity index 100% rename from generate_defaults.py rename to scripts/generate_defaults.py diff --git a/scripts/generate_docs.sh b/scripts/generate_docs.sh new file mode 100755 index 0000000..c6a575a --- /dev/null +++ b/scripts/generate_docs.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +set -eux + +script_dir="$(realpath "$(dirname "$0")")" +cd "${script_dir}" + +python3 -m pdoc --docformat numpy --math -o "${script_dir}/../docs/" coffe + +cd - + +printf "Docs generated at: %s\n" "$(realpath "${script_dir}/../docs/index.html")" + +set +eux diff --git a/install_other.sh b/scripts/install_other.sh similarity index 100% rename from install_other.sh rename to scripts/install_other.sh From c0b61f8f407d9ef3037086b943efda9784f4c58a Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 18:51:41 +0100 Subject: [PATCH 04/24] Use setuptools_scm for setting version --- pyproject.toml | 6 ++++-- setup.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 48419ac..f09a691 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "coffe" -version = "3.0.0" +dynamic = ["version"] description = "Python wrapper for the COrrelation Function Full-sky Estimator code" readme = "README.md" requires-python = ">=3.7" @@ -61,4 +61,6 @@ environment = { LDFLAGS="-L/opt/cuba/lib -L/opt/class_public/lib ${LDFLAGS}", CF [build-system] -requires = ["setuptools", "wheel", "Cython<3"] +requires = ["setuptools", "wheel", "Cython<3", "setuptools_scm"] + +[tool.setuptools_scm] diff --git a/setup.py b/setup.py index acdf806..c5c92fa 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,6 @@ def get_library_dirs(): setup( name="coffe", - version="3.0.0", url="https://github.com/JCGoran/coffe", author="Goran Jelic-Cizmek", author_email="goran.jelic-cizmek@unige.ch", From 53c4b6080066567f1543426eec1bd57e3e8851c4 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 18:54:59 +0100 Subject: [PATCH 05/24] Update CI file --- .github/workflows/build-wheels.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index c2244a5..f48dbe2 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -46,12 +46,17 @@ jobs: if: !(github.event_name == 'workflow_dispatch' && github.event.inputs.version) run: echo "CIBW_BUILD='cp311-*'" >> "$GITHUB_ENV" + - name: SCM + if: github.event_name == 'workflow_dispatch' && github.event.inputs.version + run: echo "SETUPTOOLS_SCM_PRETEND_VERSION='${{ github.event.input.version }}'" >> "$GITHUB_ENV" + - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse # to supply options, put them in 'env', like: env: # we skip tests in CI to save time CIBW_TEST_COMMAND: 'true' + CIBW_ENVIRONMENT_PASS_LINUX: 'SETUPTOOLS_SCM_PRETEND_VERSION' CIBW_ENVIRONMENT_MACOS: > CFLAGS="-I${BREW_PREFIX}/gsl/${GSL_VERSION}/include -I${BREW_PREFIX}/fftw/${FFTW_VERSION}/include -I${BREW_PREFIX}/cuba/${CUBA_VERSION}/include ${CFLAGS}" LDFLAGS="-L${BREW_PREFIX}/gsl/${GSL_VERSION}/lib -L${BREW_PREFIX}/fftw/${FFTW_VERSION}/lib -L${BREW_PREFIX}/cuba/${CUBA_VERSION}/lib ${LDFLAGS}" From 31258b5263799817f033b5a725d8d2e96b77bad8 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 18:58:53 +0100 Subject: [PATCH 06/24] Fix CI file? --- .github/workflows/build-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index f48dbe2..e22dcc3 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -43,7 +43,7 @@ jobs: # if we're not doing a release version (manual!), only build one python version - name: Setup versions - if: !(github.event_name == 'workflow_dispatch' && github.event.inputs.version) + if: ! ${{ github.event_name == 'workflow_dispatch' }} && ${{ github.event.inputs.version }} run: echo "CIBW_BUILD='cp311-*'" >> "$GITHUB_ENV" - name: SCM From f4d0a7335f180b1a8bfae0360ccfe03325205ba1 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 19:00:14 +0100 Subject: [PATCH 07/24] Fix --- .github/workflows/build-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index e22dcc3..3889217 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -43,7 +43,7 @@ jobs: # if we're not doing a release version (manual!), only build one python version - name: Setup versions - if: ! ${{ github.event_name == 'workflow_dispatch' }} && ${{ github.event.inputs.version }} + if: ${{ ! (github.event_name == 'workflow_dispatch' && github.event.inputs.version) }} run: echo "CIBW_BUILD='cp311-*'" >> "$GITHUB_ENV" - name: SCM From 9ca4d406ca0b4da60f0dd812063db36f1da533f5 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 19:01:30 +0100 Subject: [PATCH 08/24] Fix build specifier --- .github/workflows/build-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 3889217..f9df69c 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -44,7 +44,7 @@ jobs: # if we're not doing a release version (manual!), only build one python version - name: Setup versions if: ${{ ! (github.event_name == 'workflow_dispatch' && github.event.inputs.version) }} - run: echo "CIBW_BUILD='cp311-*'" >> "$GITHUB_ENV" + run: echo "CIBW_BUILD=cp311-*" >> "$GITHUB_ENV" - name: SCM if: github.event_name == 'workflow_dispatch' && github.event.inputs.version From ccb77c0c98b6791eb3ed143533739098e1e17ee9 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 20:41:55 +0100 Subject: [PATCH 09/24] Fixes for CI also make install script more flexible --- .github/workflows/build-wheels.yml | 13 +++++++++---- pyproject.toml | 2 +- scripts/install_other.sh | 23 +++++++++++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index f9df69c..83242d1 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -44,11 +44,14 @@ jobs: # if we're not doing a release version (manual!), only build one python version - name: Setup versions if: ${{ ! (github.event_name == 'workflow_dispatch' && github.event.inputs.version) }} - run: echo "CIBW_BUILD=cp311-*" >> "$GITHUB_ENV" + run: | + echo "CIBW_BUILD=cp311-*" >> "$GITHUB_ENV" + # pretend version so setuptools doesn't fail + echo "SETUPTOOLS_SCM_PRETEND_VERSION=0.1.0" >> "$GITHUB_ENV" - name: SCM if: github.event_name == 'workflow_dispatch' && github.event.inputs.version - run: echo "SETUPTOOLS_SCM_PRETEND_VERSION='${{ github.event.input.version }}'" >> "$GITHUB_ENV" + run: echo "SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.event.input.version }}" >> "$GITHUB_ENV" - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse @@ -57,9 +60,11 @@ jobs: # we skip tests in CI to save time CIBW_TEST_COMMAND: 'true' CIBW_ENVIRONMENT_PASS_LINUX: 'SETUPTOOLS_SCM_PRETEND_VERSION' + CIBW_BEFORE_ALL_MACOS: > + bash scripts/install_other.sh class CIBW_ENVIRONMENT_MACOS: > - CFLAGS="-I${BREW_PREFIX}/gsl/${GSL_VERSION}/include -I${BREW_PREFIX}/fftw/${FFTW_VERSION}/include -I${BREW_PREFIX}/cuba/${CUBA_VERSION}/include ${CFLAGS}" - LDFLAGS="-L${BREW_PREFIX}/gsl/${GSL_VERSION}/lib -L${BREW_PREFIX}/fftw/${FFTW_VERSION}/lib -L${BREW_PREFIX}/cuba/${CUBA_VERSION}/lib ${LDFLAGS}" + CFLAGS="-I${BREW_PREFIX}/gsl/${GSL_VERSION}/include -I${BREW_PREFIX}/fftw/${FFTW_VERSION}/include -I${BREW_PREFIX}/cuba/${CUBA_VERSION}/include -I/opt/class_public/include ${CFLAGS}" + LDFLAGS="-L${BREW_PREFIX}/gsl/${GSL_VERSION}/lib -L${BREW_PREFIX}/fftw/${FFTW_VERSION}/lib -L${BREW_PREFIX}/cuba/${CUBA_VERSION}/lib -L/opt/class_public/lib ${LDFLAGS}" - uses: actions/upload-artifact@v4 with: diff --git a/pyproject.toml b/pyproject.toml index f09a691..3cd92f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ test-command = [ [tool.cibuildwheel.linux] before-all = [ # install CUBA, FFTW, GSL, and CLASS - "bash scripts/install_other.sh", + "bash scripts/install_other.sh gsl cuba class fftw", ] environment = { LDFLAGS="-L/opt/cuba/lib -L/opt/class_public/lib ${LDFLAGS}", CFLAGS="-I/opt/cuba/include -I/opt/class_public/include ${CFLAGS}" } diff --git a/scripts/install_other.sh b/scripts/install_other.sh index b2d62d8..7ae2162 100755 --- a/scripts/install_other.sh +++ b/scripts/install_other.sh @@ -53,9 +53,24 @@ install_gsl(){ cd - } -install_gsl -install_class -install_fftw -install_cuba +for arg in $@ +do + case "${arg}" in + "gsl") + install_gsl + ;; + "cuba") + install_cuba + ;; + "class") + install_class + ;; + "fftw") + install_fftw + ;; + *) + ;; + esac +done set +ex From dba8601683207eb3bb2e582db44cf370e683fc86 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 23:31:43 +0100 Subject: [PATCH 10/24] Use sudo --- scripts/install_other.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install_other.sh b/scripts/install_other.sh index 7ae2162..d5dac70 100755 --- a/scripts/install_other.sh +++ b/scripts/install_other.sh @@ -30,9 +30,9 @@ install_class(){ cd "${class_dir}" make libclass.a - mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" - cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" - cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" + sudo mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" + sudo cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" + sudo cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" cd - printf 'CLASS installed\n' } From 3ec979e6a754e205b3a788c5434aed9260a04fa2 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sat, 24 Feb 2024 23:37:21 +0100 Subject: [PATCH 11/24] Removed useless requirements files --- pip-requirements-dev.txt | 12 ------------ requirements.txt | 9 --------- 2 files changed, 21 deletions(-) delete mode 100644 pip-requirements-dev.txt delete mode 100644 requirements.txt diff --git a/pip-requirements-dev.txt b/pip-requirements-dev.txt deleted file mode 100644 index 6ace6a5..0000000 --- a/pip-requirements-dev.txt +++ /dev/null @@ -1,12 +0,0 @@ -pdoc -scipy -pandas -pylint -pytest -mypy -isort -reorder-python-imports -autoimport -black -cibuildwheel -twine diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 4f985f8..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -c-compiler -gsl -fftw -make -automake -autoconf -autoconf-archive -cython -libconfig From 83abcbd01efe89dcad8988ba2cd30e4a8b7e07b4 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 20:28:26 +0100 Subject: [PATCH 12/24] Updated CI for docs --- .github/workflows/build-docs.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index f6c7d47..1401809 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -20,19 +20,14 @@ jobs: with: python-version: 3.9 - - name: Install Poetry - uses: snok/install-poetry@v1 - - name: Install dependencies run: | - python3 -m pip install coffe - python3 -m pip install -r pip-requirements-dev.txt + python3 -m pip install .[docs] # Build the site - name: Build the site run: | - rm -fr coffe/__init__.py - sh generate_docs.sh + bash scripts/generate_docs.sh # If we've pushed to master, push the book's HTML to github-pages - if: ${{ github.ref == 'refs/heads/master' }} From 547079dec6420cf47edc5ccc6d3249e2ab1f223b Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 20:40:11 +0100 Subject: [PATCH 13/24] Fix Dockerfile --- scripts/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 7235c2c..af4867a 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -2,4 +2,5 @@ ARG MANYLINUX_IMAGE=manylinux2014_x86_64 FROM quay.io/pypa/$MANYLINUX_IMAGE LABEL author="Goran Jelic-Cizmek" -bash install_other.sh +COPY install_other.sh . +RUN bash install_other.sh cuba gsl class fftw From 187d26f028371e95e376322bcf08b3c79577386f Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 20:42:43 +0100 Subject: [PATCH 14/24] Fix install_other.sh script --- scripts/install_other.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/install_other.sh b/scripts/install_other.sh index d5dac70..e8e62f6 100755 --- a/scripts/install_other.sh +++ b/scripts/install_other.sh @@ -30,9 +30,16 @@ install_class(){ cd "${class_dir}" make libclass.a - sudo mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" - sudo cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" - sudo cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" + if [ "$(python3.9 -c 'import sys;print(sys.platform)')" = 'darwin' ] + then + sudo_cmd="sudo" + else + # the manylinux container does not have sudo + sudo_cmd='' + fi + ${sudo_cmd} mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" + ${sudo_cmd} cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" + ${sudo_cmd} cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" cd - printf 'CLASS installed\n' } From 692fa43c6a9958f240ee50db0e7cf5cc7616a9a8 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 20:43:00 +0100 Subject: [PATCH 15/24] Fix setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index c5c92fa..a47ffb2 100755 --- a/setup.py +++ b/setup.py @@ -79,6 +79,7 @@ def get_library_dirs(): "cuba", "class", ], + library_dirs=get_library_dirs(), extra_compile_args=extra_compile_args, ), ] From 478688d918920082132ba08d63773c66410afe88 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 20:48:42 +0100 Subject: [PATCH 16/24] Fix docs building CI --- .github/workflows/build-docs.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 1401809..4086cca 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -22,7 +22,12 @@ jobs: - name: Install dependencies run: | - python3 -m pip install .[docs] + python3 -m pip install cibuildwheel + export CIBW_BUILD='cp39-*' + export SETUPTOOLS_SCM_PRETEND_VERSION='3.0.1' + export CIBW_ENVIRONMENT_PASS_LINUX='SETUPTOOLS_SCM_PRETEND_VERSION' + python3 -m cibuildwheel --platform linux + python3 -m pip install wheelhouse/*.whl # Build the site - name: Build the site From 3dc89bf421d9a7cece900c83866cd8e7d81b4c4e Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 21:00:29 +0100 Subject: [PATCH 17/24] Fix docs building CI --- .github/workflows/build-docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 4086cca..743cb43 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -26,6 +26,7 @@ jobs: export CIBW_BUILD='cp39-*' export SETUPTOOLS_SCM_PRETEND_VERSION='3.0.1' export CIBW_ENVIRONMENT_PASS_LINUX='SETUPTOOLS_SCM_PRETEND_VERSION' + export CIBW_TEST_COMMAND='true' python3 -m cibuildwheel --platform linux python3 -m pip install wheelhouse/*.whl From 4bbddd69818f204260ab87f71eaddc9c094b6ebd Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 21:03:18 +0100 Subject: [PATCH 18/24] Revert "Fix install_other.sh script" This reverts commit 187d26f028371e95e376322bcf08b3c79577386f. --- scripts/install_other.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/scripts/install_other.sh b/scripts/install_other.sh index e8e62f6..d5dac70 100755 --- a/scripts/install_other.sh +++ b/scripts/install_other.sh @@ -30,16 +30,9 @@ install_class(){ cd "${class_dir}" make libclass.a - if [ "$(python3.9 -c 'import sys;print(sys.platform)')" = 'darwin' ] - then - sudo_cmd="sudo" - else - # the manylinux container does not have sudo - sudo_cmd='' - fi - ${sudo_cmd} mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" - ${sudo_cmd} cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" - ${sudo_cmd} cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" + sudo mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" + sudo cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" + sudo cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" cd - printf 'CLASS installed\n' } From 3f09617b18bfe9af6b0eeb479bec43946ace79d9 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 21:07:17 +0100 Subject: [PATCH 19/24] Maybe fixed now? --- .github/workflows/build-docs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 743cb43..515335c 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -23,11 +23,10 @@ jobs: - name: Install dependencies run: | python3 -m pip install cibuildwheel - export CIBW_BUILD='cp39-*' export SETUPTOOLS_SCM_PRETEND_VERSION='3.0.1' export CIBW_ENVIRONMENT_PASS_LINUX='SETUPTOOLS_SCM_PRETEND_VERSION' export CIBW_TEST_COMMAND='true' - python3 -m cibuildwheel --platform linux + CIBW_BUILD='cp39-manylinux_x86_64' python3 -m cibuildwheel --platform linux python3 -m pip install wheelhouse/*.whl # Build the site From 71b3ea0003a95d5f12710d116441698ea2f2460b Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 21:08:17 +0100 Subject: [PATCH 20/24] Disable macos 14 for now --- .github/workflows/build-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 83242d1..d0404f1 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-13, macos-14] + os: [ubuntu-latest, macos-13] steps: - uses: actions/checkout@v4 From 5d7f1ff66be1ac01f4cce3134a8314af3e8acfad Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Sun, 25 Feb 2024 21:25:12 +0100 Subject: [PATCH 21/24] Fix includes --- src/average_multipoles.h | 2 ++ src/corrfunc.h | 2 ++ src/functions.h | 4 ++++ src/multipoles.h | 2 ++ src/parser.h | 2 ++ src/signal.h | 4 ++++ 6 files changed, 16 insertions(+) diff --git a/src/average_multipoles.h b/src/average_multipoles.h index 9e8cddf..eb3ad78 100644 --- a/src/average_multipoles.h +++ b/src/average_multipoles.h @@ -20,6 +20,8 @@ #define COFFE_AVERAGE_MULTIPOLES_H #include "common.h" +#include "background.h" +#include "integrals.h" typedef struct coffe_average_multipoles_t { diff --git a/src/corrfunc.h b/src/corrfunc.h index 1a0481c..c7960a7 100644 --- a/src/corrfunc.h +++ b/src/corrfunc.h @@ -20,6 +20,8 @@ #define COFFE_CORRFUNC_H #include "common.h" +#include "background.h" +#include "integrals.h" typedef struct coffe_corrfunc_t { diff --git a/src/functions.h b/src/functions.h index 58e6ebb..8650832 100644 --- a/src/functions.h +++ b/src/functions.h @@ -19,6 +19,10 @@ #ifndef COFFE_FUNCTIONS_H #define COFFE_FUNCTIONS_H +#include "common.h" +#include "background.h" +#include "integrals.h" + double functions_nonintegrated( const coffe_parameters_t *par, const coffe_background_t *bg, diff --git a/src/multipoles.h b/src/multipoles.h index 281b002..811ae92 100644 --- a/src/multipoles.h +++ b/src/multipoles.h @@ -20,6 +20,8 @@ #define COFFE_MULTIPOLES_H #include "common.h" +#include "background.h" +#include "integrals.h" /** contains the value of the multipole for one point, i.e. at (l, r, z) diff --git a/src/parser.h b/src/parser.h index 4f1c032..64d027f 100644 --- a/src/parser.h +++ b/src/parser.h @@ -19,6 +19,8 @@ #ifndef COFFE_PARSER_H #define COFFE_PARSER_H +#include "common.h" + int coffe_parse_default_parameters( coffe_parameters_t *par ); diff --git a/src/signal.h b/src/signal.h index fd440a9..14f3d07 100644 --- a/src/signal.h +++ b/src/signal.h @@ -1,6 +1,10 @@ #ifndef COFFE_SIGNAL_H #define COFFE_SIGNAL_H +#include "common.h" +#include "background.h" +#include "integrals.h" + struct coffe_integration_parameters_t { struct coffe_parameters_t *par; From af391a654ef076195f13862cde8e0bebec3909a8 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Mon, 26 Feb 2024 07:30:02 +0100 Subject: [PATCH 22/24] Fix install script --- scripts/install_other.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/install_other.sh b/scripts/install_other.sh index d5dac70..6fff00f 100755 --- a/scripts/install_other.sh +++ b/scripts/install_other.sh @@ -30,9 +30,15 @@ install_class(){ cd "${class_dir}" make libclass.a - sudo mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" - sudo cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" - sudo cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" + if [ "$(uname)" = 'Darwin' ] + then + sudo_cmd='sudo' + else + sudo_cmd='' + fi + "${sudo_cmd}" mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" + "${sudo_cmd}" cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" + "${sudo_cmd}" cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" cd - printf 'CLASS installed\n' } From fd21bfef6e769177392908ff823c2756b24dac01 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Mon, 26 Feb 2024 07:34:56 +0100 Subject: [PATCH 23/24] Maybe now --- scripts/install_other.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/install_other.sh b/scripts/install_other.sh index 6fff00f..fd024b8 100755 --- a/scripts/install_other.sh +++ b/scripts/install_other.sh @@ -30,15 +30,19 @@ install_class(){ cd "${class_dir}" make libclass.a + if [ "$(uname)" = 'Darwin' ] then - sudo_cmd='sudo' + sudo mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" + sudo cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" + sudo cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" + else - sudo_cmd='' + mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" + cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" + cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" fi - "${sudo_cmd}" mkdir -p "${CLASS_INSTALL_DIR}/lib" "${CLASS_INSTALL_DIR}/include" - "${sudo_cmd}" cp -a "${class_dir}/libclass.a" "${CLASS_INSTALL_DIR}/lib/" - "${sudo_cmd}" cp -a "${class_dir}/include/"*.h "${CLASS_INSTALL_DIR}/include/" + cd - printf 'CLASS installed\n' } From bfee6a14ce0e2d2b6e008ab0057b9d9725f6edca Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Mon, 26 Feb 2024 07:50:16 +0100 Subject: [PATCH 24/24] Fix CI --- .github/workflows/build-docs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 515335c..6e1a287 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -27,7 +27,8 @@ jobs: export CIBW_ENVIRONMENT_PASS_LINUX='SETUPTOOLS_SCM_PRETEND_VERSION' export CIBW_TEST_COMMAND='true' CIBW_BUILD='cp39-manylinux_x86_64' python3 -m cibuildwheel --platform linux - python3 -m pip install wheelhouse/*.whl + # install with optional dependencies + find wheelhouse/ -name "*.whl" -exec python3 -m pip install '{}[docs]' \; # Build the site - name: Build the site