From 883c338c08c8761b09f263ee4d39709101d4aa23 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 17 Jan 2024 14:00:09 +0100 Subject: [PATCH 01/15] Fixed building --- external/external_build.cmake | 1 + sample/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/external/external_build.cmake b/external/external_build.cmake index 65ee8b8..997cc4d 100644 --- a/external/external_build.cmake +++ b/external/external_build.cmake @@ -206,6 +206,7 @@ if (INTERNAL_NETCDF) DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads URL ${NETCDFCXX_URL} CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS=OFF diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index 03709a7..6d019a7 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,4 +1,8 @@ SET(tolink ${CosmoTool_local} ${CosmoTool_LIBS} ${GSL_LIBRARIES} ${DL_LIBRARY}) +if (RT_LIBRARY) + SET(tolink ${tolink} ${RT_LIBRARY}) +endif() + include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${FFTW3_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${GSL_INCLUDE_PATH}) if(YORICK_SUPPORT) From 54a59b5246407b0b8d226eddb90e8151f829278b Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 16 Jan 2024 07:54:48 +0100 Subject: [PATCH 02/15] Fix manifest --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 5c4f363..2344e64 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -17,7 +17,7 @@ include doc/source/index.rst include doc/source/intro.rst include doc/source/pythonmodule.rst include external/external_build.cmake -include external/libsharp-6077806.tar.gz +include external/libsharp-8d51946.tar.gz include external/omptl-20120422.tar.bz2 include external/patch-omptl include python/CMakeLists.txt From f2a5092cf119760a9a0f03da81980b791dbf9389 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 07:53:06 +0100 Subject: [PATCH 03/15] Fix MANIFEST --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 2344e64..6400359 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -16,6 +16,8 @@ include doc/source/cpplibrary.rst include doc/source/index.rst include doc/source/intro.rst include doc/source/pythonmodule.rst +include external/config.guess +include external/config.sub include external/external_build.cmake include external/libsharp-8d51946.tar.gz include external/omptl-20120422.tar.bz2 From 1db266b4ea982284c200739bf4e24f3166346b88 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 08:19:54 +0100 Subject: [PATCH 04/15] Add pyproject.toml --- MANIFEST.in | 1 + pyproject.toml | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 pyproject.toml diff --git a/MANIFEST.in b/MANIFEST.in index 6400359..4bc4264 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include .gitignore +include pyproject.toml include CMakeLists.txt include FindNumPy.cmake include FindPyLibs.cmake diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..890c3fc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + From 1151d0c8b6008e095a692c166afbeef807557f24 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 08:25:14 +0100 Subject: [PATCH 05/15] Add cython back to dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7c07d3a..63377a0 100644 --- a/setup.py +++ b/setup.py @@ -240,7 +240,7 @@ setup(name='cosmotool', version='1.3.5', packages=["cosmotool"], package_dir={'cosmotool': 'python/cosmotool'}, - install_requires=['numpy','cffi','numexpr','h5py'], + install_requires=['cython','numpy','cffi','numexpr','h5py'], setup_requires=['cython','cffi','numpy','numexpr'], ext_modules=[CosmoTool_extension], description='A small cosmotool box of useful functions', From 1548fd84508ed84c6c5a00bd7da570967e2edf7c Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 09:15:36 +0100 Subject: [PATCH 06/15] Add missing pyx in MANIFEST --- MANIFEST.in | 1 + pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 4bc4264..309d4fc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -27,6 +27,7 @@ include python/CMakeLists.txt include python/_cosmo_bispectrum.cpp include python/_cosmo_cic.pyx include python/_cosmo_power.pyx +include python/_cosmomath.pyx include python/_cosmotool.pyx include python/_fast_interp.pyx include python/_project.pyx diff --git a/pyproject.toml b/pyproject.toml index 890c3fc..32826dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools","wheel","cython"] build-backend = "setuptools.build_meta" From 1d59533b175b5bbe0c8a3ce02fe2808a1fdc5e51 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 10:28:58 +0100 Subject: [PATCH 07/15] Add python in search path --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 368eed6..1b3fe10 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_SHARED_MODULE_PREFIX) set(PYTHON_INCLUDES ${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/python) -include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src) +include_directories(${CMAKE_SOURCE_DIR}/python ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src) IF(CYTHON) add_custom_command( From 4bcc5f32704867a6ff9068ac1cc8e328476d6fe9 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 10:37:52 +0100 Subject: [PATCH 08/15] Add missing numpy_adaptors --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 309d4fc..105a2d6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -97,6 +97,7 @@ include sample/testkd3.cpp include setup.py include src/CMakeLists.txt include src/algo.hpp +include src/numpy_adaptors.hpp include src/bqueue.hpp include src/bqueue.tcc include src/bsp_simple.hpp From 47d63a25cec1f8a823aa14edaa10f6aa1fc93412 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 10:47:28 +0100 Subject: [PATCH 09/15] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 63377a0..0b98cce 100644 --- a/setup.py +++ b/setup.py @@ -237,7 +237,7 @@ class BuildCMakeExt(build_ext): CosmoTool_extension = CMakeExtension(name="cosmotool") setup(name='cosmotool', - version='1.3.5', + version='1.3.6', packages=["cosmotool"], package_dir={'cosmotool': 'python/cosmotool'}, install_requires=['cython','numpy','cffi','numexpr','h5py'], From be64c7fd7afe1c1c173401c64842b2ca99f27a6f Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 25 Apr 2024 17:05:54 +0200 Subject: [PATCH 10/15] Remove support for old python --- builder/build-wheels.sh | 6 +++--- builder/start.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/build-wheels.sh b/builder/build-wheels.sh index 60a8bfc..8f529dd 100755 --- a/builder/build-wheels.sh +++ b/builder/build-wheels.sh @@ -16,7 +16,7 @@ ln -fs /usr/bin/cmake3 /usr/bin/cmake test -d /io/wheelhouse || mkdir /io/wheelhouse test -d /io/wheelhouse/fix || mkdir /io/wheelhouse/fix -ALL_PYTHON="cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310" +ALL_PYTHON="cp39-cp39 cp310-cp310" # Compile wheels for pkg in $ALL_PYTHON; do @@ -24,11 +24,11 @@ for pkg in $ALL_PYTHON; do # "${PYBIN}/pip" install -r /io/dev-requirements.txt "${PYBIN}/pip" install setuptools wheel Cython "${PYBIN}/pip" install -r /io/requirements.txt - "${PYBIN}/pip" wheel -vvv /io/ -w wheelhouse/ + "${PYBIN}/pip" wheel -vvv /io/ -w /io/wheelhouse/ done # Bundle external shared libraries into the wheels -for whl in /io/wheelhouse/cosmotool*.whl; do +for whl in /io/wheelhouse/cosmotool*linux*.whl; do auditwheel repair "$whl" --plat $PLAT -w /io/wheelhouse/fix done diff --git a/builder/start.sh b/builder/start.sh index 9fbc185..31f95f0 100755 --- a/builder/start.sh +++ b/builder/start.sh @@ -9,4 +9,4 @@ if ! [ -e ${d}/setup.py ] ; then exit 1 fi -podman run -ti --rm -e PLAT=manylinux2010_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2010_x86_64 /io/builder/build-wheels.sh +podman run -ti --rm -e PLAT=manylinux2014_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2014_x86_64 /io/builder/build-wheels.sh From 924047de22b6c1e1e367d807e0508d6641c5ea24 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 25 Apr 2024 18:11:02 +0200 Subject: [PATCH 11/15] Add possibility to have an external state --- src/hdf5_array.hpp | 2 +- src/sphSmooth.hpp | 4 +++- src/sphSmooth.tcc | 37 +++++++++++++++++++++---------------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/hdf5_array.hpp b/src/hdf5_array.hpp index db75a33..55dc87b 100644 --- a/src/hdf5_array.hpp +++ b/src/hdf5_array.hpp @@ -426,7 +426,7 @@ namespace CosmoTool { #define CTOOL_HDF5_INSERT_ELEMENT(r, STRUCT, element) \ { \ ::CosmoTool::get_hdf5_data_type t; \ - long position = HOFFSET(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \ + long position = offsetof(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \ const char *field_name = BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 1, element)); \ type.insertMember(field_name, position, t.type()); \ } diff --git a/src/sphSmooth.hpp b/src/sphSmooth.hpp index fdada71..f9c468b 100644 --- a/src/sphSmooth.hpp +++ b/src/sphSmooth.hpp @@ -72,7 +72,9 @@ namespace CosmoTool { void fetchNeighbours(const typename SPHTree::coords &c, SPHState *state = 0); - void fetchNeighbours(const typename SPHTree::coords &c, uint32_t newNsph); + void fetchNeighbours( + const typename SPHTree::coords &c, uint32_t newNsph, + SPHState *state = 0); void fetchNeighboursOnVolume( const typename SPHTree::coords &c, ComputePrecision radius); const typename SPHTree::coords &getCurrentCenter() const { diff --git a/src/sphSmooth.tcc b/src/sphSmooth.tcc index c163feb..c50fb7e 100644 --- a/src/sphSmooth.tcc +++ b/src/sphSmooth.tcc @@ -35,32 +35,38 @@ namespace CosmoTool { template void SPHSmooth::fetchNeighbours( - const typename SPHTree::coords &c, uint32_t newNngb) { + const typename SPHTree::coords &c, uint32_t newNngb, SPHState *state) { ComputePrecision d2, max_dist = 0; uint32_t requested = newNngb; - if (requested > maxNgb) { - maxNgb = requested; - internal.ngb = boost::shared_ptr(new P_SPHCell[maxNgb]); - internal.distances = - boost::shared_ptr(new CoordType[maxNgb]); + if (state != 0) { + state->distances = boost::shared_ptr(new CoordType[Nsph]); + state->ngb = boost::shared_ptr(new SPHCell *[Nsph]); + } else { + state = &internal; + if (requested > maxNgb) { + maxNgb = requested; + internal.ngb = boost::shared_ptr(new P_SPHCell[maxNgb]); + internal.distances = + boost::shared_ptr(new CoordType[maxNgb]); + } } - memcpy(internal.currentCenter, c, sizeof(c)); + memcpy(state->currentCenter, c, sizeof(c)); tree->getNearestNeighbours( - c, requested, (SPHCell **)internal.ngb.get(), - (CoordType *)internal.distances.get()); + c, requested, (SPHCell **)state->ngb.get(), + (CoordType *)state->distances.get()); - internal.currentNgb = 0; - for (uint32_t i = 0; i < requested && (internal.ngb)[i] != 0; - i++, internal.currentNgb++) { - internal.distances[i] = sqrt(internal.distances[i]); - d2 = internal.distances[i]; + state->currentNgb = 0; + for (uint32_t i = 0; i < requested && (state->ngb)[i] != 0; + i++, state->currentNgb++) { + state->distances[i] = sqrt(state->distances[i]); + d2 = state->distances[i]; if (d2 > max_dist) max_dist = d2; } - internal.smoothRadius = max_dist / 2; + state->smoothRadius = max_dist / 2; } template @@ -241,5 +247,4 @@ namespace CosmoTool { const SPHSmooth &s2) { return (s1.getSmoothingLen() < s2.getSmoothingLen()); } - }; // namespace CosmoTool From fb51ffd35e5f111bbf7a679a0dffc562530c1cb1 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Fri, 26 Apr 2024 08:53:38 +0200 Subject: [PATCH 12/15] Fixup for sph --- src/sphSmooth.tcc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sphSmooth.tcc b/src/sphSmooth.tcc index c50fb7e..6643dd3 100644 --- a/src/sphSmooth.tcc +++ b/src/sphSmooth.tcc @@ -40,8 +40,8 @@ namespace CosmoTool { uint32_t requested = newNngb; if (state != 0) { - state->distances = boost::shared_ptr(new CoordType[Nsph]); - state->ngb = boost::shared_ptr(new SPHCell *[Nsph]); + state->distances = boost::shared_ptr(new CoordType[newNngb]); + state->ngb = boost::shared_ptr(new SPHCell *[newNngb]); } else { state = &internal; if (requested > maxNgb) { @@ -212,7 +212,7 @@ namespace CosmoTool { ComputePrecision d = state->distances[i]; SPHCell &cell = *(state->ngb[i]); double kernel_value = getKernel(d / state->smoothRadius) / r3; -#pragma omp atomic +#pragma omp atomic update cell.val.weight += kernel_value; } } From 736531e9fd4c9a53d3ab63a9674aab42e4a5a7e3 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 9 May 2024 09:55:02 +0300 Subject: [PATCH 13/15] Add towncrier experimental --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 32826dd..7a031e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,3 +2,7 @@ requires = ["setuptools","wheel","cython"] build-backend = "setuptools.build_meta" + +[tool.towncrier] +directory = "changes" + From 70f6f88802a145caab0ebeb1edcde6d66923d5ea Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 11 Mar 2025 14:26:57 -0400 Subject: [PATCH 14/15] Add ZLIB package --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80b1743..02a93d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ ENDIF(BUILD_PYTHON) MESSAGE(STATUS "Using the target ${CosmoTool_local} to build python module") +find_package(ZLIB) find_library(ZLIB_LIBRARY z) find_library(DL_LIBRARY dl) find_library(RT_LIBRARY rt) @@ -82,7 +83,7 @@ SET(CPACK_PACKAGE_VERSION_MINOR "3") SET(CPACK_PACKAGE_VERSION_PATCH "4${EXTRA_VERSION}") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") SET(CPACK_STRIP_FILES "lib/libCosmoTool.so") -SET(CPACK_SOURCE_IGNORE_FILES +SET(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\.git/;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;.*~;cscope.*;/CMakeFiles/;.*\\\\.cmake;Makefile") add_subdirectory(src) From 36905042612f805723ca712e1457e4ee9d587224 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Sun, 8 Jun 2025 11:02:51 +0200 Subject: [PATCH 15/15] fix: Force PIC building in all cases --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c075396..38c1901 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,7 +39,7 @@ if (HDF5_FOUND) loadFlash.cpp ) add_dependencies(CosmoHDF5 ${cosmotool_DEPS}) - set_property(TARGET CosmoHDF5 PROPERTY POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}) + set_property(TARGET CosmoHDF5 PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(CosmoHDF5 BEFORE PRIVATE ${HDF5_INCLUDE_DIR}) else(HDF5_FOUND) add_library(CosmoHDF5 OBJECT