Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update numpy to 1.25.2 #4125

Merged
merged 3 commits into from Sep 9, 2023
Merged

Update numpy to 1.25.2 #4125

merged 3 commits into from Sep 9, 2023

Conversation

rgommers
Copy link
Contributor

@rgommers rgommers commented Sep 9, 2023

Description

This is the last version of numpy that defaults to a distutils/setup.py-based build. I am also looking into moving the build to Meson (xref numpy/numpy#24603), but I thought it'd be good to make this update in case anything changed in the 1.25.x release series.

Checklists

  • Add a CHANGELOG entry
  • Add / update tests
  • Add new / update outdated documentation

This is the last version that defaults to a distutils/setup.py-based
build.
@rgommers rgommers changed the title Update numpy 125 Update numpy to 1.25.2 Sep 9, 2023
@hoodmane
Copy link
Member

hoodmane commented Sep 9, 2023

Thanks @rgommers! It seems to be mad about -std=c++17? I'll try building it locally.

@rgommers
Copy link
Contributor Author

rgommers commented Sep 9, 2023

Argh, I was hoping it would be smooth sailing. I tried building locally in a conda env following the contributor guide, but that had some hiccup. I will try with the recommended Docker setup instead.

And yes indeed, more C++ in this release. This snippet from the release notes may also be relevant:

C++ standard library usage
--------------------------
NumPy builds now depend on the C++ standard library, because
the ``numpy.core._multiarray_umath`` extension is linked with
the C++ linker.

C++17 is no problem in principle I assume, right?

EDIT: build failure for future reference:

creating tmp/tmpr8en6c1l                                                        
INFO: compile options: '-Inumpy/core/src/common -Inumpy/core/src -Inumpy/core   
-Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath     
-Inumpy/core/src/npysort -Inumpy/core/src/_simd                                 
-I/tmp/build-env-2vd3bsq6/include                                               
-I/usr/share/miniconda/envs/pyodide-env/include/python3.11                      
-Ibuild/src.emscripten_3_1_45_wasm32-3.11/numpy/core/src/common                 
-Ibuild/src.emscripten_3_1_45_wasm32-3.11/numpy/core/src/npymath -c'            
INFO: c++: /tmp/tmpr8en6c1l/test.cpp                                            
/tmp/tmpr8en6c1l/test.cpp:4:41: error: no template named 'is_const_v' in        
namespace 'std'; did you mean 'is_const'?                                       
    4 | constexpr bool test_fold = (... && std::is_const_v<T>);                 
      |                                    ~~~~~^~~~~~~~~~                      
      |                                         is_const                        
/home/runner/work/pyodide/pyodide/emsdk/emsdk/upstream/emscripten/cache/sysroot/
include/c++/v1/__type_traits/is_const.h:24:29: note: 'is_const' declared here   
   24 | struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { 
};                                                                              
      |                             ^                                           
/tmp/tmpr8en6c1l/test.cpp:4:54: error: expected '(' for function-style cast or  
type construction                                                               
    4 | constexpr bool test_fold = (... && std::is_const_v<T>);                 
      |                                    ~~~~~~~~~~~~~~~~~~^                  
/tmp/tmpr8en6c1l/test.cpp:4:16: error: constexpr variable 'test_fold<int, const 
int>' must be initialized by a constant expression                              
    4 | constexpr bool test_fold = (... && std::is_const_v<T>);                 
      |                ^                                                        
      |                          = false                                        
/tmp/tmpr8en6c1l/test.cpp:7:9: note: in instantiation of variable template      
specialization 'test_fold<int, const int>' requested here                       
    7 |     if (test_fold<int, const int>) {                                    
      |         ^                                                               
3 errors generated.                                                             
em++: error: '/home/runner/work/pyodide/pyodide/emsdk/emsdk/upstream/bin/clang++
-target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default      
-mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj     
-mllvm -disable-lsr -DEMSCRIPTEN                                                
--sysroot=/home/runner/work/pyodide/pyodide/emsdk/emsdk/upstream/emscripten/cach
e/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang                         
-iwithsysroot/include/compat -g3 -fwrapv -O3 -Wall -O2 -g0 -fPIC                
-Werror=implicit-function-declaration -Werror=mismatched-parameter-types        
-Werror=return-type -Wno-return-type -O2 -g0 -fPIC -std=c++14 -DNDEBUG          
-DPY_CALL_TRAMPOLINE -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core      
-Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath     
-Inumpy/core/src/npysort -Inumpy/core/src/_simd                                 
-I/tmp/build-env-2vd3bsq6/include                                               
-Ibuild/src.emscripten_3_1_45_wasm32-3.11/numpy/core/src/common                 
-Ibuild/src.emscripten_3_1_45_wasm32-3.11/numpy/core/src/npymath                
-I/home/runner/work/pyodide/pyodide/cpython/installs/python-3.11.3/include/pytho
n3.11                                                                           
-I/home/runner/work/pyodide/pyodide/cpython/installs/python-3.11.3/include/pytho
n3.11 -c -MMD -MF tmp/tmpr8en6c1l/test.o.d -fcolor-diagnostics                  
/tmp/tmpr8en6c1l/test.cpp -o tmp/tmpr8en6c1l/test.o' failed (returned 1)        
INFO: C compiler: /tmp/tmpdoblrjdq/c++ -DNDEBUG -g -fwrapv -O3 -Wall -O2 -g0    
-fPIC -DPY_CALL_TRAMPOLINE                 

...

RuntimeError: Broken toolchain during testing C++ compiler.                     
A compiler with support for C++17 language features is required.                
Triggered the following error: Command "/tmp/tmpdoblrjdq/c++ -DNDEBUG -g -fwrapv
-O3 -Wall -O2 -g0 -fPIC -DPY_CALL_TRAMPOLINE -Inumpy/core/src/common            
-Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath                          
-Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort     
-Inumpy/core/src/_simd -I/tmp/build-env-2vd3bsq6/include                        
-I/usr/share/miniconda/envs/pyodide-env/include/python3.11                      
-Ibuild/src.emscripten_3_1_45_wasm32-3.11/numpy/core/src/common                 
-Ibuild/src.emscripten_3_1_45_wasm32-3.11/numpy/core/src/npymath -c             
/tmp/tmpr8en6c1l/test.cpp -o tmp/tmpr8en6c1l/test.o -MMD -MF                    
tmp/tmpr8en6c1l/test.o.d -std=c++17" failed with exit status 1.                                     

@hoodmane
Copy link
Member

hoodmane commented Sep 9, 2023

Are there any simple tricks to leave tmp files in the file system after compilation fails? I always have this problem where the failing command takes arguments that were in /tmp and now they are gone...

@hoodmane
Copy link
Member

hoodmane commented Sep 9, 2023

Ah but this test is hard coded into setup.py so it's easy to create my own.

@rgommers
Copy link
Contributor Author

rgommers commented Sep 9, 2023

Yes, that is usually a pain. If you build via pip install, then --no-clean is helpful. Or otherwise yes, peek in the source of test.c and it's typically only a one-liner.

@hoodmane
Copy link
Member

hoodmane commented Sep 9, 2023

Okay found the problem.

@hoodmane
Copy link
Member

hoodmane commented Sep 9, 2023

It built really fast, 1m 31s, tests pass. Did you change something to improve the build speed?

@rgommers
Copy link
Contributor Author

rgommers commented Sep 9, 2023

Not that I know of. Locally 1m 31s isn't unusual for a local parallel build though. I just tried on Linux:

$ time python setup.py build_ext -i -j4
real    1m21,634s
user    3m36,304s
sys     0m13,231s

It'll get a lot faster still from 1.26.0 onwards, due to the Meson rewrite:

$ time python -m build -wnx
real    0m40,042s
user    7m1,368s
sys     0m22,224s

@rgommers
Copy link
Contributor Author

rgommers commented Sep 9, 2023

The macOS job failure looks unrelated. Something that picked up the system Python 2.7 in the final check-size step.

@hoodmane
Copy link
Member

hoodmane commented Sep 9, 2023

Yeah the github macos job flakes a lot so I tend not to pay much attention to it especially if the circleci safari tests pass.

@rgommers
Copy link
Contributor Author

rgommers commented Sep 9, 2023

I can reproduce the initial failure and the completed build after your fix locally now. Thanks for the help!

@hoodmane hoodmane merged commit 8b58984 into pyodide:main Sep 9, 2023
34 of 37 checks passed
@hoodmane
Copy link
Member

hoodmane commented Sep 9, 2023

Thanks again @rgommers!

@rgommers rgommers deleted the update-numpy-125 branch September 9, 2023 17:23
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.

None yet

2 participants