Skip to content

Fix CI macos#1270

Merged
carlosggarcia merged 6 commits intomasterfrom
fixCI
Dec 18, 2025
Merged

Fix CI macos#1270
carlosggarcia merged 6 commits intomasterfrom
fixCI

Conversation

@carlosggarcia
Copy link
Collaborator

@carlosggarcia carlosggarcia commented Dec 18, 2025

I believe the problem is that this warning in ubuntu

  [ 95%] Building C object pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o
  /home/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c: In function 'SWIG_mod_exec':
  /home/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c:31495:3: warning: returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
  31495 |   import_array();
        |   ^~~~~~~~~~~~

becomes this error in macos

  [ 95%] Building C object pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o
  /Users/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c:31495:3: error: incompatible pointer to integer conversion returning 'void *' from a function with result type 'int' [-Wint-conversion]
   31495 |   import_array();
         |   ^~~~~~~~~~~~~~
  /private/var/folders/xc/cl1fyykn2pj4ryhdw6r1mqtc0000gn/T/pip-build-env-afta24bz/overlay/lib/python3.10/site-packages/numpy/_core/include/numpy/__multiarray_api.h:1588:12: note: expanded from macro 'import_array'
   1588 |     return NULL; \
        |            ^~~~
  /Users/runner/miniconda3/envs/test/lib/clang/21/include/__stddef_null.h:26:14: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |              ^~~~~~~~~~
  1 error generated.
  make[3]: *** [pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o] Error 1
  make[2]: *** [pyccl/CMakeFiles/_ccllib.dir/all] Error 2
  make[1]: *** [pyccl/CMakeFiles/_ccllib.dir/rule] Error 2
  make: *** [_ccllib] Error 2

I think the problem is that we are using numpy<2 for compatibility with darkemulator. (Actually the numpy version is not the issue. See #1271)

@coveralls
Copy link

coveralls commented Dec 18, 2025

Pull Request Test Coverage Report for Build 20348695864

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 97.464%

Totals Coverage Status
Change from base Build 19081893170: 0.0%
Covered Lines: 6572
Relevant Lines: 6743

💛 - Coveralls

@carlosggarcia
Copy link
Collaborator Author

Ok. Found out the culprit: swig>=4.4 (numpy/numpy#30128). For now, I have asked clang to raise a warning, instead of an error, as seems to be doing gcc.

@nikosarcevic
Copy link
Contributor

I believe the problem is that this warning in ubuntu

  [ 95%] Building C object pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o
  /home/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c: In function 'SWIG_mod_exec':
  /home/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c:31495:3: warning: returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
  31495 |   import_array();
        |   ^~~~~~~~~~~~

becomes this error in macos

  [ 95%] Building C object pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o
  /Users/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c:31495:3: error: incompatible pointer to integer conversion returning 'void *' from a function with result type 'int' [-Wint-conversion]
   31495 |   import_array();
         |   ^~~~~~~~~~~~~~
  /private/var/folders/xc/cl1fyykn2pj4ryhdw6r1mqtc0000gn/T/pip-build-env-afta24bz/overlay/lib/python3.10/site-packages/numpy/_core/include/numpy/__multiarray_api.h:1588:12: note: expanded from macro 'import_array'
   1588 |     return NULL; \
        |            ^~~~
  /Users/runner/miniconda3/envs/test/lib/clang/21/include/__stddef_null.h:26:14: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |              ^~~~~~~~~~
  1 error generated.
  make[3]: *** [pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o] Error 1
  make[2]: *** [pyccl/CMakeFiles/_ccllib.dir/all] Error 2
  make[1]: *** [pyccl/CMakeFiles/_ccllib.dir/rule] Error 2
  make: *** [_ccllib] Error 2

I think the problem is that we are using numpy<2 for compatibility with darkemulator. (Actually the numpy version is not the issue. See #1271)

I believe the problem is that this warning in ubuntu

  [ 95%] Building C object pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o
  /home/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c: In function 'SWIG_mod_exec':
  /home/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c:31495:3: warning: returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
  31495 |   import_array();
        |   ^~~~~~~~~~~~

becomes this error in macos

  [ 95%] Building C object pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o
  /Users/runner/work/CCL/CCL/build/pyccl/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c:31495:3: error: incompatible pointer to integer conversion returning 'void *' from a function with result type 'int' [-Wint-conversion]
   31495 |   import_array();
         |   ^~~~~~~~~~~~~~
  /private/var/folders/xc/cl1fyykn2pj4ryhdw6r1mqtc0000gn/T/pip-build-env-afta24bz/overlay/lib/python3.10/site-packages/numpy/_core/include/numpy/__multiarray_api.h:1588:12: note: expanded from macro 'import_array'
   1588 |     return NULL; \
        |            ^~~~
  /Users/runner/miniconda3/envs/test/lib/clang/21/include/__stddef_null.h:26:14: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |              ^~~~~~~~~~
  1 error generated.
  make[3]: *** [pyccl/CMakeFiles/_ccllib.dir/CMakeFiles/_ccllib.dir/cclPYTHON_wrap.c.o] Error 1
  make[2]: *** [pyccl/CMakeFiles/_ccllib.dir/all] Error 2
  make[1]: *** [pyccl/CMakeFiles/_ccllib.dir/rule] Error 2
  make: *** [_ccllib] Error 2

I think the problem is that we are using numpy<2 for compatibility with darkemulator. (Actually the numpy version is not the issue. See #1271)

I tested this loaclly on macOS arm64. the build succeeds, but the underlying numpy/SWIG warning (import_array() in an int-returning function) is still present and would still fail if treated as an error. This PR seems to mitigate CI behavior but i am not sure if this really fixes the root cause. perhpas check numpy init macro in the swig wrapper so the warning cannot occur on macOS? I am not sure if this makes any sense at all

here is some output

(ccl3) niko @ Mac.lan : ~/Documents/Research/CCL-master% rm -rf build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 \
  -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror"
cmake --build build --target _ccllib --verbose
-- CMAKE_BUILD_TYPE: Release
-- The C compiler identification is Clang 21.1.2
-- The CXX compiler identification is AppleClang 17.0.0.17000603
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/niko/miniforge3/envs/ccl3/bin/arm64-apple-darwin20.0.0-clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /usr/local/Cellar/cmake/3.30.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:441 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)                                                                                           
  does not match the name of the calling package (FFTW).  This can lead to                                                                                             
  problems in calling code that expects `find_package` result variables                                                                                                
  (e.g., `_FOUND`) to follow a certain pattern.                                                                                                                        
Call Stack (most recent call first):                                                                                                                                   
  /usr/local/Cellar/cmake/3.30.5/share/cmake/Modules/FindPkgConfig.cmake:114 (find_package_handle_standard_args)                                                       
  cmake/Modules/FindFFTW.cmake:18 (include)                                                                                                                            
  cmake/Modules/BuildFFTW.cmake:6 (find_package)                                                                                                                       
  CMakeLists.txt:48 (include)                                                                                                                                          
This warning is for project developers.  Use -Wno-dev to suppress it.                                                                                                  
                                                                                                                                                                       
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "2.5.1")
-- Found FFTW: /Users/niko/miniforge3/envs/ccl3/include
-- Found GSL: /Users/niko/miniforge3/envs/ccl3/include (found suitable version "2.7", minimum required is "2.1")
-- Found OpenMP_C: -fopenmp=libomp (found version "5.1")
-- Found OpenMP_CXX: -Xclang -fopenmp (found version "5.1")
-- Found OpenMP: TRUE (found version "5.1")
-- Found SWIG: /usr/local/bin/swig (found version "4.1.1")
CMake Warning (dev) at cmake/Modules/FindPythonLibsNew.cmake:62 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules                                                                                           
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use                                                                                             
  the cmake_policy command to set the policy and suppress this warning.                                                                                                
                                                                                                                                                                       
Call Stack (most recent call first):                                                                                                                                   
  pyccl/CMakeLists.txt:8 (find_package)                                                                                                                                
This warning is for project developers.  Use -Wno-dev to suppress it.                                                                                                  
                                                                                                                                                                       
-- Found PythonInterp: /Users/niko/miniforge3/envs/ccl3/bin/python (found version "3.12.11")
-- Found PythonLibs: /Users/niko/miniforge3/envs/ccl3/lib/libpython3.12.dylib
CMake Warning (dev) at cmake/Modules/FindNumPy.cmake:45 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules                                                                                           
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use                                                                                             
  the cmake_policy command to set the policy and suppress this warning.                                                                                                
                                                                                                                                                                       
Call Stack (most recent call first):                                                                                                                                   
  pyccl/CMakeLists.txt:9 (find_package)                                                                                                                                
This warning is for project developers.  Use -Wno-dev to suppress it.                                                                                                  
                                                                                                                                                                       
-- Found NumPy: version "2.3.3" /Users/niko/miniforge3/envs/ccl3/lib/python3.12/site-packages/numpy/_core/include
CMake Warning (dev) at /usr/local/Cellar/cmake/3.30.5/share/cmake/Modules/UseSWIG.cmake:815 (message):
  Policy CMP0078 is not set: UseSWIG generates standard target names.  Run                                                                                             
  "cmake --help-policy CMP0078" for policy details.  Use the cmake_policy                                                                                              
  command to set the policy and suppress this warning.                                                                                                                 
                                                                                                                                                                       
Call Stack (most recent call first):                                                                                                                                   
  pyccl/CMakeLists.txt:28 (swig_add_library)                                                                                                                           
This warning is for project developers.  Use -Wno-dev to suppress it.                                                                                                  
                                                                                                                                                                       
CMake Warning (dev) at /usr/local/Cellar/cmake/3.30.5/share/cmake/Modules/UseSWIG.cmake:657 (message):
  Policy CMP0086 is not set: UseSWIG honors SWIG_MODULE_NAME via -module                                                                                               
  flag.  Run "cmake --help-policy CMP0086" for policy details.  Use the                                                                                                
  cmake_policy command to set the policy and suppress this warning.                                                                                                    
                                                                                                                                                                       
Call Stack (most recent call first):                                                                                                                                   
  /usr/local/Cellar/cmake/3.30.5/share/cmake/Modules/UseSWIG.cmake:928 (SWIG_ADD_SOURCE_TO_MODULE)                                                                     
  pyccl/CMakeLists.txt:28 (swig_add_library)                                                                                                                           
This warning is for project developers.  Use -Wno-dev to suppress it.    

@carlosggarcia
Copy link
Collaborator Author

carlosggarcia commented Dec 18, 2025

The root error has been fixed in numpy (in the PR i linked). At some point it will be available through pypi.

In any case, this modification makes clang and gcc behaviour to agree (at least in this regard).

@nikosarcevic
Copy link
Contributor

The root error has been fixed in numpy (in the PR i linked). At some point it will be available through pypi.

In any case, this modification makes clang and gcc behaviour to agree (at least in this regard).

Got it, thanks — in that case this looks fine to me and should resolve the CI issue

you are a superhero rockstar!!!
I am going to make sure i rebase my branches off of main

@nikosarcevic nikosarcevic self-requested a review December 18, 2025 20:17
Copy link
Contributor

@nikosarcevic nikosarcevic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me — thanks for the clarification. This should resolve the CI issue.

@carlosggarcia carlosggarcia merged commit 46fc53f into master Dec 18, 2025
4 checks passed
@carlosggarcia carlosggarcia deleted the fixCI branch December 18, 2025 20:20
@damonge
Copy link
Collaborator

damonge commented Dec 19, 2025

Late to the party, but just to say, amazing detective work @carlosggarcia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImportError: cannot import name ccllib from partially initialized module pyccl in macOS CI

4 participants