DanielBok / nlopt-python

A project to package the NLOpt library to wheels
Other
29 stars 14 forks source link

Failed to install via pip on M1 Mac #13

Open BolunDai0216 opened 2 years ago

BolunDai0216 commented 2 years ago

Hi,

I was trying to install this on an M1 Macbook and got the following error

error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [295 lines of output]
      running bdist_wheel
      running build
      running build_ext
      cmake version 3.23.0

      CMake suite maintained and supported by Kitware (kitware.com/cmake).
      -- The C compiler identification is AppleClang 13.1.6.13160021
      -- The CXX compiler identification is AppleClang 13.1.6.13160021
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - 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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonInterp: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 (found version "3.8.9")
      -- Found Python includes: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8
      -- Found Python libs: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      CMake Deprecation Warning at extern/nlopt/CMakeLists.txt:15 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      -- NLopt version 2.6.2
      -- Looking for dlfcn.h
      -- Looking for dlfcn.h - found
      -- Looking for getopt.h
      -- Looking for getopt.h - found
      -- Looking for unistd.h
      -- Looking for unistd.h - found
      -- Looking for string.h
      -- Looking for string.h - found
      -- Looking for strings.h
      -- Looking for strings.h - found
      -- Looking for inttypes.h
      -- Looking for inttypes.h - found
      -- Looking for memory.h
      -- Looking for memory.h - found
      -- Looking for stdlib.h
      -- Looking for stdlib.h - found
      -- Looking for stdint.h
      -- Looking for stdint.h - found
      -- Looking for time.h
      -- Looking for time.h - found
      -- Looking for sys/types.h
      -- Looking for sys/types.h - found
      -- Looking for sys/stat.h
      -- Looking for sys/stat.h - found
      -- Looking for sys/time.h
      -- Looking for sys/time.h - found
      -- Looking for getpid
      -- Looking for getpid - found
      -- Looking for syscall
      -- Looking for syscall - found
      -- Looking for isinf
      -- Looking for isinf - found
      -- Looking for isnan
      -- Looking for isnan - found
      -- Looking for gettimeofday
      -- Looking for gettimeofday - found
      -- Looking for qsort_r
      -- Looking for qsort_r - found
      -- Looking for time
      -- Looking for time - found
      -- Looking for copysign
      -- Looking for copysign - found
      -- Looking for stddef.h
      -- Looking for stddef.h - found
      -- Check size of uint32_t
      -- Check size of uint32_t - done
      -- Check size of unsigned int
      -- Check size of unsigned int - done
      -- Check size of unsigned long
      -- Check size of unsigned long - done
      -- Looking for sqrt in m
      -- Looking for sqrt in m - found
      -- Looking for fpclassify
      -- Looking for fpclassify - TRUE
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE - Success
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE - Failed
      -- Looking for __cplusplus
      -- Looking for __cplusplus - found
      -- Performing Test SUPPORTS_STDCXX11
      -- Performing Test SUPPORTS_STDCXX11 - Success
      -- Performing Test HAS_FPIC
      -- Performing Test HAS_FPIC - Success
      -- Found PythonLibs: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib (found suitable exact version "3.8.9")
      -- Found NumPy: /Users/bolundai/Library/Python/3.8/lib/python/site-packages/numpy/core/include (found version "1.22.3")
      -- Could NOT find Guile (missing: GUILE_EXECUTABLE GUILE_ROOT_DIR GUILE_INCLUDE_DIRS GUILE_LIBRARIES)
      -- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
      -- Could NOT find Octave (missing: OCTAVE_EXECUTABLE OCTAVE_ROOT_DIR OCTAVE_INCLUDE_DIRS OCTAVE_LIBRARIES)
      -- Found Matlab: /Applications/MATLAB_R2022a.app/extern/include (found version "9.12") found components: MX_LIBRARY MAIN_PROGRAM
      -- Performing Test HAS_MINUS_PTHREAD
      -- Performing Test HAS_MINUS_PTHREAD - Success
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/build/temp.macosx-10.14-arm64-3.8
      [  3%] Generating nlopt.f
      [  3%] Generating nlopt.hpp
      CMake Deprecation Warning at /private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/extern/nlopt/cmake/generate-fortran.cmake:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      CMake Deprecation Warning at /private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/extern/nlopt/cmake/generate-cpp.cmake:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      [  3%] Built target generate-fortran
      [  3%] Built target generate-cpp
      [  7%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/DIRect.c.o
      [  7%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/direct_wrap.c.o
      [  9%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/DIRserial.c.o
      [ 11%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/DIRsubrout.c.o
      [ 12%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/cdirect/cdirect.c.o
      [ 14%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/cdirect/hybrid.c.o
      [ 16%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/praxis/praxis.c.o
      [ 18%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/plis.c.o
      [ 20%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/plip.c.o
      [ 22%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/pnet.c.o
      [ 24%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/mssubs.c.o
      [ 25%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/pssubs.c.o
      [ 27%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/crs/crs.c.o
      [ 29%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/mlsl/mlsl.c.o
      [ 31%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/mma/mma.c.o
      [ 33%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/mma/ccsa_quadratic.c.o
      [ 35%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/cobyla/cobyla.c.o
      [ 37%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/newuoa/newuoa.c.o
      [ 38%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/neldermead/nldrmd.c.o
      [ 40%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/neldermead/sbplx.c.o
      [ 42%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/auglag/auglag.c.o
      [ 44%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/bobyqa/bobyqa.c.o
      [ 46%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/isres/isres.c.o
      [ 48%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/slsqp/slsqp.c.o
      [ 50%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/esch/esch.c.o
      [ 51%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/general.c.o
      [ 53%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/options.c.o
      [ 55%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/optimize.c.o
      [ 57%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/deprecated.c.o
      [ 59%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/f77api.c.o
      [ 61%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/mt19937ar.c.o
      [ 62%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/sobolseq.c.o
      [ 64%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/timer.c.o
      [ 66%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/stop.c.o
      [ 68%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/redblack.c.o
      [ 70%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/qsort_r.c.o
      [ 72%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/rescale.c.o
      [ 74%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/global.cc.o
      [ 75%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/linalg.cc.o
      [ 77%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/local.cc.o
      [ 79%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/stogo.cc.o
      [ 81%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/tools.cc.o
      [ 83%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/evolvent.cc.o
      [ 85%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/solver.cc.o
      [ 87%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/local_optimizer.cc.o
      [ 88%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/ags.cc.o
      [ 90%] Linking CXX static library libnlopt.a
      [ 94%] Built target nlopt
      [ 98%] Building C object extern/nlopt/src/octave/CMakeFiles/nlopt_optimize-mex.dir/Applications/MATLAB_R2022a.app/extern/version/c_mexapi_version.c.o
      [ 98%] Building C object extern/nlopt/src/octave/CMakeFiles/nlopt_optimize-mex.dir/nlopt_optimize-mex.c.o
      [100%] Linking CXX shared library ../../../../../lib.macosx-10.14-arm64-3.8/nlopt/nlopt_optimize.mexmaci64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/extern/bin/maci64/libMatlabEngine.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/bin/maci64/libMatlabDataArray.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/bin/maci64/libmx.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/bin/maci64/libmex.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      Undefined symbols for architecture arm64:
        "_mexCallMATLABWithObject", referenced from:
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mexErrMsgTxt", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mexPrintf", referenced from:
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mexWarnMsgTxt", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
        "_mxCalloc", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxCreateDoubleMatrix_730", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxDestroyArray", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxFree", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxGetCell_730", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxGetField_730", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxGetM", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxGetN", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxGetPr", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxGetScalar", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
        "_mxGetString_730", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsCell", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsChar", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsComplex", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxIsDouble", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxIsFunctionHandle", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsNaN", referenced from:
            _user_function in nlopt_optimize-mex.c.o
        "_mxIsNumeric", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
        "_mxIsStruct", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
      ld: symbol(s) not found for architecture arm64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      make[2]: *** [../lib.macosx-10.14-arm64-3.8/nlopt/nlopt_optimize.mexmaci64] Error 1
      make[1]: *** [extern/nlopt/src/octave/CMakeFiles/nlopt_optimize-mex.dir/all] Error 2
      make: *** [all] Error 2
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 85, in <module>
          setup(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
          return distutils.core.setup(**attrs)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 28, in run
          self.build_extension(ext)
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 68, in build_extension
          cmd("cmake", "--build", ".", *build_args, cwd=self.build_temp)
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 65, in cmd
          subp.check_call([str(x) for x in args], **kwds)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for nlopt
  error: subprocess-exited-with-error

  × Running setup.py install for nlopt did not run successfully.
  │ exit code: 1
  ╰─> [297 lines of output]
      running install
      running build
      running build_ext
      cmake version 3.23.0

      CMake suite maintained and supported by Kitware (kitware.com/cmake).
      -- The C compiler identification is AppleClang 13.1.6.13160021
      -- The CXX compiler identification is AppleClang 13.1.6.13160021
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - 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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonInterp: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 (found version "3.8.9")
      -- Found Python includes: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8
      -- Found Python libs: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      CMake Deprecation Warning at extern/nlopt/CMakeLists.txt:15 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      -- NLopt version 2.6.2
      -- Looking for dlfcn.h
      -- Looking for dlfcn.h - found
      -- Looking for getopt.h
      -- Looking for getopt.h - found
      -- Looking for unistd.h
      -- Looking for unistd.h - found
      -- Looking for string.h
      -- Looking for string.h - found
      -- Looking for strings.h
      -- Looking for strings.h - found
      -- Looking for inttypes.h
      -- Looking for inttypes.h - found
      -- Looking for memory.h
      -- Looking for memory.h - found
      -- Looking for stdlib.h
      -- Looking for stdlib.h - found
      -- Looking for stdint.h
      -- Looking for stdint.h - found
      -- Looking for time.h
      -- Looking for time.h - found
      -- Looking for sys/types.h
      -- Looking for sys/types.h - found
      -- Looking for sys/stat.h
      -- Looking for sys/stat.h - found
      -- Looking for sys/time.h
      -- Looking for sys/time.h - found
      -- Looking for getpid
      -- Looking for getpid - found
      -- Looking for syscall
      -- Looking for syscall - found
      -- Looking for isinf
      -- Looking for isinf - found
      -- Looking for isnan
      -- Looking for isnan - found
      -- Looking for gettimeofday
      -- Looking for gettimeofday - found
      -- Looking for qsort_r
      -- Looking for qsort_r - found
      -- Looking for time
      -- Looking for time - found
      -- Looking for copysign
      -- Looking for copysign - found
      -- Looking for stddef.h
      -- Looking for stddef.h - found
      -- Check size of uint32_t
      -- Check size of uint32_t - done
      -- Check size of unsigned int
      -- Check size of unsigned int - done
      -- Check size of unsigned long
      -- Check size of unsigned long - done
      -- Looking for sqrt in m
      -- Looking for sqrt in m - found
      -- Looking for fpclassify
      -- Looking for fpclassify - TRUE
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE - Success
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE
      -- Performing Test HAVE_THREAD_LOCAL_STORAGE - Failed
      -- Looking for __cplusplus
      -- Looking for __cplusplus - found
      -- Performing Test SUPPORTS_STDCXX11
      -- Performing Test SUPPORTS_STDCXX11 - Success
      -- Performing Test HAS_FPIC
      -- Performing Test HAS_FPIC - Success
      -- Found PythonLibs: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib (found suitable exact version "3.8.9")
      -- Found NumPy: /Users/bolundai/Library/Python/3.8/lib/python/site-packages/numpy/core/include (found version "1.22.3")
      -- Could NOT find Guile (missing: GUILE_EXECUTABLE GUILE_ROOT_DIR GUILE_INCLUDE_DIRS GUILE_LIBRARIES)
      -- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
      -- Could NOT find Octave (missing: OCTAVE_EXECUTABLE OCTAVE_ROOT_DIR OCTAVE_INCLUDE_DIRS OCTAVE_LIBRARIES)
      -- Found Matlab: /Applications/MATLAB_R2022a.app/extern/include (found version "9.12") found components: MX_LIBRARY MAIN_PROGRAM
      -- Performing Test HAS_MINUS_PTHREAD
      -- Performing Test HAS_MINUS_PTHREAD - Success
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/build/temp.macosx-10.14-arm64-3.8
      [  3%] Generating nlopt.f
      [  3%] Generating nlopt.hpp
      CMake Deprecation Warning at /private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/extern/nlopt/cmake/generate-fortran.cmake:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      CMake Deprecation Warning at /private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/extern/nlopt/cmake/generate-cpp.cmake:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      [  3%] Built target generate-fortran
      [  3%] Built target generate-cpp
      [  7%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/DIRect.c.o
      [  7%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/direct_wrap.c.o
      [  9%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/DIRserial.c.o
      [ 11%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/direct/DIRsubrout.c.o
      [ 12%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/cdirect/cdirect.c.o
      [ 14%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/cdirect/hybrid.c.o
      [ 16%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/praxis/praxis.c.o
      [ 18%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/plis.c.o
      [ 20%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/plip.c.o
      [ 22%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/pnet.c.o
      [ 24%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/mssubs.c.o
      [ 25%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/luksan/pssubs.c.o
      [ 27%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/crs/crs.c.o
      [ 29%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/mlsl/mlsl.c.o
      [ 31%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/mma/mma.c.o
      [ 33%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/mma/ccsa_quadratic.c.o
      [ 35%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/cobyla/cobyla.c.o
      [ 37%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/newuoa/newuoa.c.o
      [ 38%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/neldermead/nldrmd.c.o
      [ 40%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/neldermead/sbplx.c.o
      [ 42%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/auglag/auglag.c.o
      [ 44%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/bobyqa/bobyqa.c.o
      [ 46%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/isres/isres.c.o
      [ 48%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/slsqp/slsqp.c.o
      [ 50%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/esch/esch.c.o
      [ 51%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/general.c.o
      [ 53%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/options.c.o
      [ 55%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/optimize.c.o
      [ 57%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/deprecated.c.o
      [ 59%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/api/f77api.c.o
      [ 61%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/mt19937ar.c.o
      [ 62%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/sobolseq.c.o
      [ 64%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/timer.c.o
      [ 66%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/stop.c.o
      [ 68%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/redblack.c.o
      [ 70%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/qsort_r.c.o
      [ 72%] Building C object extern/nlopt/CMakeFiles/nlopt.dir/src/util/rescale.c.o
      [ 74%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/global.cc.o
      [ 75%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/linalg.cc.o
      [ 77%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/local.cc.o
      [ 79%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/stogo.cc.o
      [ 81%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/stogo/tools.cc.o
      [ 83%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/evolvent.cc.o
      [ 85%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/solver.cc.o
      [ 87%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/local_optimizer.cc.o
      [ 88%] Building CXX object extern/nlopt/CMakeFiles/nlopt.dir/src/algs/ags/ags.cc.o
      [ 90%] Linking CXX static library libnlopt.a
      [ 94%] Built target nlopt
      [ 98%] Building C object extern/nlopt/src/octave/CMakeFiles/nlopt_optimize-mex.dir/Applications/MATLAB_R2022a.app/extern/version/c_mexapi_version.c.o
      [ 98%] Building C object extern/nlopt/src/octave/CMakeFiles/nlopt_optimize-mex.dir/nlopt_optimize-mex.c.o
      [100%] Linking CXX shared library ../../../../../lib.macosx-10.14-arm64-3.8/nlopt/nlopt_optimize.mexmaci64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/extern/bin/maci64/libMatlabEngine.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/bin/maci64/libMatlabDataArray.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/bin/maci64/libmex.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      ld: warning: ignoring file /Applications/MATLAB_R2022a.app/bin/maci64/libmx.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
      Undefined symbols for architecture arm64:
        "_mexCallMATLABWithObject", referenced from:
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mexErrMsgTxt", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mexPrintf", referenced from:
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mexWarnMsgTxt", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
        "_mxCalloc", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxCreateDoubleMatrix_730", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxDestroyArray", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxFree", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxGetCell_730", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxGetField_730", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxGetM", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxGetN", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxGetPr", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxGetScalar", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
        "_mxGetString_730", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsCell", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsChar", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsComplex", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxIsDouble", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
            _user_pre in nlopt_optimize-mex.c.o
        "_mxIsFunctionHandle", referenced from:
            _mexFunction in nlopt_optimize-mex.c.o
        "_mxIsNaN", referenced from:
            _user_function in nlopt_optimize-mex.c.o
        "_mxIsNumeric", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
            _user_function in nlopt_optimize-mex.c.o
        "_mxIsStruct", referenced from:
            _make_opt in nlopt_optimize-mex.c.o
            _mexFunction in nlopt_optimize-mex.c.o
      ld: symbol(s) not found for architecture arm64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      make[2]: *** [../lib.macosx-10.14-arm64-3.8/nlopt/nlopt_optimize.mexmaci64] Error 1
      make[1]: *** [extern/nlopt/src/octave/CMakeFiles/nlopt_optimize-mex.dir/all] Error 2
      make: *** [all] Error 2
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 85, in <module>
          setup(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
          return distutils.core.setup(**attrs)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
          return orig.install.run(self)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/install.py", line 561, in run
          self.run_command('build')
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 28, in run
          self.build_extension(ext)
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 68, in build_extension
          cmd("cmake", "--build", ".", *build_args, cwd=self.build_temp)
        File "/private/var/folders/rq/md19ny9502q_prjm4sf7n0gr0000gn/T/pip-install-1ti436ln/nlopt_6161bd3a13584516af2ec72a8107a5b8/setup.py", line 65, in cmd
          subp.check_call([str(x) for x in args], **kwds)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> nlopt

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Is this an issue with the M1 mac or something else. Is it possible to help me take a look at this?

Thanks in advance!

romanWSgit commented 2 years ago

I am having the same issue on an M1 Mac.

The only solution I have found so far is to install build nlpot as described in the

NLopt Documentation ( LINK )

and on

Stackoverflow ( LINK ) (the post by hoefling helped me a lot).

This works without problems but is a bit cumbersome.

joamatab commented 2 years ago

conda install nlopt also works

How can we fix the pypi install for M1?

see https://github.com/flexcompute/tidy3d/issues/441

defencedog commented 1 year ago

I was successfull on Android ARM64 Termux Python3.9 @ https://github.com/stevengj/nlopt/issues/478#issuecomment-1312962575

jewaniuk commented 1 year ago

I have an M1 mac and am wondering if there is any way I can help with this, as one of my python projects depends on nlopt and it has been a pain to compile myself and for others who want to collaborate. As far as I understand, you merely need someone with an M1 mac to generate the tarball or wheel file and then you can add that to pypi, right?

rscircus commented 11 months ago

+1 here. It's the same for M2.

hakonanes commented 10 months ago

I see a similar error on mac with M3.

hf-krechan commented 8 months ago

I have the same issue and it would be great if we can solve this issue. GitHub has now runners for ARM architecture. In the cadquery repository they use also a GitHub action to build wheels for macOS-arm64.

https://github.com/CadQuery/ocp-build-system/pull/22/files

hf-krechan commented 8 months ago

Just in case if someone like does also not know about mamba. Mamba is a fast, robust, and cross-platform package manager. And with this you can install nlopt on a M1 machine.

Install Mamba

You can install it with

brew install --cask mambaforge

After the installation you need to run

mamba init "$(basename "${SHELL}")"

Create a Mamba Environment

Instead of using venv you use mamba to create a virtual environment.

mamba create --prefix ./.mamba python=3.11

Python 3.11 is the latest version at the moment. I guess it is necessary that you have Python 3.11 installed already.

Activate the conda environment with


mamba activate ./.mamba

Now you can install nlopt with

mamba install nlopt

If you need a package which is not available in the conda repositories, you can still use pip. But be careful with this approach, it can easily lead to version conflicts.