bottleneck icon indicating copy to clipboard operation
bottleneck copied to clipboard

Failed to compile on Apple M1 [BUG]

Open NikZak opened this issue 2 years ago • 12 comments

I am trying to compile on Apple M1 with pip install . and get following bug report. Any help would be appreciated

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Processing /Users/.../bottleneck
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy in /opt/homebrew/lib/python3.9/site-packages (from Bottleneck==1.4.0.dev0+117.gf2bc792) (1.20.3)
Building wheels for collected packages: Bottleneck
  Building wheel for Bottleneck (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/jh/255j6mls5nd57kvdpm0hv2qw0000gn/T/tmp0zyrguhb
       cwd: /private/var/folders/jh/255j6mls5nd57kvdpm0hv2qw0000gn/T/pip-req-build-x4fx9n_c
  Complete output (210 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-11-arm64-3.9
  creating build/lib.macosx-11-arm64-3.9/bottleneck
  copying bottleneck/_version.py -> build/lib.macosx-11-arm64-3.9/bottleneck
  copying bottleneck/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck
  copying bottleneck/_pytesttester.py -> build/lib.macosx-11-arm64-3.9/bottleneck
  creating build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/bench_detailed.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/autotimeit.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/bench.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  creating build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/reduce.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/nonreduce.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/move.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/nonreduce_axis.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  creating build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/nonreduce_axis_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/scalar_input_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/reduce_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/util.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/move_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/input_modification_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/common.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/nonreduce_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/list_input_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/memory_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/test_template.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  creating build/lib.macosx-11-arm64-3.9/bottleneck/src
  copying bottleneck/src/bn_config.py -> build/lib.macosx-11-arm64-3.9/bottleneck/src
  copying bottleneck/src/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/src
  copying bottleneck/src/bn_template.py -> build/lib.macosx-11-arm64-3.9/bottleneck/src
  creating build/lib.macosx-11-arm64-3.9/bottleneck/tests/data
  creating build/lib.macosx-11-arm64-3.9/bottleneck/tests/data/template_test
  copying bottleneck/tests/data/template_test/truth.c -> build/lib.macosx-11-arm64-3.9/bottleneck/tests/data/template_test
  copying bottleneck/tests/data/template_test/test_template.c -> build/lib.macosx-11-arm64-3.9/bottleneck/tests/data/template_test
  UPDATING build/lib.macosx-11-arm64-3.9/bottleneck/_version.py
  set build/lib.macosx-11-arm64-3.9/bottleneck/_version.py to '1.4.0.dev0+117.gf2bc792'
  running build_ext
  running config
  clang -E -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -o _configtest.i _configtest.c
  removing: _configtest.c _configtest.i
  compiling '_configtest.c':
  
  #pragma clang diagnostic error "-Wattributes"
  
  int __attribute__((optimize("O3"))) have_attribute_optimize_opt_3(void*);
  
  int main(void)
  {
      return 0;
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -falign-functions=8 -falign-functions=8 -c _configtest.c -o _configtest.o
  _configtest.c:4:20: error: unknown attribute 'optimize' ignored [-Werror,-Wunknown-attributes]
  int __attribute__((optimize("O3"))) have_attribute_optimize_opt_3(void*);
                     ^
  1 error generated.
  failure.
  removing: _configtest.c _configtest.o
  clang -E -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -o _configtest.i _configtest.c
  removing: _configtest.c _configtest.i
  compiling '_configtest.c':
  #include <math.h>
  
  
  int check(void) {
      return __builtin_isnan(0.);
  }
  
  int main(void)
  {
      return check();
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -falign-functions=8 -falign-functions=8 -c _configtest.c -o _configtest.o
  clang _configtest.o -o _configtest
  success!
  removing: _configtest.c _configtest.o _configtest
  compiling '_configtest.c':
  #include <math.h>
  
  
  int check(void) {
      return isnan(0.);
  }
  
  int main(void)
  {
      return check();
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -falign-functions=8 -falign-functions=8 -c _configtest.c -o _configtest.o
  clang _configtest.o -o _configtest
  success!
  removing: _configtest.c _configtest.o _configtest
  compiling '_configtest.c':
  #include <math.h>
  
  
  int check(void) {
      return _isnan(0.);
  }
  
  int main(void)
  {
      return check();
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -falign-functions=8 -falign-functions=8 -c _configtest.c -o _configtest.o
  _configtest.c:5:12: error: implicit declaration of function '_isnan' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      return _isnan(0.);
             ^
  1 error generated.
  failure.
  removing: _configtest.c _configtest.o
  compiling '_configtest.c':
  
  #ifndef __cplusplus
  static inline int static_func (void)
  {
      return 0;
  }
  inline int nostatic_func (void)
  {
      return 0;
  }
  #endif
  int main(void) {
      int r1 = static_func();
      int r2 = nostatic_func();
      return r1 + r2;
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -falign-functions=8 -falign-functions=8 -c _configtest.c -o _configtest.o
  success!
  removing: _configtest.c _configtest.o
  building 'bottleneck.reduce' extension
  creating build/temp.macosx-11-arm64-3.9
  creating build/temp.macosx-11-arm64-3.9/bottleneck
  creating build/temp.macosx-11-arm64-3.9/bottleneck/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -falign-functions=8 -falign-functions=8 -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -Ibottleneck/src -Ibottleneck/include -c bottleneck/src/reduce.c -o build/temp.macosx-11-arm64-3.9/bottleneck/src/reduce.o -O2
  In file included from bottleneck/src/reduce_template.c:9:
  In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/x86intrin.h:15:
  In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/immintrin.h:15:
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:50:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:129:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:159:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:189:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:216:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:239:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:260:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:287:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:310:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:331:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:352:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:373:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:394:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:416:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_paddsb((__v8qi)__m1, (__v8qi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:439:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_paddsw((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:461:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_paddusb((__v8qi)__m1, (__v8qi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:483:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_paddusw((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:504:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_psubb((__v8qi)__m1, (__v8qi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:525:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
      return (__m64)__builtin_ia32_psubw((__v4hi)__m1, (__v4hi)__m2);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for Bottleneck
Failed to build Bottleneck
ERROR: Could not build wheels for Bottleneck which use PEP 517 and cannot be installed directly

NikZak avatar Sep 23 '21 10:09 NikZak

I don't know if this might help at all. I tried to replace the OPTIONAL_HEADERS (which apparently is not optional afer all) param in bottleneck/src/bn_config.py

OPTIONAL_HEADERS = [("HAVE_SSE2", "emmintrin.h")]

with

OPTIONAL_HEADERS = []

Then I pass past the error above but get another error in bottleneck/src/reduce_template.c

Here is the dump

  ERROR: Command errored out with exit status 1:
   command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/jh/255j6mls5nd57kvdpm0hv2qw0000gn/T/tmpbbw93w1b
       cwd: /private/var/folders/jh/255j6mls5nd57kvdpm0hv2qw0000gn/T/pip-req-build-f53iw59g
  Complete output (171 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-11-arm64-3.9
  creating build/lib.macosx-11-arm64-3.9/bottleneck
  copying bottleneck/_version.py -> build/lib.macosx-11-arm64-3.9/bottleneck
  copying bottleneck/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck
  copying bottleneck/_pytesttester.py -> build/lib.macosx-11-arm64-3.9/bottleneck
  creating build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/bench_detailed.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/autotimeit.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  copying bottleneck/benchmark/bench.py -> build/lib.macosx-11-arm64-3.9/bottleneck/benchmark
  creating build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/reduce.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/nonreduce.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/move.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  copying bottleneck/slow/nonreduce_axis.py -> build/lib.macosx-11-arm64-3.9/bottleneck/slow
  creating build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/nonreduce_axis_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/scalar_input_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/reduce_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/util.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/move_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/input_modification_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/common.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/nonreduce_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/list_input_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/memory_test.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  copying bottleneck/tests/test_template.py -> build/lib.macosx-11-arm64-3.9/bottleneck/tests
  creating build/lib.macosx-11-arm64-3.9/bottleneck/src
  copying bottleneck/src/bn_config.py -> build/lib.macosx-11-arm64-3.9/bottleneck/src
  copying bottleneck/src/__init__.py -> build/lib.macosx-11-arm64-3.9/bottleneck/src
  copying bottleneck/src/bn_template.py -> build/lib.macosx-11-arm64-3.9/bottleneck/src
  creating build/lib.macosx-11-arm64-3.9/bottleneck/tests/data
  creating build/lib.macosx-11-arm64-3.9/bottleneck/tests/data/template_test
  copying bottleneck/tests/data/template_test/truth.c -> build/lib.macosx-11-arm64-3.9/bottleneck/tests/data/template_test
  copying bottleneck/tests/data/template_test/test_template.c -> build/lib.macosx-11-arm64-3.9/bottleneck/tests/data/template_test
  UPDATING build/lib.macosx-11-arm64-3.9/bottleneck/_version.py
  set build/lib.macosx-11-arm64-3.9/bottleneck/_version.py to '1.4.0.dev0+117.gf2bc792.dirty'
  running build_ext
  running config
  clang -E -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -o _configtest.i _configtest.c
  removing: _configtest.c _configtest.i
  compiling '_configtest.c':
  
  #pragma clang diagnostic error "-Wattributes"
  
  int __attribute__((optimize("O3"))) have_attribute_optimize_opt_3(void*);
  
  int main(void)
  {
      return 0;
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -c _configtest.c -o _configtest.o
  _configtest.c:4:20: error: unknown attribute 'optimize' ignored [-Werror,-Wunknown-attributes]
  int __attribute__((optimize("O3"))) have_attribute_optimize_opt_3(void*);
                     ^
  1 error generated.
  failure.
  removing: _configtest.c _configtest.o
  compiling '_configtest.c':
  #include <math.h>
  
  
  int check(void) {
      return __builtin_isnan(0.);
  }
  
  int main(void)
  {
      return check();
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -c _configtest.c -o _configtest.o
  clang _configtest.o -o _configtest
  success!
  removing: _configtest.c _configtest.o _configtest
  compiling '_configtest.c':
  #include <math.h>
  
  
  int check(void) {
      return isnan(0.);
  }
  
  int main(void)
  {
      return check();
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -c _configtest.c -o _configtest.o
  clang _configtest.o -o _configtest
  success!
  removing: _configtest.c _configtest.o _configtest
  compiling '_configtest.c':
  #include <math.h>
  
  
  int check(void) {
      return _isnan(0.);
  }
  
  int main(void)
  {
      return check();
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -c _configtest.c -o _configtest.o
  _configtest.c:5:12: error: implicit declaration of function '_isnan' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      return _isnan(0.);
             ^
  1 error generated.
  failure.
  removing: _configtest.c _configtest.o
  compiling '_configtest.c':
  
  #ifndef __cplusplus
  static inline int static_func (void)
  {
      return 0;
  }
  inline int nostatic_func (void)
  {
      return 0;
  }
  #endif
  int main(void) {
      int r1 = static_func();
      int r2 = nostatic_func();
      return r1 + r2;
  }
  
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -c _configtest.c -o _configtest.o
  success!
  removing: _configtest.c _configtest.o
  building 'bottleneck.reduce' extension
  creating build/temp.macosx-11-arm64-3.9
  creating build/temp.macosx-11-arm64-3.9/bottleneck
  creating build/temp.macosx-11-arm64-3.9/bottleneck/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/include/python3.9 -Ibottleneck/src -Ibottleneck/include -c bottleneck/src/reduce.c -o build/temp.macosx-11-arm64-3.9/bottleneck/src/reduce.o -O2
  bottleneck/src/reduce_template.c:1316:25: error: use of undeclared identifier 'ai'
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ^
  bottleneck/src/reduce_template.c:1317:39: error: use of undeclared identifier 'ai'
                          f += bn_isnan(ai);
                                        ^
  bottleneck/src/reduce_template.c:1316:25: error: use of undeclared identifier 'ai'
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ^
  bottleneck/src/reduce_template.c:1317:39: error: use of undeclared identifier 'ai'
                          f += bn_isnan(ai);
                                        ^
  bottleneck/src/reduce_template.c:1520:25: error: use of undeclared identifier 'ai'
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ^
  bottleneck/src/reduce_template.c:1521:40: error: use of undeclared identifier 'ai'
                          f += !bn_isnan(ai);
                                         ^
  bottleneck/src/reduce_template.c:1520:25: error: use of undeclared identifier 'ai'
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ^
  bottleneck/src/reduce_template.c:1521:40: error: use of undeclared identifier 'ai'
                          f += !bn_isnan(ai);
                                         ^
  8 errors generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for Bottleneck
Failed to build Bottleneck
ERROR: Could not build wheels for Bottleneck which use PEP 517 and cannot be installed directly

NikZak avatar Sep 23 '21 13:09 NikZak

Ok so I added the constant declaration const npy_DTYPE0 ai at lines 1316 and 1520 in bottleneck/src/reduce_template.c and the build finished successfuly.

NikZak avatar Sep 23 '21 13:09 NikZak

Ok I reinstalled it as pip install -e . and ran pytest. All tests (209) passed with 1 warning. So I guess this solves the issue. I can make a PR if you confirm that my actions were correct.

=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.7, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/nikolay/Projects/source/utils/bottleneck, configfile: setup.cfg
plugins: hypothesis-6.14.3, anyio-2.2.0, cov-2.12.0, web3-5.19.0, xdist-1.34.0, eth-brownie-1.15.2, forked-1.3.0
collected 209 items                                                                                                                                                                                        

bottleneck/tests/input_modification_test.py .............................                                                                                                                            [ 13%]
bottleneck/tests/list_input_test.py .............................                                                                                                                                    [ 27%]
bottleneck/tests/memory_test.py .                                                                                                                                                                    [ 28%]
bottleneck/tests/move_test.py .................................                                                                                                                                      [ 44%]
bottleneck/tests/nonreduce_axis_test.py .........................                                                                                                                                    [ 55%]
bottleneck/tests/nonreduce_test.py ..............                                                                                                                                                    [ 62%]
bottleneck/tests/reduce_test.py ...........................................................                                                                                                          [ 90%]
bottleneck/tests/scalar_input_test.py ..................                                                                                                                                             [ 99%]
bottleneck/tests/test_template.py .                                                                                                                                                                  [100%]

============================================================================================= warnings summary =============================================================================================
bottleneck/tests/scalar_input_test.py::test_scalar_input[nanmean]
  /Users/nikolay/Projects/source/utils/bottleneck/bottleneck/tests/scalar_input_test.py:45: RuntimeWarning: Mean of empty slice
    desired = func0(scalar)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
===================================================================================== 209 passed, 1 warning in 27.98s ======================================================================================

NikZak avatar Sep 23 '21 13:09 NikZak

not work here. the error output is:

  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/aaronyang/miniforge3/envs/alpha/include -arch arm64 -I/Users/aaronyang/miniforge3/envs/alpha/include -arch arm64 -I/private/var/folders/b5/73vzvtdn4pn_8wt6rpd2tb_w0000gn/T/pip-build-env-igd1baec/overlay/lib/python3.8/site-packages/numpy/core/include -I/Users/aaronyang/miniforge3/envs/alpha/include/python3.8 -Ibottleneck/src -Ibottleneck/include -c bottleneck/src/reduce.c -o build/temp.macosx-11.0-arm64-3.8/bottleneck/src/reduce.o -O2
  bottleneck/src/reduce_template.c:1317:7: error: cannot assign to variable 'ai' with const-qualified type 'const npy_float64' (aka 'const double')
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ~~ ^
  bottleneck/src/reduce_template.c:1316:43: note: variable 'ai' declared const here
                          const npy_float64 ai;
                          ~~~~~~~~~~~~~~~~~~^~
  bottleneck/src/reduce_template.c:1317:7: error: cannot assign to variable 'ai' with const-qualified type 'const npy_float32' (aka 'const float')
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ~~ ^
  bottleneck/src/reduce_template.c:1316:43: note: variable 'ai' declared const here
                          const npy_float32 ai;
                          ~~~~~~~~~~~~~~~~~~^~
  bottleneck/src/reduce_template.c:1522:28: error: cannot assign to variable 'ai' with const-qualified type 'const npy_float64' (aka 'const double')
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ~~ ^
  bottleneck/src/reduce_template.c:1521:43: note: variable 'ai' declared const here
                          const npy_float64 ai;
                          ~~~~~~~~~~~~~~~~~~^~
  bottleneck/src/reduce_template.c:1522:28: error: cannot assign to variable 'ai' with const-qualified type 'const npy_float32' (aka 'const float')
                          ai = pa[vector_offset + i * LOOP_SIZE + j];
                          ~~ ^
  bottleneck/src/reduce_template.c:1521:43: note: variable 'ai' declared const here
                          const npy_float32 ai;
                          ~~~~~~~~~~~~~~~~~~^~
  4 errors generated.
  error: command 'gcc' failed with exit status 1

zillionare avatar Sep 27 '21 15:09 zillionare

my numpy version is 1.21.2, if it helps.

zillionare avatar Sep 27 '21 15:09 zillionare

I suggested const npy_DTYPE0 ai you put const npy_float64 ai And you also try to assign to a const. My guess - that's the reason To be clear line 1316 should be:

                        const npy_DTYPE0 ai = pa[vector_offset + i * LOOP_SIZE + j];

and same for the line 1520:

                        const npy_DTYPE0 ai = pa[vector_offset + i * LOOP_SIZE + j];

NikZak avatar Sep 27 '21 16:09 NikZak

sorry I have had a typo (npy_DTYPE0 -> npy_DYPE0) at my first try。

After apply your code above, it pass the compilation. Thanks!

zillionare avatar Sep 28 '21 02:09 zillionare

@NikZak I got the same issue on my side. Any timeline on when this fix will be merged with master (and published in new release)?

Is there already a PR for this?

XenonOrion avatar Dec 01 '21 18:12 XenonOrion

I tried the suggested solution above, with no luck. Seems like my environment cannot compile C code? After trying a multitude of things (conda and pip), I'm getting the following error: fatal error: 'Python.h' file not found even after installing gcc with brew.. Any hints to resolve this?

Guess I'll try to run with Rosetta2 for now.

XenonOrion avatar Dec 01 '21 19:12 XenonOrion

I managed to install bottleneck on my mac m1 by first installing llvm utilities with brew install llvm and then AR=/opt/homebrew/opt/llvm/bin/llvm-ar pip install bottleneck

yuriyarabskyy avatar Feb 10 '22 23:02 yuriyarabskyy

I am really eager to se a fix on this one. With my new Mac this reduce function is blocking my work.

ahysing avatar Aug 03 '22 07:08 ahysing

@ahysing I installed successfully bottleneck 1.2.1 on my M1 a couple of months ago. The later versions had the problem of this issue.

tomsen-san avatar Aug 19 '22 07:08 tomsen-san