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

Pip installation fails on macOS with M1 chip #391

Closed
PFischbeck opened this issue Sep 14, 2022 · 5 comments
Closed

Pip installation fails on macOS with M1 chip #391

PFischbeck opened this issue Sep 14, 2022 · 5 comments

Comments

@PFischbeck
Copy link

When trying to install clingo with pip install clingo, it fails because skbuild is not found. After manually installing this dependency (pip install scikit-build), it still fails:


Collecting clingo
  Using cached clingo-5.6.0.tar.gz (1.8 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting cffi
  Using cached cffi-1.15.1-cp310-cp310-macosx_11_0_arm64.whl (174 kB)
Collecting pycparser
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Building wheels for collected packages: clingo
  Building wheel for clingo (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for clingo (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [172 lines of output]
      Error in sitecustomize; set PYTHONVERBOSE for traceback:
      AssertionError:
      Error in sitecustomize; set PYTHONVERBOSE for traceback:
      AssertionError:
      Error in sitecustomize; set PYTHONVERBOSE for traceback:
      AssertionError:
      Not searching for unused variables given on the command line.
      -- The C compiler identification is GNU 12.2.0
      -- Checking whether C compiler has -isysroot
      -- Checking whether C compiler has -isysroot - yes
      -- Checking whether C compiler supports OSX deployment target flag
      -- Checking whether C compiler supports OSX deployment target flag - yes
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /opt/homebrew/bin/gcc-12 - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- The CXX compiler identification is GNU 12.2.0
      -- Checking whether CXX compiler has -isysroot
      -- Checking whether CXX compiler has -isysroot - yes
      -- Checking whether CXX compiler supports OSX deployment target flag
      -- Checking whether CXX compiler supports OSX deployment target flag - yes
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /opt/homebrew/bin/g++-12 - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/_cmake_test_compile/build
      Error in sitecustomize; set PYTHONVERBOSE for traceback:
      AssertionError:
      -- The C compiler identification is GNU 12.2.0
      -- The CXX compiler identification is GNU 12.2.0
      -- Checking whether C compiler has -isysroot
      -- Checking whether C compiler has -isysroot - yes
      -- Checking whether C compiler supports OSX deployment target flag
      -- Checking whether C compiler supports OSX deployment target flag - yes
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /opt/homebrew/bin/gcc-12 - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Checking whether CXX compiler has -isysroot
      -- Checking whether CXX compiler has -isysroot - yes
      -- Checking whether CXX compiler supports OSX deployment target flag
      -- Checking whether CXX compiler supports OSX deployment target flag - yes
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /opt/homebrew/bin/g++-12 - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonInterp: /opt/homebrew/Cellar/python@3.10/3.10.6_2/bin/python3.10 (found version "3.10.6")
      -- Found PythonLibs: /opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib (found suitable version "3.10.6", minimum required is "3.6")
      -- Could NOT find BISON: Found unsuitable version "2.3", but required is at least "2.5" (found /usr/bin/bison)
      -- Could NOT find RE2C (missing: RE2C_EXECUTABLE) (Required is at least version "0.101")
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
      -- Found Threads: TRUE
      -- Potassco is not installed - using local copy
      -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
      -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
      Error in sitecustomize; set PYTHONVERBOSE for traceback:
      AssertionError:
      -- Configuring done
      -- Generating done
      CMake Warning:
        Manually-specified variables were not used by the project:

          PYTHON_NumPy_INCLUDE_DIRS
          Python3_EXECUTABLE
          Python3_INCLUDE_DIR
          Python3_LIBRARY
          Python3_NumPy_INCLUDE_DIRS
          Python_INCLUDE_DIR
          Python_LIBRARY
          Python_NumPy_INCLUDE_DIRS
          SKBUILD


      -- Build files have been written to: /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/_skbuild/macosx-12.0-arm64-3.10/cmake-build
      Error in sitecustomize; set PYTHONVERBOSE for traceback:
      AssertionError:
      [1/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/clingo.cpp.o
      [2/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/string_convert.cpp.o
      FAILED: clasp/libpotassco/src/CMakeFiles/libpotassco.dir/string_convert.cpp.o
      /opt/homebrew/bin/g++-12  -I/private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.0 -fPIC -fvisibility=hidden -std=gnu++11 -MD -MT clasp/libpotassco/src/CMakeFiles/libpotassco.dir/string_convert.cpp.o -MF clasp/libpotassco/src/CMakeFiles/libpotassco.dir/string_convert.cpp.o.d -o clasp/libpotassco/src/CMakeFiles/libpotassco.dir/string_convert.cpp.o -c /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:58:9: error: 'locale_t' does not name a type
         58 | typedef locale_t my_locale_t;
            |         ^~~~~~~~
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:59:8: error: 'my_locale_t' does not name a type
         59 | inline my_locale_t default_locale() { return newlocale(LC_ALL_MASK, "C", 0); }
            |        ^~~~~~~~~~~
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:63:9: error: 'my_locale_t' does not name a type
         63 |         my_locale_t loc_;
            |         ^~~~~~~~~~~
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp: In destructor 'LocaleHolder::~LocaleHolder()':
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:62:38: error: 'loc_' was not declared in this scope
         62 |         ~LocaleHolder() { freelocale(loc_);  }
            |                                      ^~~~
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:62:27: error: 'freelocale' was not declared in this scope; did you mean 'setlocale'?
         62 |         ~LocaleHolder() { freelocale(loc_);  }
            |                           ^~~~~~~~~~
            |                           setlocale
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp: At global scope:
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:64:24: error: 'default_locale' was not declared in this scope; did you mean 'default_locale_g'?
         64 | } default_locale_g = { default_locale() };
            |                        ^~~~~~~~~~~~~~
            |                        default_locale_g
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp: In function 'int Potassco::xconvert(const char*, double&, const char**, int)':
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:230:50: error: 'struct LocaleHolder' has no member named 'loc_'
        230 |         out = strtod_l(x, &err, default_locale_g.loc_);
            |                                                  ^~~~
      /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/clasp/libpotassco/src/string_convert.cpp:230:15: error: 'strtod_l' was not declared in this scope; did you mean 'strtoull'?
        230 |         out = strtod_l(x, &err, default_locale_g.loc_);
            |               ^~~~~~~~
            |               strtoull
      [3/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/rule_utils.cpp.o
      [4/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/match_basic_types.cpp.o
      [5/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/aspif.cpp.o
      [6/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/application.cpp.o
      [7/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/theory_data.cpp.o
      [8/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/smodels.cpp.o
      [9/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/convert.cpp.o
      [10/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/aspif_text.cpp.o
      [11/102] Building CXX object clasp/libpotassco/src/CMakeFiles/libpotassco.dir/program_options.cpp.o
      ninja: build stopped: subcommand failed.
        File "/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 645, in setup
          cmkr.make(make_args, install_target=cmake_install_target, env=env)
        File "/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/skbuild/cmaker.py", line 680, in make
          self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
        File "/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/skbuild/cmaker.py", line 704, in make_impl
          raise SKBuildError(


      --------------------------------------------------------------------------------
      -- Trying "Ninja" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "Ninja" generator - success
      --------------------------------------------------------------------------------

      Configuring Project
        Working directory:
          /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/_skbuild/macosx-12.0-arm64-3.10/cmake-build
        Command:
          cmake /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/_skbuild/macosx-12.0-arm64-3.10/cmake-install -DPYTHON_VERSION_STRING:STRING=3.10.6 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/skbuild/resources/cmake -DPython3_EXECUTABLE:FILEPATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/bin/python3.10 -DPython3_INCLUDE_DIR:PATH=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -DPython3_LIBRARY:PATH=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib -DPython3_NumPy_INCLUDE_DIRS:PATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/include -DPython_EXECUTABLE:FILEPATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/bin/python3.10 -DPython_INCLUDE_DIR:PATH=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -DPython_LIBRARY:PATH=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib -DPython_NumPy_INCLUDE_DIRS:PATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/include -DPYTHON_EXECUTABLE:FILEPATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/bin/python3.10 -DPYTHON_INCLUDE_DIR:PATH=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -DPYTHON_LIBRARY:PATH=/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib -DPYTHON_NumPy_INCLUDE_DIRS:PATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/include -DCMAKE_MAKE_PROGRAM:FILEPATH=/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ninja/data/bin/ninja -DCLINGO_MANAGE_RPATH=OFF -DCLINGO_BUILD_APPS=OFF -DCLINGO_BUILD_WITH_PYTHON=pip -DCLINGO_BUILD_WITH_LUA=OFF -DPYCLINGO_INSTALL_DIR=libpyclingo -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=12.0 -DCMAKE_OSX_ARCHITECTURES:STRING=arm64

      Traceback (most recent call last):

      An error occurred while building with CMake.
        Command:
          cmake --build . --target install --config Release --
        Install target:
          install
        Source directory:
          /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c
        Working directory:
          /private/var/folders/qc/076rcjln3g9c295t2m5dxcm40000gn/T/pip-install-iqstvmuc/clingo_6b952882bef84f01ad03ec92d511457c/_skbuild/macosx-12.0-arm64-3.10/cmake-build
      Please check the install target is valid and see CMake's output for more information.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for clingo
Failed to build clingo
ERROR: Could not build wheels for clingo, which is required to install pyproject.toml-based projects

I am on macOS 12.5.1, with an M1 chip, Python 3.10, pip 22.2.2, G++ 12.2.0.

Installation via homebrew works fine, but I want to include clingo as a pip dependency in another project.

@rkaminsk
Copy link
Member

There are conda packages for clingo for ARM Macs. My guess is that there is some difference between the clang/gcc compilers. If you use the native compiler, clang, it should go through. One could probably also add #include <xlocale.h> plus some other small changes to make it work.

On this note, we have Actions that build clingo pip packages for various platforms. There is probably also a way to build for ARM Macs. Unfortunately, I don't have an ARM Mac so it is hard for me to test. A PR or an example project compiling clasp using Github Actions targeting ARM macs would really help. Then I could extend the current actions to build read to use binary wheels.

@rkaminsk
Copy link
Member

Maybe the whole pip package building could be automated better using cibuildwheel. It seems to support building for ARM out-of-the box.

@rkaminsk
Copy link
Member

Using cibuildwheel simplifies deployment a lot. Since there was a (small) bug in the last clingo release, I'll do another release soon that will then include arm64 wheels for macos. I just have to iron out some remaining rough edges.

@rkaminsk
Copy link
Member

Done, wheels will be online in a couple of hours.

@PFischbeck
Copy link
Author

Thanks a lot!

This issue was closed.
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

No branches or pull requests

2 participants