かりんちゃんの随心日誌

随筆、旅行の話、温泉むすめの話、香港の話、言いたい放題

MAC(M3)環境でazure-iot-hubをインストール失敗の解決策

仕事のMacはM3なのですが、Azure IoTのテストをするためにazure-iot-hubをインストールしようとしたら、へんなエラーが現れた。

Building wheels for collected packages: uamqp
  Building wheel for uamqp (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for uamqp (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [148 lines of output]
      /private/var/folders/6j/_9yj3y8x29l2cr4z8vx08ynr0000gq/T/pip-build-env-v8zjv47z/overlay/lib/python3.12/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!
      
              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:
      
              License :: OSI Approved :: MIT License
      
              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************
      
      !!
        self._finalize_license_expression()
      running bdist_wheel
      running build
      running build_py
      creating build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/sender.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/address.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/compat.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/client.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/constants.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/session.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/receiver.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/__init__.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/message.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/types.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/connection.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/mgmt_operation.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/utils.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      copying uamqp/errors.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      creating build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/sender_async.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/session_async.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/client_async.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/__init__.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/utils.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/receiver_async.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/connection_async.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      copying uamqp/async_ops/mgmt_operation_async.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/async_ops
      creating build/lib.macosx-11.1-arm64-cpython-312/uamqp/authentication
      copying uamqp/authentication/__init__.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/authentication
      copying uamqp/authentication/common.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/authentication
      copying uamqp/authentication/cbs_auth.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/authentication
      copying uamqp/authentication/cbs_auth_async.py -> build/lib.macosx-11.1-arm64-cpython-312/uamqp/authentication
      running egg_info
      writing uamqp.egg-info/PKG-INFO
      writing dependency_links to uamqp.egg-info/dependency_links.txt
      writing requirements to uamqp.egg-info/requires.txt
      writing top-level names to uamqp.egg-info/top_level.txt
      reading manifest file 'uamqp.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE'
      writing manifest file 'uamqp.egg-info/SOURCES.txt'
      copying uamqp/c_uamqp.c -> build/lib.macosx-11.1-arm64-cpython-312/uamqp
      running build_ext
      will build uamqp in build/temp.macosx-11.1-arm64-cpython-312/cmake
      Building with generator flags: -G "Unix Makefiles"
      calling cmake /private/var/folders/6j/_9yj3y8x29l2cr4z8vx08ynr0000gq/T/pip-install-a0jmk6gs/uamqp_4fab5482f709418d820054174d5cbbe2/src/vendor/azure-uamqp-c/ -G "Unix Makefiles" -Duse_openssl:bool=OFF -Duse_default_uuid:bool=ON  -Duse_builtin_httpapi:bool=ON  -Dskip_samples:bool=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release
      CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
        Compatibility with CMake < 3.10 will be removed from a future version of
        CMake.
      
        Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
        to tell CMake that the project requires at least <min> but has been updated
        to work with policies introduced by <max> or earlier.
      
      
      -- The C compiler identification is AppleClang 16.0.0.16000026
      -- The CXX compiler identification is AppleClang 16.0.0.16000026
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /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: /usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      CMake Error at deps/azure-macro-utils-c/CMakeLists.txt:4 (cmake_minimum_required):
        Compatibility with CMake < 3.5 has been removed from CMake.
      
        Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
        to tell CMake that the project requires at least <min> but has been updated
        to work with policies introduced by <max> or earlier.
      
        Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
      
      
      -- Configuring incomplete, errors occurred!

どうやら依存してるuamqpの問題です。

最初はChatGPTに色々と聞いてみるが、ChatGPTの回答がどんどんおかしくなってきて、こりゃだめだな、と他に色々と当たってみた。 しかし、ヒントらしいヒントはGoogleにもないのでかなり難航してた。

最後の一言に「-DCMAKE_POLICY_VERSION_MINIMUM=3.5」にもしかして?と思ったけど、どう渡せばいいかわからず 色々検索してみたらやっと解決策を見つけました

https://github.com/Azure/azure-uamqp-python/issues/386#issuecomment-2783739275

% CFLAGS="-Wno-error=incompatible-function-pointer-types" CMAKE_POLICY_VERSION_MINIMUM=3.5 pip install uamqp==1.6.11
Collecting uamqp==1.6.11
  Using cached uamqp-1.6.11.tar.gz (4.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: certifi>=2017.4.17 in /Users/xxx/miniconda3/lib/python3.12/site-packages (from uamqp==1.6.11) (2025.1.31)
Building wheels for collected packages: uamqp
  Building wheel for uamqp (pyproject.toml) ... done
  Created wheel for uamqp: filename=uamqp-1.6.11-cp312-cp312-macosx_11_0_arm64.whl size=1212787 sha256=432828ec5fca27f2a220c8ff32be3a9b76c78f107c1ee96eeb7fb9c6d985f7ae
  Stored in directory: /Users/xxx/Library/Caches/pip/wheels/3a/56/d7/39becd18bef71a4bea6753f6ed4f4bdbf8df686652882ce3e8
Successfully built uamqp
Installing collected packages: uamqp
Successfully installed uamqp-1.6.11

無事にインストールを成功です!

エラーを見る限り、Cmakeのポリシーチェックに通じなかったみたいですが、これだとM3関係なくないか…?

ちなみにChatGPTが何がだめというと、「uamqp>=1.6.14」とか世の中に存在しないバージョンを提示していた。こいつ未来に生きてんな。